United States-English |
|
|
HP-UX Reference > Ggetdate(3C)HP-UX 11i Version 3: February 2007 |
|
NAMEgetdate() — convert user format date and time DESCRIPTIONThe 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:
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 template file or in string is ignored. The field descriptors %c, %x, and %X are not supported if they include unsupported field descriptors. The following example shows the possible contents of a template: %m %A %B %d, %Y, %H:%M:%S %A %B %m/%d/%y %I %p %d,%m,%Y %H:%M at %A the %dst of %B in %Y run job at %I %p, %B %dnd %A den %d. %B %Y %H.%M Uhr The following are examples of valid input specifications for the above template: getdate("10/1/87 4 PM"); getdate("Friday"); getdate("Friday September 18, 1987, 10:30:30"); getdate("24,9,1986 10:30"); getdate("at monday the 1st of december in 1986"); getdate("run job at 3 PM, december 2nd"); If the LC_TIME category is set to a German locale that includes freitag as a weekday name and oktober as a month name, the following would be valid: getdate("freitag den 10. oktober 1986 10.30 Uhr"); This example shows how local date and time specification can be defined in the template:
The following rules apply when converting the input specification into the internal format:
The following examples help to illustrate the above rules assuming that the current date is Mon Sep 22 12:19:47 EDT 1986, and the LC_TIME category is set to the default C locale.
ERRORSUpon failure, getdate() returns NULL and the symbol getdate_err is set to indicate the error. The following is a complete list of the getdate_err settings and their interpretation:
|
Printable version | ||
|