From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: bob.c.feng@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Wed, 14 Aug 2019 18:36:23 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 18:36:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,387,1559545200"; d="scan'208";a="170971990" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga008.jf.intel.com with ESMTP; 14 Aug 2019 18:36:23 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 14 Aug 2019 18:36:22 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 14 Aug 2019 18:36:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.80]) with mapi id 14.03.0439.000; Thu, 15 Aug 2019 09:36:20 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Gao, Liming" , Leif Lindholm Subject: Re: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime script. Thread-Topic: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime script. Thread-Index: AQHVUooEOiO/rFaXi0uHrFtWQuWfaqb7boLA Date: Thu, 15 Aug 2019 01:36:20 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D161522F35@SHSMSX104.ccr.corp.intel.com> References: <20190814102106.9236-1-chasel.chiu@intel.com> In-Reply-To: <20190814102106.9236-1-chasel.chiu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chiu= , Chasel Sent: Wednesday, August 14, 2019 6:21 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Gao, Liming = ; Leif Lindholm Subject: [edk2-devel] [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime scr= ipt. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2067 A script that can return UTC date and time in ascii format which is conven= ient for patching build time information in any binary. Cc: Bob Feng Cc: Liming Gao Cc: Leif Lindholm Signed-off-by: Chasel Chiu --- BaseTools/Scripts/GetUtcDateTime.py | 44 ++++++++++++++++++++++++++++++++= ++++++++++++ 1 file changed, 44 insertions(+) diff --git a/BaseTools/Scripts/GetUtcDateTime.py b/BaseTools/Scripts/GetUt= cDateTime.py new file mode 100644 index 0000000000..3cfb6ac2ae --- /dev/null +++ b/BaseTools/Scripts/GetUtcDateTime.py @@ -0,0 +1,44 @@ +## @file +# Get current UTC date and time information and output as ascii code. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
# # +SPDX-License-Identifier: BSD-2-Clause-Patent # + +VersionNumber =3D '0.1' +import sys +import datetime +import argparse + +def Main(): + PARSER =3D argparse.ArgumentParser( + description=3D'Retrieves UTC date and time information (output or= dering: year, date, time) - Version ' + VersionNumber) + PARSER.add_argument('--year', + action=3D'store_true', + help=3D'Return UTC year of now. [Example output (= 2019): 39313032]') + PARSER.add_argument('--date', + action=3D'store_true', + help=3D'Return UTC date MMDD of now. [Example out= put (7th August): 37303830]') + PARSER.add_argument('--time', + action=3D'store_true', + help=3D'Return 24-hour-format UTC time HHMM of=20 +now. [Example output (14:25): 35323431]') + + ARGS =3D PARSER.parse_args() + if len(sys.argv) =3D=3D 1: + print ("ERROR: At least one argument is required!\n") + PARSER.print_help() + + today =3D datetime.datetime.utcnow() + if ARGS.year: + ReversedNumber =3D str(today.year)[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedN= umber)) + if ARGS.date: + ReversedNumber =3D str(today.strftime("%m%d"))[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedN= umber)) + if ARGS.time: + ReversedNumber =3D str(today.strftime("%H%M"))[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in=20 + ReversedNumber)) + +if __name__ =3D=3D '__main__': + Main() -- 2.13.3.windows.1