From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::22d; helo=mail-io0-x22d.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E674D2098C224 for ; Thu, 31 May 2018 06:07:42 -0700 (PDT) Received: by mail-io0-x22d.google.com with SMTP id u4-v6so1948400iof.2 for ; Thu, 31 May 2018 06:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7SvyBSiONxHz6jpdLHiIElbQ3kmNJqiypMrqA1WWOoU=; b=cM4RWfrPEKCEICZTtw10Y6inRdEfzhaGRtdwv8jD7CGPyjnL+QTcqNGhJ6eLwdHnBv dkjm/JmP4paCi3Qac9Zz5jRctgx6qNbOr0rsWmA7MevXoKryo/v6AXhyDPs0pIaY6bhd rmElWImD/qS0E69yoWhN3pGhU+5xmxQJJE6Rk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7SvyBSiONxHz6jpdLHiIElbQ3kmNJqiypMrqA1WWOoU=; b=rWBlzqtz/7z37Tz5QeL62x91/awq1C6yXelQatEiR4P6i7TbVgszOeUtYrjN/s4khT Zc4XKoP2fcm/e6O2PeXdB+Re76sFft9Z/wzz+Dr2pTPqC8FT6bvMrU9KHbqUgf+ah4Ij bqb+rf1UQ9qbAC5VIIgHtBobByfIh93Tj4sfT5QPzTWwopCNcHoxu7yZbOixMWYt70X7 EVqxZEVAhREfJR1d811tkpW6clRf9HtpKYvuwf3mz7Y2/CJwBGV+PCULodIFQtafTGge pgyKkbWPgwqmTSWilJPzKlBDqeSuLAXC8oR8zHqmCTxHgkwOOdK969O9I2Pq8BDpu0Ue hc+A== X-Gm-Message-State: ALKqPwffRUR6WOUqYdPqMHU40TBEO4/uErZpOE9lSIoEL3sxoKr767xR 8WtHePnOvmDoM23d+r33vL5ueT87qkytCAjXVMk/9g== X-Google-Smtp-Source: ADUXVKJIfe0MIm5flohImUEo7RR3Wp3PIPmGnmEshnOtwvLjQbwqc1X/dQRgaWE6KXwBB2B8J9OJdZ2laipdQSAx/OI= X-Received: by 2002:a6b:268b:: with SMTP id m133-v6mr6622247iom.107.1527772062150; Thu, 31 May 2018 06:07:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bb86:0:0:0:0:0 with HTTP; Thu, 31 May 2018 06:07:41 -0700 (PDT) In-Reply-To: <1527786160-9755-1-git-send-email-meenakshi.aggarwal@nxp.com> References: <1527786160-9755-1-git-send-email-meenakshi.aggarwal@nxp.com> From: Ard Biesheuvel Date: Thu, 31 May 2018 15:07:41 +0200 Message-ID: To: Meenakshi Aggarwal Cc: Leif Lindholm , "edk2-devel@lists.01.org" , Vabhav Subject: Re: [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 13:07:43 -0000 Content-Type: text/plain; charset="UTF-8" On 31 May 2018 at 19:02, Meenakshi Aggarwal wrote: > This patch add function EfiTimeToWday() which returns > day of the week. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Meenakshi Aggarwal > Signed-off-by: Vabhav Please use your full name in the S-o-b line Also, do you need this patch for upcoming edk2-platforms changes? If so, please mention that, otherwise it is unclear why we need this change. > --- > EmbeddedPkg/Include/Library/TimeBaseLib.h | 8 ++++++ > EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c | 38 ++++++++++++++++++++++++--- > 2 files changed, 43 insertions(+), 3 deletions(-) > > diff --git a/EmbeddedPkg/Include/Library/TimeBaseLib.h b/EmbeddedPkg/Include/Library/TimeBaseLib.h > index fe3618e..dd0b99f 100644 > --- a/EmbeddedPkg/Include/Library/TimeBaseLib.h > +++ b/EmbeddedPkg/Include/Library/TimeBaseLib.h > @@ -65,4 +65,12 @@ EfiTimeToEpoch ( > IN EFI_TIME *Time > ); > > +/** > + returns Day of the week [0-6] 0=Sunday > + **/ > +UINTN > +EfiTimeToWday ( > + IN EFI_TIME *Time > + ); > + > #endif > diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c > index 0c0d940..5f2bf65 100644 > --- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c > +++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c > @@ -77,11 +77,11 @@ EpochToEfiTime ( > } > > /** > - Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) > + Calculate Epoch days > **/ > UINTN > EFIAPI > -EfiTimeToEpoch ( > +EfiGetEpochDays ( > IN EFI_TIME *Time > ) > { > @@ -90,7 +90,6 @@ EfiTimeToEpoch ( > UINTN m; > UINTN JulianDate; // Absolute Julian Date representation of the supplied Time > UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY > - UINTN EpochSeconds; > > a = (14 - Time->Month) / 12 ; > y = Time->Year + 4800 - a; > @@ -101,11 +100,44 @@ EfiTimeToEpoch ( > ASSERT (JulianDate >= EPOCH_JULIAN_DATE); > EpochDays = JulianDate - EPOCH_JULIAN_DATE; > > + return EpochDays; > +} > +/** > + Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) > + **/ > +UINTN > +EFIAPI > +EfiTimeToEpoch ( > + IN EFI_TIME *Time > + ) > +{ > + UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY > + UINTN EpochSeconds; > + > + EpochDays = EfiGetEpochDays (Time); > + > EpochSeconds = (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * SEC_PER_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second; > > return EpochSeconds; > } > > +/** > + returns Day of the week [0-6] 0=Sunday > + **/ > +UINTN > +EfiTimeToWday ( > + IN EFI_TIME *Time > + ) > +{ > + UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY > + > + EpochDays = EfiGetEpochDays (Time); > + > + // 4=1/1/1970 was a Thursday > + > + return (EpochDays + 4) % 7; > +} > + > BOOLEAN > EFIAPI > IsLeapYear ( > -- > 1.9.1 >