Repository navigation
Fix interval count when DST skips the start day's midnight - #75
Closed
draarivpatel-ui wants to merge 1 commit into
Closed
draarivpatel-ui wants to merge 1 commit into
draarivpatel-ui wants to merge 1 commit into
Conversation
In zones where DST starts at 00:00 local (America/Santiago, America/Havana, Asia/Beirut), floor of the DST-start day lands at 01:00, so the elapsed-time quotient in interval.count is N - 1/24 and Math.floor under-counts by one boundary. Both ends are already boundaries after flooring, so round instead of floor. Fixes d3#74.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #74.
Problem
In time zones where DST starts at 00:00 local (America/Santiago, America/Havana, Asia/Beirut),
floorof the DST-start day resolves to 01:00 because midnight does not exist. The elapsed-time quotient ininterval.countis then N - 1/24 (or N - 1/168 for weeks), andMath.floorunder-counts by one boundary:Fix
Both ends are already interval boundaries after
floori(t0)/floori(t1), so the true count is always an integer. Round the quotient instead of flooring it:Math.floortoMath.roundininterval.count. This also fixes the same class of off-by-one fortimeWeek.count, month boundaries that land on a skipped midnight, and floating-point noise below the true value.Test
Added cases to
test/day-test.jsandtest/sunday-test.jsthat switchprocess.env.TZto America/Santiago (restored infinally), verifying counts across the 2025-09-07 skipped midnight. They fail before the fix and pass after. Ranvitest runon the touched files plus the full suite under the repo's TZ=America/Los_Angeles: 467/467 pass.