mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 14:43:01 +02:00
Enable DTZ005: add timezone to datetime.now() calls
This commit is contained in:
parent
0d75d68c9c
commit
60cf90a699
@ -1,7 +1,7 @@
|
||||
"""Generate random colorful JPEG images with configurable parameters."""
|
||||
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
@ -125,7 +125,7 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
|
||||
# Create folder named after the current timestamp
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
timestamp = datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S")
|
||||
folder = f"generated_images_{timestamp}"
|
||||
|
||||
# Display used parameters
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Requires user to log their workout to unlock the screen.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@ -635,7 +635,7 @@ class ScreenLocker:
|
||||
with open(self.log_file) as f:
|
||||
logs = json.load(f)
|
||||
|
||||
today = datetime.now().strftime("%Y-%m-%d")
|
||||
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
||||
return today in logs
|
||||
except (OSError, json.JSONDecodeError):
|
||||
return False
|
||||
@ -652,9 +652,9 @@ class ScreenLocker:
|
||||
logs = {}
|
||||
|
||||
# Add today's workout
|
||||
today = datetime.now().strftime("%Y-%m-%d")
|
||||
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
||||
logs[today] = {
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"timestamp": datetime.now(tz=timezone.utc).isoformat(),
|
||||
"workout_data": self.workout_data,
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,6 @@ ignore = [
|
||||
"S311", # suspicious-non-cryptographic-random - not security critical
|
||||
"S310", # suspicious-url-open - acceptable for scripts
|
||||
"S110", # try-except-pass - common pattern in scripts
|
||||
"DTZ005", # datetime.now without tz - acceptable for local scripts
|
||||
"PERF401", # manual-list-comprehension - style preference
|
||||
"RUF005", # collection-literal-concatenation - style preference
|
||||
"SIM102", # collapsible-if - style preference
|
||||
|
||||
Loading…
Reference in New Issue
Block a user