iPXE
time.h
Go to the documentation of this file.
1 #ifndef _TIME_H
2 #define _TIME_H
3 
4 /** @file
5  *
6  * Date and time
7  */
8 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 FILE_SECBOOT ( PERMITTED );
11 
12 #include <sys/time.h>
13 #include <ipxe/time.h>
14 
15 /** Broken-down time */
16 struct tm {
17  /** Seconds [0,60] */
18  int tm_sec;
19  /** Minutes [0,59] */
20  int tm_min;
21  /** Hour [0,23] */
22  int tm_hour;
23  /** Day of month [1,31] */
24  int tm_mday;
25  /** Month of year [0,11] */
26  int tm_mon;
27  /** Years since 1900 */
28  int tm_year;
29  /** Day of week [0,6] (Sunday=0) */
30  int tm_wday;
31  /** Day of year [0,365] */
32  int tm_yday;
33  /** Daylight savings flag */
34  int tm_isdst;
35 };
36 
37 /**
38  * Get current time in seconds since the Epoch
39  *
40  * @v t Time to fill in, or NULL
41  * @ret time Current time
42  */
43 static inline __attribute__ (( always_inline )) time_t time ( time_t *t ) {
44  time_t now;
45 
46  now = ( time_now() + time_offset );
47  if ( t )
48  *t = now;
49  return now;
50 }
51 
52 extern time_t mktime ( struct tm *tm );
53 
54 #endif /* _TIME_H */
signed long time_offset
Current system clock offset.
Definition: time.c:48
int tm_min
Minutes [0,59].
Definition: time.h:20
int tm_mday
Day of month [1,31].
Definition: time.h:24
Date and time.
int tm_year
Years since 1900.
Definition: time.h:28
time_t time_now(void)
Get current time in seconds (ignoring system clock offset)
FILE_SECBOOT(PERMITTED)
int tm_mon
Month of year [0,11].
Definition: time.h:26
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Broken-down time.
Definition: time.h:16
int tm_wday
Day of week [0,6] (Sunday=0)
Definition: time.h:30
int tm_yday
Day of year [0,365].
Definition: time.h:32
time_t mktime(struct tm *tm)
Calculate seconds since the Epoch.
Definition: time.c:118
static __attribute__((always_inline)) time_t time(time_t *t)
Get current time in seconds since the Epoch.
Definition: time.h:43
int tm_sec
Seconds [0,60].
Definition: time.h:18
int tm_hour
Hour [0,23].
Definition: time.h:22
int64_t time_t
Seconds since the Epoch.
Definition: time.h:19
Time source.
int tm_isdst
Daylight savings flag.
Definition: time.h:34