1
0

Parse datetimes to UTC.

This commit is contained in:
Jon Michael Aanes 2024-11-24 18:44:04 +01:00
parent ec27c7e4e0
commit 91e5562298
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 6 additions and 2 deletions

View File

@ -211,6 +211,9 @@ def import_watched_series_csv_from_file(vault: ObsidianVault) -> int:
def import_played_games_csv_from_file(vault: ObsidianVault) -> int:
data_path = Path('output/games_played.csv')
if not data_path.exists():
logger.warning('Skipping import of played games: %s is missing', data_path)
return 0
return import_activity_sample_csv_from_file(
vault,
data_path,

View File

@ -67,7 +67,7 @@ def parse_time(text: str) -> datetime.datetime:
if time.tzinfo is None:
msg = 'Could not parse timezone: ' + text
raise RuntimeError(msg)
return time
return time.astimezone(datetime.UTC)
def parse_date(text: str) -> datetime.date:

View File

@ -20,7 +20,8 @@ def csv_safe_value(v: Any) -> str:
return v.geturl()
if isinstance(v, datetime.datetime):
if v.tzinfo is None or v.tzinfo != datetime.UTC:
raise ValueError(v)
msg = f'Timezone must be UTC: {v}'
raise ValueError(msg)
return str(v)