forked from DGNum/gestioCOF
simplify StatScale
This commit is contained in:
parent
b3a9ad8a96
commit
1bb83ccdd7
1 changed files with 4 additions and 8 deletions
|
@ -79,12 +79,6 @@ class StatScale(object):
|
||||||
label_fmt = self.label_fmt
|
label_fmt = self.label_fmt
|
||||||
return [begin.strftime(label_fmt) for begin, end in self]
|
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):
|
class DayStatScale(StatScale):
|
||||||
name = 'day'
|
name = 'day'
|
||||||
|
@ -102,8 +96,10 @@ class WeekStatScale(StatScale):
|
||||||
label_fmt = 'Semaine %W'
|
label_fmt = 'Semaine %W'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def offset_to_chunk_start(cls, dt):
|
def get_chunk_start(cls, dt):
|
||||||
return timezone.timedelta(days=dt.weekday())
|
dt_kfet = to_kfet_day(dt)
|
||||||
|
offset = timezone.timedelta(days=dt_kfet.weekday())
|
||||||
|
return dt_kfet - offset
|
||||||
|
|
||||||
|
|
||||||
class MonthStatScale(StatScale):
|
class MonthStatScale(StatScale):
|
||||||
|
|
Loading…
Reference in a new issue