Создать строку TZ из Python ZoneInfo ⇐ Python
-
Anonymous
Создать строку TZ из Python ZoneInfo
I can easily get a ZoneInfo object for the time zone of my choice:
import zoneinfo ct = zoneinfo.ZoneInfo('America/Chicago') I need to create a TZ environment variable for an embedded system that doesn't have a timezone database, so I can't simply reuse the location string as you might do on a regular Linux system. I need to embed the actual daylight savings transition rules in the string, for my example it would look like:
TZ=CST06CDT05,M3.2.0/2,M11.1.0/2 I haven't been able to find any way to build that string. It doesn't bother me that the string might become obsolete if the rules change.
This also needs to work for time zones outside the U.S.
If there's a better way to get the information than using ZoneInfo, I'm willing to entertain answers for that too.
Источник: https://stackoverflow.com/questions/780 ... n-zoneinfo
I can easily get a ZoneInfo object for the time zone of my choice:
import zoneinfo ct = zoneinfo.ZoneInfo('America/Chicago') I need to create a TZ environment variable for an embedded system that doesn't have a timezone database, so I can't simply reuse the location string as you might do on a regular Linux system. I need to embed the actual daylight savings transition rules in the string, for my example it would look like:
TZ=CST06CDT05,M3.2.0/2,M11.1.0/2 I haven't been able to find any way to build that string. It doesn't bother me that the string might become obsolete if the rules change.
This also needs to work for time zones outside the U.S.
If there's a better way to get the information than using ZoneInfo, I'm willing to entertain answers for that too.
Источник: https://stackoverflow.com/questions/780 ... n-zoneinfo