38#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
39#define SECSPERMIN (60)
40#define SECSPERHOUR (60 * 60)
41#define SECSPERDAY (24 * SECSPERHOUR)
48UINTN CumulativeDays[2][14] = {
56 31 + 28 + 31 + 30 + 31,
57 31 + 28 + 31 + 30 + 31 + 30,
58 31 + 28 + 31 + 30 + 31 + 30 + 31,
59 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
60 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
61 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
62 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
63 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
72 31 + 29 + 31 + 30 + 31,
73 31 + 29 + 31 + 30 + 31 + 30,
74 31 + 29 + 31 + 30 + 31 + 30 + 31,
75 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
76 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
77 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
78 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
79 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
97 Status =
gRT->GetTime (&Time,
NULL);
98 if (EFI_ERROR (Status) || (Time.Year < 1970)) {
106 for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
107 CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
115 (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
116 (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
117 (time_t)(Time.Hour * SECSPERHOUR) +
118 (time_t)(Time.Minute * 60) +
147 if (GmTime ==
NULL) {
153 DayNo = (UINT16)(*timer / SECSPERDAY);
154 DayRemainder = (UINT16)(*timer % SECSPERDAY);
156 GmTime->tm_sec = (int)(DayRemainder % SECSPERMIN);
157 GmTime->tm_min = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN);
158 GmTime->tm_hour = (int)(DayRemainder / SECSPERHOUR);
159 GmTime->tm_wday = (int)((DayNo + 4) % 7);
161 for (Year = 1970, YearNo = 0; DayNo > 0; Year++) {
162 TotalDays = (UINT16)(IsLeap (Year) ? 366 : 365);
163 if (DayNo >= TotalDays) {
164 DayNo = (UINT16)(DayNo - TotalDays);
171 GmTime->tm_year = (int)(YearNo + (1970 - 1900));
172 GmTime->tm_yday = (int)DayNo;
174 for (MonthNo = 12; MonthNo > 1; MonthNo--) {
175 if (DayNo >= CumulativeDays[IsLeap (Year)][MonthNo]) {
176 DayNo = (UINT16)(DayNo - (UINT16)(CumulativeDays[IsLeap (Year)][MonthNo]));
181 GmTime->tm_mon = (int)MonthNo - 1;
182 GmTime->tm_mday = (int)DayNo + 1;
184 GmTime->tm_isdst = 0;
185 GmTime->tm_gmtoff = 0;
186 GmTime->tm_zone =
NULL;
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
struct tm * gmtime(const time_t *)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_RUNTIME_SERVICES * gRT
#define EFI_UNSPECIFIED_TIMEZONE
time_t _time64(time_t *t)