1 | ## @file
|
---|
2 | # Get current UTC date and time information and output as ascii code.
|
---|
3 | #
|
---|
4 | # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
---|
5 | #
|
---|
6 | # SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 | #
|
---|
8 |
|
---|
9 | VersionNumber = '0.1'
|
---|
10 | import sys
|
---|
11 | import datetime
|
---|
12 | import argparse
|
---|
13 |
|
---|
14 | def Main():
|
---|
15 | PARSER = argparse.ArgumentParser(
|
---|
16 | description='Retrieves UTC date and time information (output ordering: year, date, time) - Version ' + VersionNumber)
|
---|
17 | PARSER.add_argument('--year',
|
---|
18 | action='store_true',
|
---|
19 | help='Return UTC year of now. [Example output (2019): 39313032]')
|
---|
20 | PARSER.add_argument('--date',
|
---|
21 | action='store_true',
|
---|
22 | help='Return UTC date MMDD of now. [Example output (7th August): 37303830]')
|
---|
23 | PARSER.add_argument('--time',
|
---|
24 | action='store_true',
|
---|
25 | help='Return 24-hour-format UTC time HHMM of now. [Example output (14:25): 35323431]')
|
---|
26 |
|
---|
27 | ARGS = PARSER.parse_args()
|
---|
28 | if len(sys.argv) == 1:
|
---|
29 | print ("ERROR: At least one argument is required!\n")
|
---|
30 | PARSER.print_help()
|
---|
31 |
|
---|
32 | today = datetime.datetime.now(datetime.timezone.utc)
|
---|
33 | if ARGS.year:
|
---|
34 | ReversedNumber = str(today.year)[::-1]
|
---|
35 | print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber))
|
---|
36 | if ARGS.date:
|
---|
37 | ReversedNumber = str(today.strftime("%m%d"))[::-1]
|
---|
38 | print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber))
|
---|
39 | if ARGS.time:
|
---|
40 | ReversedNumber = str(today.strftime("%H%M"))[::-1]
|
---|
41 | print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber))
|
---|
42 |
|
---|
43 | if __name__ == '__main__':
|
---|
44 | Main()
|
---|