Commit 4e344683 authored by Vincent Pelletier's avatar Vincent Pelletier

Add comments on error caused by time approximations.

Some are corrected, others are TODO.
parent fa46d997
......@@ -813,6 +813,7 @@ period_parser = {
# Longest month: 31 days
timedelta(31),
lambda x: x,
# Error margin without correction: 3/31 = 10%
lambda x: 31. / calendar.monthrange(x.year, x.month)[1],
),
'quarter': (
......@@ -824,6 +825,7 @@ period_parser = {
'%Y/%m/%d',
timedelta(7),
_roundWeek,
# Error margin without correction: (366 % 7 = 2) 2/7 = 29%
_getWeekCoefficient,
),
'month': (
......@@ -834,7 +836,8 @@ period_parser = {
# Longest day: 24 hours + 1h DST (never more ?)
timedelta(seconds=3600 * 25),
lambda x: x,
lambda x: 1, # XXX: take DST into account (1/24th) ?
# Error margin without correction: (DST) 1/24 = 4%
lambda x: 1,
),
'week': ( # XXX: should be "7 days", but a single word is more convenient
_as6HourString,
......@@ -843,6 +846,7 @@ period_parser = {
'%Y/%m/%d %H',
timedelta(seconds=3600 * 6),
_round6Hour,
# Error margin without correction: (DST) 1/6 = 17%
lambda x: 1,
),
'day': (
......@@ -853,6 +857,7 @@ period_parser = {
# Longest hour: 60 * 60 seconds + 1 leap second.
timedelta(seconds=3601),
lambda x: x,
# Error margin without correction: (leap) 1/3600 = .03%
lambda x: 1,
),
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment