Manual Pages for Linux CentOS command on man getdate_err
MyWebUniversity

Manual Pages for Linux CentOS command on man getdate_err

GETDATE(3) Linux Programmer's Manual GETDATE(3)

NAME

getdate, getdater - convert a date-plus-time string to broken-down time SYNOPSIS

#include struct tm *getdate(const char *string); extern int getdateerr;

#include int getdater(const char *string, struct tm *res); Feature Test Macro Requirements for glibc (see featuretestmacros(7)): getdate(): XOPENSOURCE >= 500 || XOPENSOURCE && XOPENSOURCEEXTENDED getdater(): GNUSOURCE DESCRIPTION The function getdate() converts a string representation of a date and

time, contained in the buffer pointed to by string, into a broken-down

time. The broken-down time is stored in a tm structure, and a pointer to this structure is returned as the function result. This tm struc‐ ture is allocated in static storage, and consequently it will be over‐ written by further calls to getdate(). In contrast to strptime(3), (which has a format argument), getdate() uses the formats found in the file whose full pathname 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 specified

in POSIX.1-2001:

%Z Timezone name. This is not implemented in glibc.

When %Z is given, the structure containing the broken-down time is ini‐ tialized with values corresponding to the current time in the given

timezone. Otherwise, the structure is initialized to the broken-down time corresponding to the current local time (as by a call to local‐ time(3)). 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. getdater() is a GNU extension that provides a reentrant version of getdate(). 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. RETURN VALUE When successful, getdate() returns a pointer to a struct tm. Other‐ wise, it returns NULL and sets the global variable getdateerr to one of the error numbers shown below. Changes to errno are unspecified. On success getdater() returns 0; on error it returns one of the error numbers shown below. ERRORS The following errors are returned via getdateerr (for getdate()) or as the function result (for getdater()): 1 The DATEMSK environment variable is not defined, or its value is an empty string. 2 The template file specified by DATEMSK cannot be opened for read‐ ing. 3 Failed to get file status information. 4 The template file is not a regular file. 5 An error was encountered while reading the template file. 6 Memory allocation failed (not enough memory available). 7 There is no line in the file that matches the input. 8 Invalid input specification. ENVIRONMENT DATEMSK File containing format patterns. TZ, LCTIME Variables used by strptime(3). ATTRIBUTES For an explanation of the terms used in this section, see attributes(7). ┌────────────┬───────────────┬───────────────────────────────────┐ │Interface │ Attribute │ Value │ ├────────────┼───────────────┼───────────────────────────────────┤

│getdate() │ Thread safety │ MT-Unsafe race:getdate env locale │ ├────────────┼───────────────┼───────────────────────────────────┤

│getdater() │ Thread safety │ MT-Safe env locale │ └────────────┴───────────────┴───────────────────────────────────┘ CONFORMING TO

POSIX.1-2001. NOTES

The POSIX.1-2001 specification for strptime(3) contains conversion

specifications using the %E or %O modifier, while such specifications are not given for getdate(). In glibc, getdate() is implemented using strptime(3), so that precisely the same conversions are supported by both. EXAMPLE

The program below calls getdate() for each of its command-line argu‐ ments, 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 # Full weekday name

$ echo '%T' >> $TFILE # ISO date (YYYY-MM-DD)

$ echo '%F' >> $TFILE # Time (HH:MM:SS)

$ date

$ export DATEMSK=$TFILE

$ ./a.out Tuesday '2009-12-28' '12:22:33' Sun Sep 7 06:03:36 CEST 2008 Call 1 ("Tuesday") succeeded: tmsec = 36 tmmin = 3 tmhour = 6 tmmday = 9 tmmon = 8 tmyear = 108 tmwday = 2 tmyday = 252 tmisdst = 1

Call 2 ("2009-12-28") succeeded: tmsec = 36 tmmin = 3 tmhour = 6 tmmday = 28 tmmon = 11 tmyear = 109 tmwday = 1 tmyday = 361 tmisdst = 0 Call 3 ("12:22:33") succeeded: tmsec = 33 tmmin = 22 tmhour = 12 tmmday = 7 tmmon = 8 tmyear = 108 tmwday = 0 tmyday = 250 tmisdst = 1 Program source

#define GNUSOURCE 500

#include

#include

#include int main(int argc, char *argv[]) { struct tm *tmp; int j; for (j = 1; j < argc; j++) { tmp = getdate(argv[j]); if (tmp == NULL) {

printf("Call %d failed; getdateerr = %d\n", j, getdateerr); continue; }

printf("Call %d (\"%s\") succeeded:\n", j, argv[j]);

printf(" tmsec = %d\n", tmp->tmsec);

printf(" tmmin = %d\n", tmp->tmmin);

printf(" tmhour = %d\n", tmp->tmhour);

printf(" tmmday = %d\n", tmp->tmmday);

printf(" tmmon = %d\n", tmp->tmmon);

printf(" tmyear = %d\n", tmp->tmyear);

printf(" tmwday = %d\n", tmp->tmwday);

printf(" tmyday = %d\n", tmp->tmyday);

printf(" tmisdst = %d\n", tmp->tmisdst); } exit(EXITSUCCESS); } SEE ALSO time(2), localtime(3), setlocale(3), strftime(3), strptime(3) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

2013-06-21 GETDATE(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™