simplify StatScale

This commit is contained in:
Aurélien Delobelle 2017-04-03 15:10:53 +02:00
parent b3a9ad8a96
commit 1bb83ccdd7

View file

@ -79,12 +79,6 @@ class StatScale(object):
label_fmt = self.label_fmt
return [begin.strftime(label_fmt) for begin, end in self]
@classmethod
def get_chunk_start(cls, dt):
dt_kfet = to_kfet_day(dt)
start = dt_kfet - cls.offset_to_chunk_start(dt_kfet)
return start
class DayStatScale(StatScale):
name = 'day'
@ -102,8 +96,10 @@ class WeekStatScale(StatScale):
label_fmt = 'Semaine %W'
@classmethod
def offset_to_chunk_start(cls, dt):
return timezone.timedelta(days=dt.weekday())
def get_chunk_start(cls, dt):
dt_kfet = to_kfet_day(dt)
offset = timezone.timedelta(days=dt_kfet.weekday())
return dt_kfet - offset
class MonthStatScale(StatScale):