CPython/MicroPython returns different result of time.localtime()
Posted: Tue Apr 10, 2018 7:12 am
I am trying to make a NTP clock with MicroPython. And I ported Arduino's NTP library to MicroPython, since it returns identical timestamp as CPython does. Now I find CPython and MicroPython on ESP8266 returns different result when I try to convert timestamp into time strings.
It seems tm_year, tm_mday, tm_hour are wrong from MicroPython. I also tried another pyb, which is identical to ESP8266 port.
So far I am using a dedicated functions to convert timestamp to tuple. Is it a bug ?
Code: Select all
> python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.localtime(1523338307)
time.struct_time(tm_year=2018, tm_mon=4, tm_mday=10, tm_hour=13, tm_min=31, tm_sec=47, tm_wday=1, tm_yday=100,
Code: Select all
PYB: soft reboot
MicroPython v1.9.3-500-gbc3a5f19 on 2018-03-30; ESP module with ESP8266
Type "help()" for more information.
>>> import time
>>> time.localtime(1523338307)
(2048, 4, 9, 5, 31, 47, 3, 100)
>>>
So far I am using a dedicated functions to convert timestamp to tuple. Is it a bug ?