From e475b0c7160142c4b9d9524d2d2a3013c09067a1 Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 1 Dec 2020 18:59:39 +0100 Subject: [PATCH] Added setting for timezone --- maloja/data_files/settings/default.ini | 3 +++ maloja/malojatime.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/maloja/data_files/settings/default.ini b/maloja/data_files/settings/default.ini index 824e695..4c11155 100644 --- a/maloja/data_files/settings/default.ini +++ b/maloja/data_files/settings/default.ini @@ -71,6 +71,9 @@ 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 + [Fluff] # how many scrobbles a track needs to aquire this status diff --git a/maloja/malojatime.py b/maloja/malojatime.py index cc6cf4d..712f4d8 100644 --- a/maloja/malojatime.py +++ b/maloja/malojatime.py @@ -1,9 +1,13 @@ import datetime from datetime import datetime as dtm +from datetime import timezone, timedelta from calendar import monthrange from os.path import commonprefix import math +from doreah.settings import get_settings +OFFSET = get_settings("TIMEZONE") +TIMEZONE = timezone(timedelta(hours=OFFSET)) FIRST_SCROBBLE = int(datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).timestamp()) @@ -545,7 +549,7 @@ def timestamp_desc(t,short=False): return timeobject.strftime("%Y") else: - timeobject = datetime.datetime.fromtimestamp(t) + timeobject = datetime.datetime.fromtimestamp(t,tz=TIMEZONE) return timeobject.strftime("%d. %b %Y %I:%M %p")