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:
commit
4e69a6119d
|
@ -15,7 +15,7 @@ links = {
|
||||||
requires = [
|
requires = [
|
||||||
"bottle>=0.12.16",
|
"bottle>=0.12.16",
|
||||||
"waitress>=1.3",
|
"waitress>=1.3",
|
||||||
"doreah>=1.6.10",
|
"doreah>=1.6.13",
|
||||||
"nimrodel>=0.6.4",
|
"nimrodel>=0.6.4",
|
||||||
"setproctitle>=1.1.10",
|
"setproctitle>=1.1.10",
|
||||||
"wand>=0.5.4",
|
"wand>=0.5.4",
|
||||||
|
|
|
@ -71,6 +71,9 @@ CHARTS_DISPLAY_TILES = false
|
||||||
# prevent visitors from mindlessly clicking on those options and hogging your cpu
|
# prevent visitors from mindlessly clicking on those options and hogging your cpu
|
||||||
DISCOURAGE_CPU_HEAVY_STATS = false
|
DISCOURAGE_CPU_HEAVY_STATS = false
|
||||||
|
|
||||||
|
# Offset in hours to UTC
|
||||||
|
TIMEZONE = 0
|
||||||
|
|
||||||
[Fluff]
|
[Fluff]
|
||||||
|
|
||||||
# how many scrobbles a track needs to aquire this status
|
# how many scrobbles a track needs to aquire this status
|
||||||
|
|
|
@ -57,9 +57,6 @@ config(
|
||||||
caching={
|
caching={
|
||||||
"folder": datadir("cache")
|
"folder": datadir("cache")
|
||||||
},
|
},
|
||||||
regular={
|
|
||||||
"autostart": False
|
|
||||||
},
|
|
||||||
auth={
|
auth={
|
||||||
"multiuser":False,
|
"multiuser":False,
|
||||||
"cookieprefix":"maloja",
|
"cookieprefix":"maloja",
|
||||||
|
@ -74,6 +71,10 @@ settingsconfig._readpreconfig()
|
||||||
config(
|
config(
|
||||||
logging={
|
logging={
|
||||||
"logfolder": datadir("logs") if get_settings("LOGGING") else None
|
"logfolder": datadir("logs") if get_settings("LOGGING") else None
|
||||||
|
},
|
||||||
|
regular={
|
||||||
|
"autostart": False,
|
||||||
|
"offset": get_settings("TIMEZONE")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import datetime as dtm
|
from datetime import datetime as dtm
|
||||||
|
from datetime import timezone, timedelta
|
||||||
from calendar import monthrange
|
from calendar import monthrange
|
||||||
from os.path import commonprefix
|
from os.path import commonprefix
|
||||||
import math
|
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())
|
FIRST_SCROBBLE = int(datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).timestamp())
|
||||||
|
|
||||||
def register_scrobbletime(timestamp):
|
def register_scrobbletime(timestamp):
|
||||||
|
@ -178,10 +183,10 @@ class MTime(MRangeDescriptor):
|
||||||
|
|
||||||
def first_stamp(self):
|
def first_stamp(self):
|
||||||
day = self.first_day().dateobject
|
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):
|
def last_stamp(self):
|
||||||
day = self.last_day().dateobject + datetime.timedelta(days=1)
|
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)
|
# next range of equal length (not exactly same amount of days, but same precision level)
|
||||||
def next(self,step=1):
|
def next(self,step=1):
|
||||||
|
@ -379,18 +384,18 @@ y = MTime(2020)
|
||||||
|
|
||||||
|
|
||||||
def today():
|
def today():
|
||||||
tod = datetime.datetime.utcnow()
|
tod = datetime.datetime.now(tz=TIMEZONE)
|
||||||
return MTime(tod.year,tod.month,tod.day)
|
return MTime(tod.year,tod.month,tod.day)
|
||||||
def thisweek():
|
def thisweek():
|
||||||
tod = datetime.datetime.utcnow()
|
tod = datetime.datetime.now(tz=TIMEZONE)
|
||||||
tod = datetime.date(tod.year,tod.month,tod.day)
|
tod = datetime.date(tod.year,tod.month,tod.day)
|
||||||
y,w,_ = tod.chrcalendar()
|
y,w,_ = tod.chrcalendar()
|
||||||
return MTimeWeek(y,w)
|
return MTimeWeek(y,w)
|
||||||
def thismonth():
|
def thismonth():
|
||||||
tod = datetime.datetime.utcnow()
|
tod = datetime.datetime.now(tz=TIMEZONE)
|
||||||
return MTime(tod.year,tod.month)
|
return MTime(tod.year,tod.month)
|
||||||
def thisyear():
|
def thisyear():
|
||||||
tod = datetime.datetime.utcnow()
|
tod = datetime.datetime.now(tz=TIMEZONE)
|
||||||
return MTime(tod.year)
|
return MTime(tod.year)
|
||||||
def alltime():
|
def alltime():
|
||||||
return MRange(None,None)
|
return MRange(None,None)
|
||||||
|
@ -545,7 +550,7 @@ def timestamp_desc(t,short=False):
|
||||||
|
|
||||||
return timeobject.strftime("%Y")
|
return timeobject.strftime("%Y")
|
||||||
else:
|
else:
|
||||||
timeobject = datetime.datetime.utcfromtimestamp(t)
|
timeobject = datetime.datetime.fromtimestamp(t,tz=TIMEZONE)
|
||||||
return timeobject.strftime("%d. %b %Y %I:%M %p")
|
return timeobject.strftime("%d. %b %Y %I:%M %p")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user