diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index 409e49f..386eeaf 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -15,7 +15,7 @@ links = { requires = [ "bottle>=0.12.16", "waitress>=1.3", - "doreah>=1.6.10", + "doreah>=1.6.13", "nimrodel>=0.6.4", "setproctitle>=1.1.10", "wand>=0.5.4", diff --git a/maloja/data_files/settings/default.ini b/maloja/data_files/settings/default.ini index 824e695..b929df3 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 in hours to UTC +TIMEZONE = 0 + [Fluff] # how many scrobbles a track needs to aquire this status diff --git a/maloja/globalconf.py b/maloja/globalconf.py index 4404677..61adb2c 100644 --- a/maloja/globalconf.py +++ b/maloja/globalconf.py @@ -57,9 +57,6 @@ config( caching={ "folder": datadir("cache") }, - regular={ - "autostart": False - }, auth={ "multiuser":False, "cookieprefix":"maloja", @@ -74,6 +71,10 @@ settingsconfig._readpreconfig() config( logging={ "logfolder": datadir("logs") if get_settings("LOGGING") else None + }, + regular={ + "autostart": False, + "offset": get_settings("TIMEZONE") } ) diff --git a/maloja/malojatime.py b/maloja/malojatime.py index 9e18f5f..63af16a 100644 --- a/maloja/malojatime.py +++ b/maloja/malojatime.py @@ -1,10 +1,15 @@ 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()) def register_scrobbletime(timestamp): @@ -178,10 +183,10 @@ class MTime(MRangeDescriptor): def first_stamp(self): day = self.first_day().dateobject - return int(datetime.datetime.combine(day,datetime.time(tzinfo=datetime.timezone.utc)).timestamp()) + return int(datetime.datetime.combine(day,datetime.time(tzinfo=TIMEZONE)).timestamp()) def last_stamp(self): day = self.last_day().dateobject + datetime.timedelta(days=1) - return int(datetime.datetime.combine(day,datetime.time(tzinfo=datetime.timezone.utc)).timestamp() - 1) + return int(datetime.datetime.combine(day,datetime.time(tzinfo=TIMEZONE)).timestamp() - 1) # next range of equal length (not exactly same amount of days, but same precision level) def next(self,step=1): @@ -379,18 +384,18 @@ y = MTime(2020) def today(): - tod = datetime.datetime.utcnow() + tod = datetime.datetime.now(tz=TIMEZONE) return MTime(tod.year,tod.month,tod.day) def thisweek(): - tod = datetime.datetime.utcnow() + tod = datetime.datetime.now(tz=TIMEZONE) tod = datetime.date(tod.year,tod.month,tod.day) y,w,_ = tod.chrcalendar() return MTimeWeek(y,w) def thismonth(): - tod = datetime.datetime.utcnow() + tod = datetime.datetime.now(tz=TIMEZONE) return MTime(tod.year,tod.month) def thisyear(): - tod = datetime.datetime.utcnow() + tod = datetime.datetime.now(tz=TIMEZONE) return MTime(tod.year) def alltime(): return MRange(None,None) @@ -545,7 +550,7 @@ def timestamp_desc(t,short=False): return timeobject.strftime("%Y") else: - timeobject = datetime.datetime.utcfromtimestamp(t) + timeobject = datetime.datetime.fromtimestamp(t,tz=TIMEZONE) return timeobject.strftime("%d. %b %Y %I:%M %p")