mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 22:54:57 -04:00
Fix pytz and time localization
This commit is contained in:
parent
5de292e12a
commit
4a7376f17b
5 changed files with 10 additions and 5 deletions
|
@ -119,11 +119,11 @@ class kmsBase:
|
|||
|
||||
# Localize the request time, if module "tzlocal" is available.
|
||||
try:
|
||||
from datetime import datetime
|
||||
from tzlocal import get_localzone
|
||||
from pytz.exceptions import UnknownTimeZoneError
|
||||
try:
|
||||
tz = get_localzone()
|
||||
local_dt = tz.localize(requestDatetime)
|
||||
local_dt = datetime.fromisoformat(str(requestDatetime)).astimezone(get_localzone())
|
||||
except UnknownTimeZoneError:
|
||||
pretty_printer(log_obj = loggersrv.warning,
|
||||
put_text = "{reverse}{yellow}{bold}Unknown time zone ! Request time not localized.{end}")
|
||||
|
@ -132,6 +132,11 @@ class kmsBase:
|
|||
pretty_printer(log_obj = loggersrv.warning,
|
||||
put_text = "{reverse}{yellow}{bold}Module 'tzlocal' not available ! Request time not localized.{end}")
|
||||
local_dt = requestDatetime
|
||||
except Exception as e:
|
||||
# Just in case something else goes wrong
|
||||
loggersrv.warning('Okay, something went horribly wrong while localizing the request time (proceeding anyways): ' + str(e))
|
||||
local_dt = requestDatetime
|
||||
pass
|
||||
|
||||
# Activation threshold.
|
||||
# https://docs.microsoft.com/en-us/windows/deployment/volume-activation/activate-windows-10-clients-vamt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue