Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-81708: Support negative timestamps in _PyTime_localtime for windows#131056

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ammaraskar wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromammaraskar:negative_timestamp_windows

Conversation

ammaraskar
Copy link
Member

@ammaraskarammaraskar commentedMar 10, 2025
edited by bedevere-appbot
Loading

DO NOT MERGE.

This is a work-in-progress/proof-of-concept pull request for not usinglocaltime on Windows for negative epoch values but instead using win32 APIs. We basically have a set of long-standing issues and work-arounds/platform specific code for the fact thatlocaltime on Windows does not support negative numbers, unlike our other platforms.

Some examples from a quick search include:

The changes toPython/pytime.c are the ones to look at, the rest are just enabling tests/removing work-arounds. Note that I had to use anif-guard to only use the new win32 apis when the unix timestamp is>= 0 because as it turns out,mktime on Windows has this behavior where it just doesn't account for DST correctly. Without it, tests that rely on round-trippingmktime andlocaltime fail. (Seethis repo for more details on that)

There is also the question on how to supporttm_yday andtm_isdst. I have an implementation oftm_yday and a commented out one fortm_isdst.

/cc@zooba for thoughts on this approach, whether it's worth pursuing.
/cc@eryksun for Windows expertise on the APIs/methodology

@zooba
Copy link
Member

On the overall approach, I guess it fills in a gap, but I'd prefer to have a single codepath that handles it all. Dates/times are hard though, and I'm not even going to pretend I know how this function is actually meant to behave.

My preference would be to use the best available OS API for the entire job, rather than splitting it up. If no such API exists, something like this I'd think we could implement ourselves and stop relying on the OS entirely.

But if the people who understand this particular subject better than me say it's not safe to make a change like that, then I'm happy enough to go with their recommendation. I'm not sure who those people are right now.

@ammaraskar
Copy link
MemberAuthor

My preference would be to use the best available OS API for the entire job, rather than splitting it up

Switchingmktime to also use the symmetrical win32 APIs would be able to achieve that since it would avoid thatmktime bug I mentioned. I'll try updating this PR to do that, avoiding the split logic based on thet value and see if it works better/how much complexity it involves.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@pgansslepganssleAwaiting requested review from pgansslepganssle will be requested when the pull request is marked ready for reviewpganssle is a code owner

@abalkinabalkinAwaiting requested review from abalkinabalkin will be requested when the pull request is marked ready for reviewabalkin is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ammaraskar@zooba

[8]ページ先頭

©2009-2025 Movatter.jp