19#define SECSPERMIN (60)
20#define SECSPERHOUR (60 * 60)
21#define SECSPERDAY (24 * SECSPERHOUR)
30UINTN CumulativeDays[2][14] = {
38 31 + 28 + 31 + 30 + 31,
39 31 + 28 + 31 + 30 + 31 + 30,
40 31 + 28 + 31 + 30 + 31 + 30 + 31,
41 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
42 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
43 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
44 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
45 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
54 31 + 29 + 31 + 30 + 31,
55 31 + 29 + 31 + 30 + 31 + 30,
56 31 + 29 + 31 + 30 + 31 + 30 + 31,
57 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
58 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
59 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
60 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
61 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
82 return (Remainder1 == 0 && (Remainder2 != 0 || Remainder3 == 0));
98 for (Year = 1970, CalTime = 0; Year != Time->Year; Year++) {
99 CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
107 (time_t)(CumulativeDays[IsLeap (Time->Year)][Time->Month] * SECSPERDAY) +
108 (time_t)(((Time->Day > 0) ? Time->Day - 1 : 0) * SECSPERDAY) +
109 (time_t)(Time->Hour * SECSPERHOUR) +
110 (time_t)(Time->Minute * 60) +
111 (time_t)Time->Second;
132 Status =
gRT->GetTime (&Time,
NULL);
133 if (EFI_ERROR (Status) || (Time.Year < 1970)) {
137 CalTime = CalculateTimeT (&Time);
152 .Year = (UINT16)t->tm_year,
153 .Month = (UINT8)t->tm_mon,
154 .Day = (UINT8)t->tm_mday,
155 .Hour = (UINT8)t->tm_hour,
156 .Minute = (UINT8)t->tm_min,
157 .Second = (UINT8)t->tm_sec,
161 return CalculateTimeT (&Time);
185 GmTime = malloc (
sizeof (
struct tm));
186 if (GmTime ==
NULL) {
193 DayRemainder = (UINT64)Remainder;
196 GmTime->tm_sec = (int)Remainder;
201 GmTime->tm_wday = (int)Remainder;
203 for (Year = 1970, YearNo = 0; DayNo > 0; Year++) {
204 TotalDays = (UINT32)(IsLeap (Year) ? 366 : 365);
205 if (DayNo >= TotalDays) {
206 DayNo = (UINT64)(DayNo - TotalDays);
213 GmTime->tm_year = (int)(YearNo + (1970 - 1900));
214 GmTime->tm_yday = (int)DayNo;
216 for (MonthNo = 12; MonthNo > 1; MonthNo--) {
217 if (DayNo >= CumulativeDays[IsLeap (Year)][MonthNo]) {
218 DayNo = (UINT64)(DayNo - (UINT32)(CumulativeDays[IsLeap (Year)][MonthNo]));
223 GmTime->tm_mon = (int)MonthNo - 1;
224 GmTime->tm_mday = (int)DayNo + 1;
226 GmTime->tm_isdst = 0;
227 GmTime->tm_gmtoff = 0;
228 GmTime->tm_zone =
NULL;
238 gBS->Stall (seconds * 1000 * 1000);
INT64 EFIAPI DivS64x64Remainder(IN INT64 Dividend, IN INT64 Divisor, OUT INT64 *Remainder OPTIONAL)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
struct tm * gmtime(const time_t *)
EFI_RUNTIME_SERVICES * gRT
#define EFI_UNSPECIFIED_TIMEZONE