mktime()

NAME

mktime() - transform format of time value

SYNOPSIS

#include <time.h>

time_t mktime (struct tm *tm)

DESCRIPTION

The function mktime(3) converts the local time, expressed in the structure pointed to by tm into a time_t time value with the same encoding as that of the values returned by the time(2) function, that is, seconds from the Epoch, UTC.

The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to their normal ranges. (A positive or zero value for tm_isdst causes mktime(3) to presume initially that summer time (for example, Daylight Saving Time) is or is not in effect for the specified time, respectively. A negative value for tm_isdst causes the mktime(3) function to attempt to divine whether summer time is in effect for the specified time.)

On successful completion, the values of the tm_wday and tm_yday components of the structure are set appropriately, and the other components are set to represent the specified calendar time, but with their values forced to their normal ranges; the final value of tm_mday is not set until tm_mon and tm_year are determined. Mktime(3) returns the specified calendar time; if the calendar time cannot be represented, it returns -1.

External declarations as well as the tm structure definition are in the <time.h> include file. The tm structure includes at least the following fields:

int tm_sec; seconds (0 - 60)
int tm_min; minutes (0 - 59)
int tm_hour; hours (0 - 23)
int tm_mday; day of month (1 - 31)
int tm_mon; month of year (0 - 11)
int tm_year; year - 1900
int tm_wday; day of week (Sunday = 0)
int tm_yday; day of year (0 - 365)
int tm_isdst; is summer time in effect?

The field tm_isdst is non-zero if summer time is in effect.

SEE ALSO

date(1)

asctime(3)

ctime(3)

gmtime(3)

localtime(3)

difftime(3)

getenv(3)

time(2)

tzset(3)