From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=yhC6L1PQ; spf=pass (domain: linaro.org, ip: 209.85.128.43, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by groups.io with SMTP; Wed, 14 Aug 2019 04:14:08 -0700 Received: by mail-wm1-f43.google.com with SMTP id z23so4107490wmf.2 for ; Wed, 14 Aug 2019 04:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bPFBMQ9rHVRjfsI6Fe4RZblj5l+mtDZH7a5k2glUEU8=; b=yhC6L1PQkAzGUbJvaIZ9lZBJVoH7aJ8uTe1Oi+OTRHeNftxrfIQy0aA5BvP6PAyY8+ 9FP8FP9KUFc5qq2qFEV6cMpldeFJ9ltEIsW0IPFBDGHUCAH+ueEjgbPXF6bFcFEXpuKk viJJCetHCMk37NkqhiWx0WcyUwf2nVVzIsIB4DK4OszOAkq3aOlTuQlVEE1Hibn/u0mD O2RTc2JhuIsfwvfJ/TmQT6kaXgL9Tklamh4IDcWLhz+rHNOm/LOQR4t4eTzncdJz3q75 egPANYLEnTid/0QnjeEO3b3ehGNAWXnOM1BoKEEMBQj2FWkmL6hwpYOI1FfsDLOgn5z8 OsEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bPFBMQ9rHVRjfsI6Fe4RZblj5l+mtDZH7a5k2glUEU8=; b=dHry7dfzAOSpEFLa1c83QCCkLNfsie/CZv+ic4K4drgVnxHJ+gc/5UCqqwam0+yHvU bIs313N1B7PV6Ujl3dJKH1ff7ABP//9MWgYkco0P12d/xpLS1MAPF5YP0irhVHAff5KF ZbH0muKhymly7eibq/DOSuBtngYn/1uLhG47zaPZp3NJlrrJDBkDSh62wDOwusg6QbHP BqC5kLzRpuxxl+En4dP4d6+If0ZKgCr2fa4ibIXFpx/OK/3Ytck4P7yLVy1m4a8rpheh 3aN5WJqfMBIVqgIKBuLT+IBotAAc0oo1pVxV1GKi1m2oqe/RERXhsL3yrNBps2KCJme6 Dq8g== X-Gm-Message-State: APjAAAUVVF2JLYvlJikj8e54fTyEdRje/btwVpONBE6xC4SJwgbu8ung eyY2aPmByaRxjR6Ixu5xRd7pRw== X-Google-Smtp-Source: APXvYqzfY8EKnSPq1biJ3qiFJoNNKBNzNXnj/Gu/TtiHOKRKgOUMrgGH/+Dnjra1k3VYCpmFxXVhhA== X-Received: by 2002:a7b:cb89:: with SMTP id m9mr8416207wmi.154.1565781247036; Wed, 14 Aug 2019 04:14:07 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id r5sm5358774wmh.35.2019.08.14.04.14.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 04:14:06 -0700 (PDT) Date: Wed, 14 Aug 2019 12:14:04 +0100 From: "Leif Lindholm" To: Chasel Chiu Cc: devel@edk2.groups.io Subject: Re: [PATCH v2] BaseTools/Scripts: Add GetUtcDateTime script. Message-ID: <20190814111404.GG29255@bivouac.eciton.net> References: <20190814102106.9236-1-chasel.chiu@intel.com> MIME-Version: 1.0 In-Reply-To: <20190814102106.9236-1-chasel.chiu@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Aug 14, 2019 at 06:21:06PM +0800, Chasel Chiu wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2067 > > A script that can return UTC date and time in ascii > format which is convenient for patching build time > information in any binary. > > Cc: Bob Feng > Cc: Liming Gao > Cc: Leif Lindholm > Signed-off-by: Chasel Chiu Yeah, this looks a lot better, thanks. Acked-by: Leif Lindholm > --- > BaseTools/Scripts/GetUtcDateTime.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/BaseTools/Scripts/GetUtcDateTime.py b/BaseTools/Scripts/GetUtcDateTime.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 = '0.1' > +import sys > +import datetime > +import argparse > + > +def Main(): > + PARSER = argparse.ArgumentParser( > + description='Retrieves UTC date and time information (output ordering: year, date, time) - Version ' + VersionNumber) > + PARSER.add_argument('--year', > + action='store_true', > + help='Return UTC year of now. [Example output (2019): 39313032]') > + PARSER.add_argument('--date', > + action='store_true', > + help='Return UTC date MMDD of now. [Example output (7th August): 37303830]') > + PARSER.add_argument('--time', > + action='store_true', > + help='Return 24-hour-format UTC time HHMM of now. [Example output (14:25): 35323431]') > + > + ARGS = PARSER.parse_args() > + if len(sys.argv) == 1: > + print ("ERROR: At least one argument is required!\n") > + PARSER.print_help() > + > + today = datetime.datetime.utcnow() > + if ARGS.year: > + ReversedNumber = str(today.year)[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber)) > + if ARGS.date: > + ReversedNumber = str(today.strftime("%m%d"))[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber)) > + if ARGS.time: > + ReversedNumber = str(today.strftime("%H%M"))[::-1] > + print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNumber)) > + > +if __name__ == '__main__': > + Main() > -- > 2.13.3.windows.1 >