#Datetime formatting/math?

1 messages · Page 1 of 1 (latest)

bright epoch
#

What I'd like is to be able to take a timestamp in UTC, and have it format a string (or at least return components) in a given time zone, automatically applying DST adjustments.

#

Datetime formatting/math?

honest spade
bright epoch
#

When I try to use the format specifier {0:%d}, as shown here, I get an error that it's invalid

honest spade
#

That example is just ... wrong. I'm tracking down what was meant.

#

Also I see in the code that there is datetime arithmetic, but it was not included in the documentation!

honest spade
#

ok, I tracked this down. Somebody else created some readthedocs projects for a few circuitpython libraries almost four years ago. They are based on very old versions of the libraries. I've asked them to delete those projects.

bright epoch
#

Where does datetime get the current time? (I'm on an ESP32-S3, with a ds3231 attached)

bright epoch
#

I can see in the CP sources that RTC.datetime ends up calling gettimeofday, but I can't find a definition for that anywhere in the CP sources (using github's search feature).

honest spade
#

It's calling getttimeofday() as provided by a few board's SDK, e.g., the Espressif ESP-iDF. In the below, cxd56 is Sony Spresense.

ports/espressif/common-hal/rtc/RTC.c:16:    gettimeofday(&tv_now, NULL);
ports/cxd56/common-hal/pulseio/PulseIn.c:36:    gettimeofday(&tv, NULL);
ports/cxd56/common-hal/rtc/RTC.c:17:    gettimeofday(&tv, NULL);