Skip to content

Commit a888117

Browse files
authored
Merge pull request #536 from duxovni/fix-summer-winter-week-floor
Prevent summer/wintertime changeover from breaking week floor calculation
2 parents b34cb1a + 2ea5bb6 commit a888117

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

timetagger/app/dt.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,8 @@ def floor(t, res):
224224
tup[-1] = int((tup[-1] - 1) / resFactor) * resFactor + 1 # days are 1-based
225225
elif resName == "W":
226226
day_offset = 7 - get_first_day_of_week()
227-
d.setHours(0, 0, 0, 0)
228227
daysoff = (d.getDay() + day_offset) % 7 # Align to a sunday/monday
229-
d = Date(d.getTime() - 86_400_000 * daysoff)
230-
tup = d.getFullYear(), d.getMonth(), d.getDate()
228+
tup = d.getFullYear(), d.getMonth(), (d.getDate() - daysoff)
231229
elif resName == "M":
232230
tup = tup[:2] # Note that it is zero-based (jan is zero)
233231
tup[-1] = int(tup[-1] / resFactor) * resFactor

0 commit comments

Comments
 (0)