]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PL031RealTimeClockLib: ignore DST setting when timezone is set
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 6 Nov 2017 18:08:15 +0000 (18:08 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 13 Nov 2017 13:33:42 +0000 (13:33 +0000)
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>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c

index f1eb0deb324931f4f7b3c79905e49226d0d208ce..459dcc0a0519277f3f921d5ee170d87d895bbb70 100644 (file)
@@ -164,12 +164,10 @@ LibGetTime (
   }\r
 \r
   // Adjust for the correct time zone\r
+  // The timezone setting also reflects the DST setting of the clock\r
   if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {\r
     EpochSeconds += Time->TimeZone * SEC_PER_MIN;\r
-  }\r
-\r
-  // Adjust for the correct period\r
-  if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {\r
+  } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {\r
     // Convert to adjusted time, i.e. spring forwards one hour\r
     EpochSeconds += SEC_PER_HOUR;\r
   }\r
@@ -229,12 +227,10 @@ LibSetTime (
   EpochSeconds = EfiTimeToEpoch (Time);\r
 \r
   // Adjust for the correct time zone, i.e. convert to UTC time zone\r
+  // The timezone setting also reflects the DST setting of the clock\r
   if (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) {\r
     EpochSeconds -= Time->TimeZone * SEC_PER_MIN;\r
-  }\r
-\r
-  // Adjust for the correct period\r
-  if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {\r
+  } else if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {\r
     // Convert to un-adjusted time, i.e. fall back one hour\r
     EpochSeconds -= SEC_PER_HOUR;\r
   }\r