GETDATESection: Linux Programmer's Manual (3)Updated: 2001-12-26 |
GETDATESection: Linux Programmer's Manual (3)Updated: 2001-12-26 |
struct tm *getdate (const char *string);
extern int getdate_err;
#define _GNU_SOURCE
#include <time.h>
int getdate_r (const char *string, struct tm *res);
In contrast to strptime(3), (which has a format argument), getdate() uses the formats found in the file of which the full path name is given in the environment variable DATEMSK. The first line in the file that matches the given input string is used for the conversion.
The matching is done case insensitively. Superfluous whitespace, either in the pattern or in the string to be converted, is ignored.
The conversion specifications that a pattern can contain are those given for strptime(3). One more conversion specification is accepted:
When %Z is given, the value to be returned is initialised to the broken-down time corresponding to the current time in the given time zone. Otherwise, it is initialised to the broken-down time corresponding to the current local time.
When only the weekday is given, the day is taken to be the first such day on or after today.
When only the month is given (and no year), the month is taken to be the first such month equal to or after the current month. 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.
If no date is given, but we know the hour, then that hour is taken to be the first such hour equal to or after the current hour.
The POSIX 1003.1-2001 specification for strptime() contains conversion specifications using the %E or %O modifier, while such specifications are not given for getdate(). The glibc implementation implements getdate() using strptime() so that automatically precisely the same conversions are supported by both.
The glibc implementation does not support the %Z conversion specification.