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

Workaround for Windows local time prior to 1601 #1377

Closed
wants to merge 1 commit into from

Conversation

ChrisDenton
Copy link

@ChrisDenton ChrisDenton commented Jan 18, 2024

This PR makes the minimum necessary changes to workaround #1364. It's not a full fix but it will allow people to use chrono to get the local time of files with a creation time of zero. I believe this to be worthwhile in the interim until a better patch lands.

If getting the offset for 1601 fails with ERROR_INVALID_PARAMETER then this patch instead calculates the offset for 1602. This works only because the 1600's are long enough ago that dynamic timezones aren't a concern and negative timezone offsets will always be much less than a year (typically a few hours).

@ChrisDenton
Copy link
Author

Btw, the test is copy/pasted from #1017.

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cee242a) 91.69% compared to head (2925bea) 91.69%.

Additional details and impacted files
@@           Coverage Diff           @@
##            0.4.x    #1377   +/-   ##
=======================================
  Coverage   91.69%   91.69%           
=======================================
  Files          38       38           
  Lines       17608    17617    +9     
=======================================
+ Hits        16145    16154    +9     
  Misses       1463     1463           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisDenton
Copy link
Author

ChrisDenton commented Jan 18, 2024

On second thought, I've scoped it to only hit the fallback case on 1601-01-01 (UTC). This better expresses the intent and timezone offsets are always going to be less than 24hrs, so from 1601-01-02 onwards ERROR_INVALID_PARAMETER is a real error.

@djc
Copy link
Member

djc commented Jan 19, 2024

@pitdicker do you think you'll have time to rework #1017 sometime soonish?

@pitdicker
Copy link
Collaborator

Yes, I'll get back to it this weekend.

@pitdicker
Copy link
Collaborator

The complete fix in #1017 is merged. @ChrisDenton Thank you for your efforts here.

@pitdicker pitdicker closed this Feb 10, 2024
@ChrisDenton ChrisDenton deleted the local-workaround-4x branch February 12, 2024 09:19
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.

3 participants