Skip to content

POSIX: fix mktime on 32-bit platforms with large time_t #21554

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

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Oct 10, 2023

If IV is a 32-bit type, but time_t is bigger, then it is possible for mktime() to return values outside the 32-bit range (> 0x7fff_ffff after 2038-01-19). In that case, fall back to NV (i.e. floating point). A double-precision floating point number provides more than 52 bits of precision, which should be plenty.

Fixes #21551.

If IV is a 32-bit type, but time_t is bigger, then it is possible for
mktime() to return values outside the 32-bit range (> 0x7fff_ffff after
2038-01-19). In that case, fall back to NV (i.e. floating point). A
double-precision floating point number provides more than 52 bits of
precision, which should be plenty.

Fixes Perl#21551.
@mauke mauke merged commit 505e27e into Perl:blead Oct 11, 2023
@mauke mauke deleted the posix-mktime-32bit branch October 11, 2023 04:31
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.

year 2038 bug in POSIX::mktime
3 participants