[libc] Add mktime() function

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-03-19 16:09:41 +00:00
parent 0b2c7885c7
commit bd6805a8c1
3 changed files with 173 additions and 25 deletions

View File

@@ -1,20 +1,18 @@
#ifndef _SYS_TIME_H
#define _SYS_TIME_H
#include <time.h>
/** @file
*
* Date and time
*/
typedef unsigned long suseconds_t;
#include <stdint.h>
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
struct timezone {
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
extern int gettimeofday ( struct timeval *tv, struct timezone *tz );
/** Seconds since the Epoch
*
* We use a 64-bit type to avoid Y2K38 issues, since we may have to
* handle distant future dates (e.g. X.509 certificate expiry dates).
*/
typedef int64_t time_t;
#endif /* _SYS_TIME_H */

View File

@@ -1,22 +1,35 @@
#ifndef _TIME_H
#define _TIME_H
typedef unsigned long time_t;
/** @file
*
* Date and time
*/
#include <sys/time.h>
/** Broken-down time */
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
/** 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;
};
extern time_t time ( time_t *t );
extern time_t mktime ( struct tm *tm );
#endif /* _TIME_H */