www.delorie.com/djgpp/doc/libc/libc_575.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

mktime

Syntax

 
#include <time.h>

time_t mktime(struct tm *tptr);

Description

This function converts a time structure into the number of seconds since 00:00:00 GMT 1/1/1970. It also attempts to normalize the fields of tptr. The layout of a struct tm is as follows:

 
struct tm {
  int    tm_sec;    /* seconds after the minute [0-60] */
  int    tm_min;    /* minutes after the hour [0-59] */
  int    tm_hour;   /* hours since midnight [0-23] */
  int    tm_mday;   /* day of the month [1-31] */
  int    tm_mon;    /* months since January [0-11] */
  int    tm_year;   /* years since 1900 */
  int    tm_wday;   /* days since Sunday [0-6] */
  int    tm_yday;   /* days since January 1 [0-365] */
  int    tm_isdst;  /* Daylight Savings Time flag */
  long   tm_gmtoff; /* offset from GMT in seconds */
  char * tm_zone;   /* timezone abbreviation */
};

If you don't know whether daylight saving is in effect at the moment specified by the contents of tptr, set the tm_isdst member to -1, which will cause mktime to compute the DST flag using the data base in the `zoneinfo' subdirectory of your main DJGPP installation. This requires that you set the environment variable TZ to a file in that directory which corresponds to your geographical area.

Return Value

The resulting time, or -1 if the time in tptr cannot be described in that format.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004