This code works in micropython because there is no inbuilt "unix epoch correction" there. time_localtime calls timeutils_seconds_since_2000_to_struct_time compare this with circuitpython's timeutils timeutils_seconds_since_epoch_to_struct_time function which gets called during localtime
Just because the syntax doesn’t work as it does in micropython doesn’t necessarily mean it’s a bug. Trying to help plug holes with stuff tagged as good first issue.
powersoft commentedSep 1, 2020
I wont to convert a unixtimestamp to localtime in circuit python.
This is the simple code:
unix_correction = 946684800 # correct to 01-01-2000
timezone = 7200
t=1598887049
def convertUnixTime(t,timezone):
dummy=time.localtime(t-unix_correction+timezone)
return "%4d-%02d-%02d %02d:%02d" % (dummy[0],dummy[1],dummy[2],dummy[3],dummy[4])
Running it I get the error message:
"timestamp out of range for platform time_t"
could not found a solution for this problem (it is working well in micropython!)
thank for any help.
cheers,
Jan
The text was updated successfully, but these errors were encountered: