From nobody Mon Apr 29 01:32:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=nxp.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528109083271681.9554585941208; Mon, 4 Jun 2018 03:44:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DD702209605C6; Mon, 4 Jun 2018 03:44:41 -0700 (PDT) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4F0E32110C819 for ; Mon, 4 Jun 2018 03:44:39 -0700 (PDT) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4C5671A00D5; Mon, 4 Jun 2018 12:44:37 +0200 (CEST) Received: from inv0113.in-blr01.nxp.com (inv0113.in-blr01.nxp.com [165.114.116.118]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 17A311A00EE; Mon, 4 Jun 2018 12:44:37 +0200 (CEST) Received: from uefi-OptiPlex-790.ap.freescale.net (uefi-OptiPlex-790.ap.freescale.net [10.232.132.78]) by inv0113.in-blr01.nxp.com (Postfix) with ESMTP id 2D51C314; Mon, 4 Jun 2018 16:14:36 +0530 (IST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=92.121.34.13; helo=inva020.nxp.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org From: Meenakshi Aggarwal To: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, edk2-devel@lists.01.org Date: Mon, 4 Jun 2018 22:01:44 +0530 Message-Id: <1528129904-28171-1-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527796029-10160-1-git-send-email-meenakshi.aggarwal@nxp.com> References: <1527796029-10160-1-git-send-email-meenakshi.aggarwal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [edk2] [PATCH v3] 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch add function EfiTimeToWday() which returns day of the week. It is needed by our upcoming patches in edk2-platforms. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Vabhav Sharma Signed-off-by: Meenakshi Aggarwal Reviewed-by: Leif Lindholm --- 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/Includ= e/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 ); =20 +/** + returns Day of the week [0-6] 0=3DSunday + **/ +UINTN +EfiTimeToWday ( + IN EFI_TIME *Time + ); + #endif diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Li= brary/TimeBaseLib/TimeBaseLib.c index 0c0d940..5f2bf65 100644 --- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c +++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c @@ -77,11 +77,11 @@ EpochToEfiTime ( } =20 /** - 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 supplie= d Time UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY - UINTN EpochSeconds; =20 a =3D (14 - Time->Month) / 12 ; y =3D Time->Year + 4800 - a; @@ -101,11 +100,44 @@ EfiTimeToEpoch ( ASSERT (JulianDate >=3D EPOCH_JULIAN_DATE); EpochDays =3D JulianDate - EPOCH_JULIAN_DATE; =20 + 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 =3D EfiGetEpochDays (Time); + EpochSeconds =3D (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * SEC_PE= R_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second; =20 return EpochSeconds; } =20 +/** + returns Day of the week [0-6] 0=3DSunday + **/ +UINTN +EfiTimeToWday ( + IN EFI_TIME *Time + ) +{ + UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY + + EpochDays =3D EfiGetEpochDays (Time); + + // 4=3D1/1/1970 was a Thursday + + return (EpochDays + 4) % 7; +} + BOOLEAN EFIAPI IsLeapYear ( --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel