static void convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) { memset(wtime, 0, sizeof(*wtime)); wtime->tm_sec = eft->second; wtime->tm_min = eft->minute; wtime->tm_hour = eft->hour; wtime->tm_mday = eft->day; wtime->tm_mon = eft->month - 1; wtime->tm_year = eft->year - 1900; /* day of the week [0-6], Sunday=0 */ wtime->tm_wday = compute_wday(eft); /* day in the year [1-365]*/ wtime->tm_yday = compute_yday(eft); switch (eft->daylight & EFI_ISDST) { case EFI_ISDST: wtime->tm_isdst = 1; break; case EFI_TIME_ADJUST_DAYLIGHT: wtime->tm_isdst = 0; break; default: wtime->tm_isdst = -1; } }
static bool convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) { memset(wtime, 0, sizeof(*wtime)); if (eft->second >= 60) return false; wtime->tm_sec = eft->second; if (eft->minute >= 60) return false; wtime->tm_min = eft->minute; if (eft->hour >= 24) return false; wtime->tm_hour = eft->hour; if (!eft->day || eft->day > 31) return false; wtime->tm_mday = eft->day; if (!eft->month || eft->month > 12) return false; wtime->tm_mon = eft->month - 1; if (eft->year < 1900 || eft->year > 9999) return false; wtime->tm_year = eft->year - 1900; /* day in the year [1-365]*/ wtime->tm_yday = compute_yday(eft); /* day of the week [0-6], Sunday=0 */ wtime->tm_wday = compute_wday(eft, wtime->tm_yday); switch (eft->daylight & EFI_ISDST) { case EFI_ISDST: wtime->tm_isdst = 1; break; case EFI_TIME_ADJUST_DAYLIGHT: wtime->tm_isdst = 0; break; default: wtime->tm_isdst = -1; } return true; }