2007-01-19 04:09:22 +01:00
|
|
|
#ifndef _TIME_H
|
|
|
|
#define _TIME_H
|
|
|
|
|
2012-03-19 17:09:41 +01:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Date and time
|
|
|
|
*/
|
2007-01-19 04:09:22 +01:00
|
|
|
|
2015-03-02 12:54:40 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
2013-07-16 00:23:09 +02:00
|
|
|
|
2012-03-19 17:09:41 +01:00
|
|
|
#include <sys/time.h>
|
2012-03-19 17:59:53 +01:00
|
|
|
#include <ipxe/time.h>
|
2012-03-19 17:09:41 +01:00
|
|
|
|
|
|
|
/** Broken-down time */
|
2007-01-19 04:09:22 +01:00
|
|
|
struct tm {
|
2012-03-19 17:09:41 +01:00
|
|
|
/** Seconds [0,60] */
|
|
|
|
int tm_sec;
|
|
|
|
/** Minutes [0,59] */
|
|
|
|
int tm_min;
|
|
|
|
/** Hour [0,23] */
|
|
|
|
int tm_hour;
|
|
|
|
/** Day of month [1,31] */
|
|
|
|
int tm_mday;
|
|
|
|
/** Month of year [0,11] */
|
|
|
|
int tm_mon;
|
|
|
|
/** Years since 1900 */
|
|
|
|
int tm_year;
|
|
|
|
/** Day of week [0,6] (Sunday=0) */
|
|
|
|
int tm_wday;
|
|
|
|
/** Day of year [0,365] */
|
|
|
|
int tm_yday;
|
|
|
|
/** Daylight savings flag */
|
|
|
|
int tm_isdst;
|
2007-01-19 04:09:22 +01:00
|
|
|
};
|
|
|
|
|
2012-03-19 17:59:53 +01:00
|
|
|
/**
|
|
|
|
* Get current time in seconds since the Epoch
|
|
|
|
*
|
|
|
|
* @v t Time to fill in, or NULL
|
|
|
|
* @ret time Current time
|
|
|
|
*/
|
2016-06-13 16:29:05 +02:00
|
|
|
static inline __attribute__ (( always_inline )) time_t time ( time_t *t ) {
|
2012-03-19 17:59:53 +01:00
|
|
|
time_t now;
|
|
|
|
|
2016-06-13 16:29:05 +02:00
|
|
|
now = ( time_now() + time_offset );
|
2012-03-19 17:59:53 +01:00
|
|
|
if ( t )
|
|
|
|
*t = now;
|
|
|
|
return now;
|
|
|
|
}
|
|
|
|
|
2007-01-19 04:09:22 +01:00
|
|
|
extern time_t mktime ( struct tm *tm );
|
|
|
|
|
|
|
|
#endif /* _TIME_H */
|