1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Use system timezone as TIMEZONE setting default

This commit is contained in:
FoxxMD 2020-12-01 15:48:56 -05:00
parent e6535eb6bc
commit 75d8251a29
2 changed files with 10 additions and 3 deletions

View File

@ -71,8 +71,10 @@ CHARTS_DISPLAY_TILES = false
# prevent visitors from mindlessly clicking on those options and hogging your cpu
DISCOURAGE_CPU_HEAVY_STATS = false
# offset to UTC
TIMEZONE = 0
# Use system timezone by default. Otherwise specify as either:
# offset in hours IE 0 = UTC, -5 = EST
# IANA time zone IE America/New_York = EST
TIMEZONE = None
[Fluff]

View File

@ -6,8 +6,13 @@ from os.path import commonprefix
import math
from doreah.settings import get_settings
# use system timezone as default
# https://stackoverflow.com/a/39079819/1469797
TIMEZONE = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
# if user specifies a timezone in settings then try to use that instead
OFFSET = get_settings("TIMEZONE")
TIMEZONE = timezone(timedelta(hours=OFFSET))
if OFFSET is not None:
TIMEZONE = timezone(timedelta(hours=OFFSET))
FIRST_SCROBBLE = int(datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).timestamp())