getdate.3c (2010 09)
g
getdate(3C) getdate(3C)
NAME
getdate() - convert user format date and time
SYNOPSIS
#include <time.h>
struct tm *getdate(const char *string);
Obsolescent Interface
int getdate_r(const char *string, struct tm *result, int *errnum);
DESCRIPTION
The getdate() function converts user definable date and/or time specifications pointed to by string into
a
struct tm. The structure declaration is in the
<time.h> header file (see ctime (3C)).
User-supplied templates are used to parse and interpret the input string. The templates are text files
created by the user and identified via the environment variable
DATEMSK. DATEMSK should be set to
indicate the full path name of the template file. The first line in the template that matches the input
specification is used for interpretation and conversion into the internal time format. Upon successful
completion,
getdate() returns a pointer to a
struct tm; otherwise, it returns NULL and the symbol
getdate_err is set to indicate the error.
The following field descriptors are supported:
%% same as %
%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c locale’s appropriate date and time representation
%C century number (00 through 99; leading zeros are permitted but not required)
%d day of the month (01 through 31; the leading 0 is optional)
%e same as %d
%D date as %m/%d/%y
%h abbreviated month name
%H hour (00 through 23)
%I hour (01 through 12)
%m month number (01 through 12)
%M minute (00 through 59)
%n same as \n
%p locale’s equivalent of either AM or PM
%r time as %I:%M:%S %p
%R time as %H:%M
%S seconds (00 through 61)
%t insert a tab
%T time as %H:%M:%S
%w weekday number (Sunday = 0 through Saturday = 6)
%x locale’s appropriate date representation
%X locale’s appropriate time representation
%y year without century (00 through 99). For inputs 69-99, the 20th century (1900s) is
assumed, and for inputs 00-68, the 21st century (2000s) is assumed.
%Y year as ccyy (e.g., 1986)
%Z time zone name or no characters if no time zone exists. If the time zone supplied by %Z is
not the same as the time zone getdate() expects, an invalid specification error is
returned. getdate() calculates the expected time zone from the TZ environment vari-
able.
Month and weekday names may consist of any combination of uppercase and lowercase letters. The user
can request that the input date or time specification be in a specific language by setting the
LC_TIME
category (see setlocale (3C)).
For descriptors that allow leading zeros, leading zeros are optional. However, the number of digits used
for those descriptors must not exceed two, including leading zeros. Extra whitespace in either the tem-
plate file or in string is ignored.
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1