Use local timezone

This commit is contained in:
makeworld 2020-12-04 19:07:21 -05:00
parent 2c58b4a576
commit 371bec6227
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) <year> <owner>. All rights reserved.
Copyright (c) 2020 Solderpunk. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

View File

@ -113,7 +113,8 @@ def get_update_time(filename, time_func):
basename = os.path.basename(filename)
if re.search("^[0-9]{4}-[01][0-9]-[0-3][0-9]", basename):
date = basename[0:10] + " Z" # Add UTC marker
return datetime.datetime.strptime(date, "%Y-%m-%d %z")
# Put in user's local timezone
return datetime.datetime.strptime(date, "%Y-%m-%d %z").replace(tzinfo=datetime.timezone.utc).astimezone(tz=None)
else:
updated = time_func(filename)
return datetime.datetime.fromtimestamp(updated, tz=datetime.timezone.utc)