time.localtime()

12 views
Skip to first unread message

Jeff Halnon

unread,
Apr 7, 2025, 5:58:45 AMApr 7
to thonny
I'm using a raspberry pi pico w as the heart of a clock.  I'm new to micropython (my primary programming language is a soldering iron).  I had planned to use ntptime to set the RTC to UTC time then adjust for timezone and DST.  I was surprised to see that on power-up time.localtime() returns the correct time already adjusted for timezone and DST.  I had expected it to come up with some default value.

If I can find a way to invoke the function that set the clock in the background automatically on power up, I can eliminate the logic required to make the adjustment from UTC to EST (or EDT or whatever I wanted).  Is this possible?

Paul Naish

unread,
Apr 7, 2025, 6:23:37 AMApr 7
to thonny
PICO has a RTC but no battery to keep it's setting. What you are witnessing is that Thonny sets the RTC when it connects. To get the true behavior disable this setting in the Interpreter setuo
Screenshot 2025-04-07 at 6.21.57 AM.png

Reply all
Reply to author
Forward
0 new messages