The program below calls getdate() for each of its command-line arguments, and for each call displays the values in the fields of the returned tm structure.
The following shell session demonstrates the operation of the program: $ TFILE=$PWD/tfile $ echo '%A' $TFILE # Time (HH: MM: SS) $ date $ export DATEMSK=$TFILE $ ./Tuesday '2009-12-28' '' Sun Sep 7 CEST 2008 Call 1 ("Tuesday") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 9 tm_mon = 8 tm_year = 108 tm_wday = 2 tm_yday = 252 tm_isdst = 1 Call 2 ("2009-12-28") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 28 tm_mon = 11 tm_year = 109 tm_wday = 1 tm_yday = 361 tm_isdst = 0 Call 3 ("") succeeded: tm_sec = 33 tm_min = 22 tm_hour = 12 tm_mday = 7 tm_mon = 8 tm_year = 108 tm_wday = 0 tm_yday = 250 tm_isdst = 1 Program source #define _GNU_SOURCE #include This page is part of release 5.02 of the Linux man-pages project.
Rather than using a global variable to report errors and a static buffer to return the broken down time, it returns errors via the function result value, and returns the resulting broken-down time in the caller-allocated buffer pointed to by the argument res.
When successful, getdate() returns a pointer to a struct tm.
The match between the template and input specification performed by getdate() shall be case-insensitive.
The month and weekday names can consist of any combination of upper and lowercase letters.
The external variable or macro getdate_err is used by getdate() to return error values.
The broken-down time is stored in a tm structure, and a pointer to this structure is returned as the function result.
If no day is given, it is the first day of the month.
When no hour, minute and second are given, the current hour, minute and second are taken.
Otherwise, it returns NULL and sets the global variable getdate_err to one of the error numbers shown below. On success getdate_r() returns 0; on error it returns one of the error numbers shown below.
The following errors are returned via getdate_err (for getdate()) or as the function result (for getdate_r()): 1 The DATEMSK environment variable is not defined, or its value is an empty string. 5 An error was encountered while reading the template file.
is not the timezone that getdate() expects, an invalid input specification error shall result.