]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getdate.3
ffix
[thirdparty/man-pages.git] / man3 / getdate.3
CommitLineData
fea681da
MK
1.\" Copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" Modified, 2001-12-26, aeb
24.TH GETDATE 3 2001-12-26 "" "Linux Programmer's Manual"
25.SH NAME
c13182ef 26getdate \- convert a string to struct tm
fea681da
MK
27.SH SYNOPSIS
28.B "#define _XOPEN_SOURCE"
29.br
30.B "#define _XOPEN_SOURCE_EXTENDED
31.br
32.B "#include <time.h>"
33.sp
b9f02710 34.BI "struct tm *getdate(const char *" string );
fea681da
MK
35.sp
36.BI "extern int getdate_err;"
cf0a9ace 37.sp
fea681da
MK
38.B "#define _GNU_SOURCE"
39.br
40.B "#include <time.h>"
41.sp
42.BI "int getdate_r (const char *" string ", struct tm *" res );
fea681da
MK
43.SH DESCRIPTION
44The function
63aa9df0 45.BR getdate ()
fea681da
MK
46converts a string pointed to by
47.I string
48into the tm structure that it returns.
49This tm structure may be found in static storage, so that
50it will be overwritten by the next call.
51
c13182ef 52In contrast to
fea681da
MK
53.BR strptime (3),
54(which has a
55.I format
56argument),
63aa9df0 57.BR getdate ()
fea681da 58uses the formats found in the file
2d7195b8 59of which the full pathname is given in the environment variable
fea681da
MK
60.BR DATEMSK .
61The first line in the file that matches the given input string
62is used for the conversion.
63
64The matching is done case insensitively.
65Superfluous whitespace, either in the pattern or in the string to
66be converted, is ignored.
67
68The conversion specifications that a pattern can contain are those given for
69.BR strptime (3).
70One more conversion specification is accepted:
71.TP
72.B %Z
73Timezone name.
74.LP
75When
76.B %Z
d9bfdb9c 77is given, the value to be returned is initialized to the broken-down time
fea681da 78corresponding to the current time in the given time zone.
d9bfdb9c 79Otherwise, it is initialized to the broken-down time corresponding to
fea681da
MK
80the current local time.
81.LP
82When only the weekday is given, the day is taken to be the first such day
83on or after today.
84.LP
85When only the month is given (and no year), the month is taken to
86be the first such month equal to or after the current month.
87If no day is given, it is the first day of the month.
88.LP
89When no hour, minute and second are given, the current
90hour, minute and second are taken.
91.LP
92If no date is given, but we know the hour, then that hour is taken
93to be the first such hour equal to or after the current hour.
94.SH "RETURN VALUE"
95When successful, this function returns a pointer to a
8478ee02 96.IR "struct tm" .
fea681da 97Otherwise, it returns NULL and sets the global variable
8478ee02 98.IR getdate_err .
fea681da
MK
99Changes to
100.I errno
c13182ef
MK
101are unspecified.
102The following values for
8478ee02 103.I getdate_err
fea681da
MK
104are defined:
105.TP 4n
106.B 1
2f0af33b
MK
107The
108.B DATEMSK
109environment variable is null or undefined.
fea681da
MK
110.TP
111.B 2
112The template file cannot be opened for reading.
113.TP
114.B 3
115Failed to get file status information.
116.TP
117.B 4
118The template file is not a regular file.
119.TP
120.B 5
121An error is encountered while reading the template file.
122.TP
123.B 6
124Memory allocation failed (not enough memory available).
125.TP
126.B 7
127There is no line in the file that matches the input.
128.TP
129.B 8
130Invalid input specification.
2b2581ee
MK
131.SH ENVIRONMENT
132.TP
133.B DATEMSK
134File containing format patterns.
135.TP
136.BR TZ ", " LC_TIME
137Variables used by
138.BR strptime (3).
139.SH "CONFORMING TO"
140POSIX.1-2001
fea681da 141.SH NOTES
c13182ef 142Since
63aa9df0 143.BR getdate ()
c13182ef 144is not reentrant because of the use of
8478ee02 145.I getdate_err
fea681da 146and the static buffer to return the result in, glibc provides a
c13182ef
MK
147thread-safe variant.
148The functionality is the same.
149The result is returned in the buffer pointed to by
fea681da 150.I res
f59a3f19 151and in case of an error the return value is non-zero with the same
c13182ef 152values as given above for
fea681da
MK
153.IR getdate_err .
154.LP
68e1685c 155The POSIX.1-2001 specification for
fb186734 156.BR strptime (3)
fea681da
MK
157contains conversion specifications using the
158.B %E
159or
160.B %O
161modifier, while such specifications are not given for
63aa9df0 162.BR getdate ().
fea681da 163The glibc implementation implements
63aa9df0 164.BR getdate ()
fea681da 165using
fb186734 166.BR strptime (3)
fea681da
MK
167so that automatically precisely the same conversions are supported by both.
168.LP
169The glibc implementation does not support the
170.B %Z
171conversion specification.
fea681da 172.SH "SEE ALSO"
be4d4fe4 173.BR time (2),
fea681da 174.BR localtime (3),
9fcfcba0 175.BR setlocale (3),
fea681da
MK
176.BR strftime (3),
177.BR strptime (3),
a8e7c990 178.BR feature_test_macros (7)