Development
This commit is contained in:
parent
025adb9f15
commit
5b1f905ed0
7 changed files with 38 additions and 47 deletions
|
|
@ -31,6 +31,16 @@ def get_host_utc_offset():
|
|||
return time.localtime().tm_gmtoff
|
||||
|
||||
|
||||
def get_client_utc_offset(timezone_str):
|
||||
"""Return signed integer UTC offset in seconds for the given IANA timezone string."""
|
||||
try:
|
||||
from zoneinfo import ZoneInfo
|
||||
from datetime import datetime
|
||||
return int(datetime.now(ZoneInfo(timezone_str)).utcoffset().total_seconds())
|
||||
except Exception:
|
||||
return get_host_utc_offset()
|
||||
|
||||
|
||||
def get_host_timezone():
|
||||
"""Return the host timezone name (e.g. 'America/New_York'), or '' if unknown."""
|
||||
tz = os.environ.get('TZ', '').strip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue