#Datetime formatting/math?
1 messages · Page 1 of 1 (latest)
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?
adafruit_datetime, https://docs.circuitpython.org/projects/datetime/en/latest/api.html is a subset of what regular Python's datetime class provides.
https://github.com/micropython/micropython-lib/blob/master/python-stdlib/datetime/datetime.py is a micropython library that does have date/time arithmetic and less support for formatting.
When I try to use the format specifier {0:%d}, as shown here, I get an error that it's invalid
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!
Use this documentation: https://docs.circuitpython.org/projects/datetime/en/latest/index.html. The link you gave above is outdated or something. I'm not sure why it's in readthedocs.
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.
Where does datetime get the current time? (I'm on an ESP32-S3, with a ds3231 attached)
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).
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);