* Re: [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-05-31 17:02 [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day Meenakshi Aggarwal
@ 2018-05-31 13:07 ` Ard Biesheuvel
2018-05-31 13:47 ` Meenakshi Aggarwal
2018-05-31 19:47 ` [PATCH v2] " Meenakshi Aggarwal
1 sibling, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2018-05-31 13:07 UTC (permalink / raw)
To: Meenakshi Aggarwal; +Cc: Leif Lindholm, edk2-devel@lists.01.org, Vabhav
On 31 May 2018 at 19:02, Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com> wrote:
> This patch add function EfiTimeToWday() which returns
> day of the week.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Signed-off-by: Vabhav <vabhav.sharma@nxp.com>
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-05-31 13:07 ` Ard Biesheuvel
@ 2018-05-31 13:47 ` Meenakshi Aggarwal
0 siblings, 0 replies; 7+ messages in thread
From: Meenakshi Aggarwal @ 2018-05-31 13:47 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: Leif Lindholm, edk2-devel@lists.01.org, Vabhav Sharma
Yes, we need this patch for edk2-platform changes [Leif suggested to move the changes in edk2 as function was a generic one].
Will send V2.
Thanks,
Meenakshi
-----Original Message-----
From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
Sent: Thursday, May 31, 2018 6:38 PM
To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>; edk2-devel@lists.01.org; Vabhav Sharma <vabhav.sharma@nxp.com>
Subject: Re: [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
On 31 May 2018 at 19:02, Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com> wrote:
> This patch add function EfiTimeToWday() which returns day of the week.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Signed-off-by: Vabhav <vabhav.sharma@nxp.com>
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-05-31 19:47 ` [PATCH v2] " Meenakshi Aggarwal
@ 2018-05-31 14:28 ` Ard Biesheuvel
2018-06-04 16:31 ` [PATCH v3] " Meenakshi Aggarwal
1 sibling, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2018-05-31 14:28 UTC (permalink / raw)
To: Meenakshi Aggarwal; +Cc: Leif Lindholm, edk2-devel@lists.01.org, Vabhav Sharma
On 31 May 2018 at 21:47, Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com> 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: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Actually, what is Vabhav's involvement in this patch?
If he is the co-author of the patch, you are welcome to mention him in
the commit log. But adding a signed-off-by implies that it is he who
took your patch and sent it to the mailing list, which is obviously
not the case
> ---
> 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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
@ 2018-05-31 17:02 Meenakshi Aggarwal
2018-05-31 13:07 ` Ard Biesheuvel
2018-05-31 19:47 ` [PATCH v2] " Meenakshi Aggarwal
0 siblings, 2 replies; 7+ messages in thread
From: Meenakshi Aggarwal @ 2018-05-31 17:02 UTC (permalink / raw)
To: leif.lindholm, ard.biesheuvel, edk2-devel
This patch add function EfiTimeToWday() which returns
day of the week.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Vabhav <vabhav.sharma@nxp.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-05-31 17:02 [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day Meenakshi Aggarwal
2018-05-31 13:07 ` Ard Biesheuvel
@ 2018-05-31 19:47 ` Meenakshi Aggarwal
2018-05-31 14:28 ` Ard Biesheuvel
2018-06-04 16:31 ` [PATCH v3] " Meenakshi Aggarwal
1 sibling, 2 replies; 7+ messages in thread
From: Meenakshi Aggarwal @ 2018-05-31 19:47 UTC (permalink / raw)
To: leif.lindholm, ard.biesheuvel, edk2-devel
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: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-05-31 19:47 ` [PATCH v2] " Meenakshi Aggarwal
2018-05-31 14:28 ` Ard Biesheuvel
@ 2018-06-04 16:31 ` Meenakshi Aggarwal
2018-06-05 15:40 ` Leif Lindholm
1 sibling, 1 reply; 7+ messages in thread
From: Meenakshi Aggarwal @ 2018-06-04 16:31 UTC (permalink / raw)
To: leif.lindholm, ard.biesheuvel, edk2-devel
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 <vabhav.sharma@nxp.com>
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] EmbeddedPkg/TimeBaseLib: Add function to get Week day.
2018-06-04 16:31 ` [PATCH v3] " Meenakshi Aggarwal
@ 2018-06-05 15:40 ` Leif Lindholm
0 siblings, 0 replies; 7+ messages in thread
From: Leif Lindholm @ 2018-06-05 15:40 UTC (permalink / raw)
To: Meenakshi Aggarwal; +Cc: ard.biesheuvel, edk2-devel, Vabhav Sharma
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 <vabhav.sharma@nxp.com>
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Thanks.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-06-05 15:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31 17:02 [PATCH] EmbeddedPkg/TimeBaseLib: Add function to get Week day Meenakshi Aggarwal
2018-05-31 13:07 ` Ard Biesheuvel
2018-05-31 13:47 ` Meenakshi Aggarwal
2018-05-31 19:47 ` [PATCH v2] " Meenakshi Aggarwal
2018-05-31 14:28 ` Ard Biesheuvel
2018-06-04 16:31 ` [PATCH v3] " Meenakshi Aggarwal
2018-06-05 15:40 ` Leif Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox