diff mbox series

[1/1] efi_loader: daylight saving time

Message ID 20201027200910.17244-1-xypron.glpk@gmx.de
State Accepted, archived
Commit 0eae552d18690a19cc714046fb1665138f5701f6
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] efi_loader: daylight saving time | expand

Commit Message

Heinrich Schuchardt Oct. 27, 2020, 8:09 p.m. UTC
Adjust the SetTime() and GetTime() runtime services to correctly convert
the daylight saving time information when communicating with the RTC.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_runtime.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

--
2.28.0
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index dea2b4e5ee..1fa1595e40 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -266,9 +266,13 @@  static efi_status_t EFIAPI efi_get_time_boottime(
 	time->hour = tm.tm_hour;
 	time->minute = tm.tm_min;
 	time->second = tm.tm_sec;
-	if (tm.tm_isdst)
+	if (tm.tm_isdst > 0)
 		time->daylight =
 			EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT;
+	else if (!tm.tm_isdst)
+		time->daylight = EFI_TIME_ADJUST_DAYLIGHT;
+	else
+		time->daylight = 0;
 	time->timezone = EFI_UNSPECIFIED_TIMEZONE;

 	if (capabilities) {
@@ -347,8 +351,17 @@  static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time)
 	tm.tm_hour = time->hour;
 	tm.tm_min = time->minute;
 	tm.tm_sec = time->second;
-	tm.tm_isdst = time->daylight ==
-		      (EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT);
+	switch (time->daylight) {
+	case EFI_TIME_ADJUST_DAYLIGHT:
+		tm.tm_isdst = 0;
+		break;
+	case EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT:
+		tm.tm_isdst = 1;
+		break;
+	default:
+		tm.tm_isdst = -1;
+		break;
+	}
 	/* Calculate day of week */
 	rtc_calc_weekday(&tm);