Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bizarre time math on leap hour day (today) #121

Open
ccavnor opened this issue Mar 12, 2023 · 0 comments
Open

Bizarre time math on leap hour day (today) #121

ccavnor opened this issue Mar 12, 2023 · 0 comments

Comments

@ccavnor
Copy link

ccavnor commented Mar 12, 2023

let now: Date = Date()
let then: Date = now.adjust(second: 30)!
print("NOW: (now.toString(dateStyle: .full, timeStyle: .full)!)")
print("THEN: (then.toString(dateStyle: .full, timeStyle: .full)!)")

NOW: Sunday, March 12, 2023 at 11:42:48 AM Pacific Daylight Time
THEN: Sunday, March 12, 2023 at 11:42:30 AM Pacific Daylight Time

then is somehow 18 seconds BEHIND now. I understand neither the incorrect offset nor the negative time, but I strongly suspect that it has to do with today being a leap hour day (Spring forward in time).

if I instead do:
let then: Date = now + 30 // add 30 seconds

then all is as expected:

NOW: Sunday, March 12, 2023 at 11:50:08 AM Pacific Daylight Time
THEN: Sunday, March 12, 2023 at 11:50:38 AM Pacific Daylight Time

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

No branches or pull requests

1 participant