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

Merge branch 'master' of github.com:krateng/maloja

This commit is contained in:
Krateng 2020-12-13 03:09:03 +01:00
commit 4e69a6119d
4 changed files with 20 additions and 11 deletions

View File

@ -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",

View File

@ -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

View File

@ -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")
}
)

View File

@ -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")