Skip to content

Commit b34cb1a

Browse files
authored
Merge pull request #535 from duxovni/fix-summer-winter-snap
Prevent summer/wintertime changeover from sending the snap range logic into a loop
2 parents 153675a + dd18b02 commit b34cb1a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

timetagger/app/front.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ def _get_snap_range(self, scalestep=0):
539539
scale_index = max(0, min(len(SCALES) - 1, scale_index))
540540
ran, res, _, _ = SCALES[scale_index]
541541

542+
# Short-circuit to avoid weirdness around summer/wintertime transitions
543+
if dt.round(t1, res) == t1 and dt.add(t1, ran) == t2:
544+
return t1, t2, res
545+
542546
# Round
543547
t5 = 0.5 * (t1 + t2) # center
544548
t3 = 0.5 * (t5 + dt.add(t5, "-" + ran)) # unrounded t3

0 commit comments

Comments
 (0)