mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 14:10:52 -07:00
Calculate months for graphs using datetime
This commit is contained in:
parent
1e777b1a1b
commit
7486a50c33
1 changed files with 10 additions and 6 deletions
|
@ -369,19 +369,23 @@ class Graphs(object):
|
||||||
|
|
||||||
# create our date range as some months may not have any data
|
# create our date range as some months may not have any data
|
||||||
# but we still want to display them
|
# but we still want to display them
|
||||||
base = time.localtime()
|
dt_today = datetime.date.today()
|
||||||
month_range = [time.localtime(
|
dt = dt_today
|
||||||
time.mktime((base.tm_year, base.tm_mon - n, 1, 0, 0, 0, 0, 0, 0))) for n in range(int(time_range))]
|
month_range = [dt]
|
||||||
|
for n in range(int(time_range)-1):
|
||||||
|
if not ((dt_today.month-n) % 12)-1:
|
||||||
|
dt = datetime.date(dt.year-1, 12, 1)
|
||||||
|
else:
|
||||||
|
dt = datetime.date(dt.year, dt.month-1, 1)
|
||||||
|
month_range.append(dt)
|
||||||
|
|
||||||
categories = []
|
categories = []
|
||||||
series_1 = []
|
series_1 = []
|
||||||
series_2 = []
|
series_2 = []
|
||||||
series_3 = []
|
series_3 = []
|
||||||
|
|
||||||
for month_item in sorted(month_range):
|
for dt in sorted(month_range):
|
||||||
dt = datetime.datetime(*month_item[:6])
|
|
||||||
date_string = dt.strftime('%Y-%m')
|
date_string = dt.strftime('%Y-%m')
|
||||||
|
|
||||||
categories.append(dt.strftime('%b %Y').decode(plexpy.SYS_ENCODING, 'replace'))
|
categories.append(dt.strftime('%b %Y').decode(plexpy.SYS_ENCODING, 'replace'))
|
||||||
series_1_value = 0
|
series_1_value = 0
|
||||||
series_2_value = 0
|
series_2_value = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue