Skip to content

Fix BeginningOfDay when local midnight is skipped - #92

Open
SashaMIT wants to merge 1 commit into
jinzhu:masterfrom
SashaMIT:fix/beginning-of-day-skipped-midnight
Open

SashaMIT wants to merge 1 commit into
jinzhu:masterfrom
SashaMIT:fix/beginning-of-day-skipped-midnight

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

BeginningOfDay of noon on 2018-11-04 in America/Sao_Paulo returned 2018-11-03 23:00. Local midnight did not exist, because the clocks jumped from 23:59 to 01:00, and time.Date placed that missing midnight on the previous day. The day now starts at the first instant that still has that date, 2018-11-04 01:00.

An ordinary day in the same zone is still midnight. The Berlin fall-back day already covered by the tests is unchanged, because that midnight exists.

Test plan

  • go test for the package
  • Red before the fix: BeginningOfDay formats as 2018-11-03 23:00:00
  • Green after: 2018-11-04 01:00:00, and one second earlier is still November 3

A daylight-saving jump at midnight made time.Date return the previous day, so noon on 2018-11-04 in Sao Paulo began on November 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant