[Linux manuál]
Návod, kniha: Linux Programmer's Manual
#define _XOPEN_SOURCE_EXTENDED
#include <time.h>
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:
getdate(): převést řetězec na strukt tm
Originální popis anglicky: getdate() - convert a string to struct tmNávod, kniha: Linux Programmer's Manual
STRUČNĚ
#define _XOPEN_SOURCEPOPIS / INSTRUKCE
The function getdate() converts a string pointed to by string into the tm structure that it returns. This tm structure may be found in static storage, so that it will be overwritten by the next call.- %Z
- Timezone name.
NÁVRATOVÁ HODNOTA
When successful, this function returns a pointer to a struct tm. Otherwise, it returns NULL and sets the global variable getdate_err. Changes to errno are unspecified. The following values for getdate_err are defined:- 1
- The DATEMSK environment variable is null or undefined.
- 2
- The template file cannot be opened for reading.
- 3
- Failed to get file status information.
- 4
- The template file is not a regular file.
- 5
- An error is 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.
NOTES
Since getdate() is not reentrant because of the use of getdate_err and the static buffer to return the result in, glibc provides a thread-safe variant. The functionality is the same. The result is returned in the buffer pointed to by res and in case of an error the return value is nonzero with the same values as given above for getdate_err. 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.ENVIRONMENT
- DATEMSK
- File containing format patterns.
- TZ, LC_TIME
- Variables used by strptime().
ODPOVÍDAJÍCÍ
ISO 9899, POSIX 1003.1-2001SOUVISEJÍCÍ
localtime(3), strftime(3), strptime(3), time(3)| 2001-12-26 |