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