Parse datetimes to UTC.
This commit is contained in:
parent
ec27c7e4e0
commit
91e5562298
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user