mktime() feature request #14390
-
Hi. I'm struggling with mktime() on a Pico W only allowing dates up to the year 2037 (or a couple of weeks past) before getting OverflowError: overflow converting long int to machine word This occurs because mktime is counting the number of seconds from the Pico's epoch (Jan 1, 1970) rather than the documented Jan 1, 2000. So with a Pico, you get 30 years less than other ports before it starts erroring. 2037 is not really that far into the future compared to how far we are past 1970. There are several possible solutions such as making the Pico also count from Jan 1, 2000; but IMHO a more elegant solution would be to add another (optional) argument to mktime() to define the start date that it begins counting from. eg import time
print(time.mktime([2020, 01, 01], time.localtime())) or similar. Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
See the 2038 problem. The maintainers are unlikely to go with a solution that breaks CPython compatibility. There are a number of inconsistencies in MP time support which can't be fixed without breaking code. Hopefully they will be fixed for the V2 release, including some way of fixing the2038 problem. |
Beta Was this translation helpful? Give feedback.
See the 2038 problem.
The maintainers are unlikely to go with a solution that breaks CPython compatibility. There are a number of inconsistencies in MP time support which can't be fixed without breaking code. Hopefully they will be fixed for the V2 release, including some way of fixing the2038 problem.