No responses yet :-(
On 13/02/2026 10:50, Terry Coles wrote:
import zoneinfo
from datetime import datetime
NYC = zoneinfo.ZoneInfo("America/New_York")
datetime(2020, 1, 1, tzinfo=NYC)
There seems to be multiple ways of writing the above block. In the
Python doc (https://docs.python.org/3/library/zoneinfo.html). I found:
fromzoneinfoimport ZoneInfo
fromdatetimeimport datetime, timedelta
dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
print(dt)
2020-10-31 12:00:00-07:00
dt.tzname()
'PDT'
I began to wonder if the date-time group 2020-10-31 12:00-07:00 referred
to the end of Daylight Savings Time in LA, but that isn't quite right
because in 2020 DST ended on Sunday 1st Nov. In any case, why would you
hardwire any date into your code, so that you were committed to the
perpetual maintenance task of updating it every 12 months?
I have found a different example for GMT:
|>>> from datetime import datetime, timedelta >>> from zoneinfo import
ZoneInfo >>> >>> # This time is after British Summer Time (BST) ends >>>
x = datetime(2022, 10, 31, 18, 30, tzinfo=ZoneInfo("Europe/London")) >>>
str(x) '2022-10-31 18:30:00+00:00' >>> x.tzname() 'GMT' |
This is almost, but not quite, the same as the LA example, and nowhere
can I find a proper definition of the DTG information.
Does anyone have any experience of using this Python Module?
--
Terry Coles
--
Next meeting: Online, Jitsi, Tuesday, 2026-03-03 20:00
Check to whom you are replying
Meetings, mailing list, IRC, ... https://dorset.lug.org.uk
New thread, don't hijack: mailto:[email protected]