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.120, mailfrom: bob.c.feng@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Sun, 11 Aug 2019 22:52:18 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Aug 2019 22:52:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,376,1559545200"; d="scan'208";a="375122278" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 11 Aug 2019 22:52:17 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 11 Aug 2019 22:52:17 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 11 Aug 2019 22:52:17 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.249]) with mapi id 14.03.0439.000; Mon, 12 Aug 2019 13:52:15 +0800 From: "Bob Feng" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Gao, Liming" Subject: Re: [edk2-devel] [PATCH] BaseTools/Scripts: Add GetUtcDateTimer script. Thread-Topic: [edk2-devel] [PATCH] BaseTools/Scripts: Add GetUtcDateTimer script. Thread-Index: AQHVTekCobHveXo3FE+kkNlvNNyPwKb3CDdw Date: Mon, 12 Aug 2019 05:52:14 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D161520BE1@SHSMSX104.ccr.corp.intel.com> References: <20190808125807.1840-1-chasel.chiu@intel.com> In-Reply-To: <20190808125807.1840-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 Patch looks good. Reviewed-by: Bob Feng -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chiu= , Chasel Sent: Thursday, August 8, 2019 8:58 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Gao, Liming Subject: [edk2-devel] [PATCH] BaseTools/Scripts: Add GetUtcDateTimer scrip= t. 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 Signed-off-by: Chasel Chiu --- BaseTools/Scripts/GetUtcDateTime.py | 47 ++++++++++++++++++++++++++++++++= +++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/BaseTools/Scripts/GetUtcDateTime.py b/BaseTools/Scripts/GetUt= cDateTime.py new file mode 100644 index 0000000000..8b25a0a867 --- /dev/null +++ b/BaseTools/Scripts/GetUtcDateTime.py @@ -0,0 +1,47 @@ +## @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 + +def Usage(): + print ("GetUtcDateTime - Version " + VersionNumber) + print ("Usage:") + print ("GetUtcDateTime [type]") + print (" --year: Return UTC year of now") + print (" Example output (2019): 39313032") + print (" --date: Return UTC date MMDD of now") + print (" Example output (7th August): 37303830") + print (" --time: Return 24-hour-format UTC time HHMM of n= ow") + print (" Example output (4:25): 35323430") + +def Main(): + if len(sys.argv) =3D=3D 1: + Usage() + return 0 + + today =3D datetime.datetime.utcnow() + if sys.argv[1].strip().lower() =3D=3D "--year": + ReversedNumber =3D str(today.year)[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumbe= r)) + return 0 + if sys.argv[1].strip().lower() =3D=3D "--date": + ReversedNumber =3D str(today.strftime("%m%d"))[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumbe= r)) + return 0 + if sys.argv[1].strip().lower() =3D=3D "--time": + ReversedNumber =3D str(today.strftime("%H%M"))[::-1] + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumbe= r)) + return 0 + else: + Usage() + return 0 + +if __name__ =3D=3D '__main__': + sys.exit(Main()) -- 2.13.3.windows.1