BaseTools/GetUtcDateTime.py: Python 3.12 support

Ref to https://docs.python.org/3/whatsnew/3.12.html
utcnow() and utcfromtimestamp() are deprecated
Prevent use it cause build error.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Gua Guo 2024-04-21 20:44:55 +08:00 committed by mergify[bot]
parent 66c24219ad
commit c0dfe3ec1f

View File

@ -29,7 +29,7 @@ def Main():
print ("ERROR: At least one argument is required!\n")
PARSER.print_help()
today = datetime.datetime.utcnow()
today = datetime.datetime.now(datetime.timezone.utc)
if ARGS.year:
ReversedNumber = str(today.year)[::-1]
print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber))