Message ID | 20171106182038.16750-4-ard.biesheuvel@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | ArmPlatformPkg EmbeddedPkg: consolidate shared RTC functionality | expand |
On Mon, Nov 06, 2017 at 06:20:38PM +0000, Ard Biesheuvel wrote: > According to the UEFI spec, the timezone setting which the platform needs > to record in addition to the actual date and time already reflects the > current DST setting. In other words, moving the clock from standard time > to daylight saving time also involves adding or subtracting 60 minutes > from the timezone setting, as well as flicking the EFI_TIME_IN_DAYLIGHT > bit in the DST setting. > > This means we need to disregard the DST setting if the timezone is > specified, and only add or subtract the additional hour if we are on > local time. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Assuming I understand the above correctly, and page 259/260 in 2.7a: Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> > --- > ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c > index f1eb0deb3249..459dcc0a0519 100644 > --- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c > +++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c > @@ -164,12 +164,10 @@ LibGetTime ( > } > > // Adjust for the correct time zone > + // The timezone setting also reflects the DST setting of the clock > if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { > EpochSeconds += Time->TimeZone * SEC_PER_MIN; > - } > - > - // Adjust for the correct period > - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { > + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { > // Convert to adjusted time, i.e. spring forwards one hour > EpochSeconds += SEC_PER_HOUR; > } > @@ -229,12 +227,10 @@ LibSetTime ( > EpochSeconds = EfiTimeToEpoch (Time); > > // Adjust for the correct time zone, i.e. convert to UTC time zone > + // The timezone setting also reflects the DST setting of the clock > if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { > EpochSeconds -= Time->TimeZone * SEC_PER_MIN; > - } > - > - // Adjust for the correct period > - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { > + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { > // Convert to un-adjusted time, i.e. fall back one hour > EpochSeconds -= SEC_PER_HOUR; > } > -- > 2.11.0 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c index f1eb0deb3249..459dcc0a0519 100644 --- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c +++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c @@ -164,12 +164,10 @@ LibGetTime ( } // Adjust for the correct time zone + // The timezone setting also reflects the DST setting of the clock if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { EpochSeconds += Time->TimeZone * SEC_PER_MIN; - } - - // Adjust for the correct period - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { // Convert to adjusted time, i.e. spring forwards one hour EpochSeconds += SEC_PER_HOUR; } @@ -229,12 +227,10 @@ LibSetTime ( EpochSeconds = EfiTimeToEpoch (Time); // Adjust for the correct time zone, i.e. convert to UTC time zone + // The timezone setting also reflects the DST setting of the clock if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) { EpochSeconds -= Time->TimeZone * SEC_PER_MIN; - } - - // Adjust for the correct period - if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { + } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) { // Convert to un-adjusted time, i.e. fall back one hour EpochSeconds -= SEC_PER_HOUR; }
According to the UEFI spec, the timezone setting which the platform needs to record in addition to the actual date and time already reflects the current DST setting. In other words, moving the clock from standard time to daylight saving time also involves adding or subtracting 60 minutes from the timezone setting, as well as flicking the EFI_TIME_IN_DAYLIGHT bit in the DST setting. This means we need to disregard the DST setting if the timezone is specified, and only add or subtract the additional hour if we are on local time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel