From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (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 45CB021195BF6 for ; Tue, 5 Jun 2018 08:40:32 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id x6-v6so5801446wmc.3 for ; Tue, 05 Jun 2018 08:40:32 -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=FtCiWDYpqjVAAmInmxPmGqAYxtLkQLbERONvFTpogDk=; b=OkE0TGMBjR3OlCDvAhgpVU0nbKnEblX+3GdjlFS85MffxqpBPNGN56fO3JqtK7QZHi o3EReI8W61FQJ1kgt7+R0dm7ihuNsD0rJWJ0N8EOgTKrA6WF6yJqZurh0uOfZHy8//7a /HIyOg8WOOKas9cPmEMz8/2zuqfjj+RiylcOM= 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=FtCiWDYpqjVAAmInmxPmGqAYxtLkQLbERONvFTpogDk=; b=tZ1hl2RFjLhaAC2BsBQLZ4Bd5V1YiI/AWJWkGCOc+WuOCpRWO3ILy+AyPeqwjwQGVT GZvesYVkNeHC1MLDK1E5Pt31cf5P8+MXvv5onuvlGFV7Helqb8LPni3bvEjnB9lMbKhN v2uOaF/6GAVy7BBngUZigljtkbNKzU7N8xqxtUc2wflFc4t9xyPd+0s7dw2vsZ4B32CZ b1kE9mt/mxYMn/w9g7X/XPL4BBLQ8sNv55S9PoEj2R7zi5ozI/kyYFPNh7nETy2CcsYo wgKTsaD+oZAFXWpHF85Tgq9uHlTcP6c8VTKOT1zd4eJ6A9onRa/+ZA6+2/0oeZh6wKZS MXHg== X-Gm-Message-State: ALKqPwdN+TProE4K+wgzrh+5AwO8Bm0QP55Uz+ge4MWA7+XL9Ez95kZc OnHi1DmPAZerWQQ+Djj2GqVNHQ== X-Google-Smtp-Source: ADUXVKIZIMlNNzkW9oZjzi7W5BOF3ql/+0PiSb/XHskFvJCh+3b10twiLxU4FRjdrkL0DrxmGAW+9w== X-Received: by 2002:a1c:e846:: with SMTP id f67-v6mr12054042wmh.63.1528213230523; Tue, 05 Jun 2018 08:40:30 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id e13-v6sm36173622wrm.45.2018.06.05.08.40.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 08:40:28 -0700 (PDT) Date: Tue, 5 Jun 2018 16:40:26 +0100 From: Leif Lindholm To: Meenakshi Aggarwal Cc: ard.biesheuvel@linaro.org, edk2-devel@lists.01.org, Vabhav Sharma Message-ID: <20180605154026.t4vrl7answ2a7ldm@bivouac.eciton.net> References: <1527796029-10160-1-git-send-email-meenakshi.aggarwal@nxp.com> <1528129904-28171-1-git-send-email-meenakshi.aggarwal@nxp.com> MIME-Version: 1.0 In-Reply-To: <1528129904-28171-1-git-send-email-meenakshi.aggarwal@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [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: , X-List-Received-Date: Tue, 05 Jun 2018 15:40:32 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 04, 2018 at 10:01:44PM +0530, Meenakshi Aggarwal wrote: > 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 Thanks. Reviewed-by: Leif Lindholm Pushed as 91c31ff04a. / Leif > --- > 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 >