]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Scripts/GetUtcDateTime.py
2 # Get current UTC date and time information and output as ascii code.
4 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
15 PARSER
= argparse
.ArgumentParser(
16 description
='Retrieves UTC date and time information (output ordering: year, date, time) - Version ' + VersionNumber
)
17 PARSER
.add_argument('--year',
19 help='Return UTC year of now. [Example output (2019): 39313032]')
20 PARSER
.add_argument('--date',
22 help='Return UTC date MMDD of now. [Example output (7th August): 37303830]')
23 PARSER
.add_argument('--time',
25 help='Return 24-hour-format UTC time HHMM of now. [Example output (14:25): 35323431]')
27 ARGS
= PARSER
.parse_args()
28 if len(sys
.argv
) == 1:
29 print ("ERROR: At least one argument is required!\n")
32 today
= datetime
.datetime
.utcnow()
34 ReversedNumber
= str(today
.year
)[::-1]
35 print (''.join(hex(ord(HexString
))[2:] for HexString
in ReversedNumber
))
37 ReversedNumber
= str(today
.strftime("%m%d"))[::-1]
38 print (''.join(hex(ord(HexString
))[2:] for HexString
in ReversedNumber
))
40 ReversedNumber
= str(today
.strftime("%H%M"))[::-1]
41 print (''.join(hex(ord(HexString
))[2:] for HexString
in ReversedNumber
))
43 if __name__
== '__main__':