]>
Commit | Line | Data |
---|---|---|
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 | 26 | getdate \- 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 |
44 | The function | |
63aa9df0 | 45 | .BR getdate () |
fea681da MK |
46 | converts a string pointed to by |
47 | .I string | |
48 | into the tm structure that it returns. | |
49 | This tm structure may be found in static storage, so that | |
50 | it will be overwritten by the next call. | |
51 | ||
c13182ef | 52 | In contrast to |
fea681da MK |
53 | .BR strptime (3), |
54 | (which has a | |
55 | .I format | |
56 | argument), | |
63aa9df0 | 57 | .BR getdate () |
fea681da | 58 | uses the formats found in the file |
2d7195b8 | 59 | of which the full pathname is given in the environment variable |
fea681da MK |
60 | .BR DATEMSK . |
61 | The first line in the file that matches the given input string | |
62 | is used for the conversion. | |
63 | ||
64 | The matching is done case insensitively. | |
65 | Superfluous whitespace, either in the pattern or in the string to | |
66 | be converted, is ignored. | |
67 | ||
68 | The conversion specifications that a pattern can contain are those given for | |
69 | .BR strptime (3). | |
70 | One more conversion specification is accepted: | |
71 | .TP | |
72 | .B %Z | |
73 | Timezone name. | |
74 | .LP | |
75 | When | |
76 | .B %Z | |
d9bfdb9c | 77 | is given, the value to be returned is initialized to the broken-down time |
fea681da | 78 | corresponding to the current time in the given time zone. |
d9bfdb9c | 79 | Otherwise, it is initialized to the broken-down time corresponding to |
fea681da MK |
80 | the current local time. |
81 | .LP | |
82 | When only the weekday is given, the day is taken to be the first such day | |
83 | on or after today. | |
84 | .LP | |
85 | When only the month is given (and no year), the month is taken to | |
86 | be the first such month equal to or after the current month. | |
87 | If no day is given, it is the first day of the month. | |
88 | .LP | |
89 | When no hour, minute and second are given, the current | |
90 | hour, minute and second are taken. | |
91 | .LP | |
92 | If no date is given, but we know the hour, then that hour is taken | |
93 | to be the first such hour equal to or after the current hour. | |
94 | .SH "RETURN VALUE" | |
95 | When successful, this function returns a pointer to a | |
8478ee02 | 96 | .IR "struct tm" . |
fea681da | 97 | Otherwise, it returns NULL and sets the global variable |
8478ee02 | 98 | .IR getdate_err . |
fea681da MK |
99 | Changes to |
100 | .I errno | |
c13182ef MK |
101 | are unspecified. |
102 | The following values for | |
8478ee02 | 103 | .I getdate_err |
fea681da MK |
104 | are defined: |
105 | .TP 4n | |
106 | .B 1 | |
2f0af33b MK |
107 | The |
108 | .B DATEMSK | |
109 | environment variable is null or undefined. | |
fea681da MK |
110 | .TP |
111 | .B 2 | |
112 | The template file cannot be opened for reading. | |
113 | .TP | |
114 | .B 3 | |
115 | Failed to get file status information. | |
116 | .TP | |
117 | .B 4 | |
118 | The template file is not a regular file. | |
119 | .TP | |
120 | .B 5 | |
121 | An error is encountered while reading the template file. | |
122 | .TP | |
123 | .B 6 | |
124 | Memory allocation failed (not enough memory available). | |
125 | .TP | |
126 | .B 7 | |
127 | There is no line in the file that matches the input. | |
128 | .TP | |
129 | .B 8 | |
130 | Invalid input specification. | |
2b2581ee MK |
131 | .SH ENVIRONMENT |
132 | .TP | |
133 | .B DATEMSK | |
134 | File containing format patterns. | |
135 | .TP | |
136 | .BR TZ ", " LC_TIME | |
137 | Variables used by | |
138 | .BR strptime (3). | |
139 | .SH "CONFORMING TO" | |
140 | POSIX.1-2001 | |
fea681da | 141 | .SH NOTES |
c13182ef | 142 | Since |
63aa9df0 | 143 | .BR getdate () |
c13182ef | 144 | is not reentrant because of the use of |
8478ee02 | 145 | .I getdate_err |
fea681da | 146 | and the static buffer to return the result in, glibc provides a |
c13182ef MK |
147 | thread-safe variant. |
148 | The functionality is the same. | |
149 | The result is returned in the buffer pointed to by | |
fea681da | 150 | .I res |
f59a3f19 | 151 | and in case of an error the return value is non-zero with the same |
c13182ef | 152 | values as given above for |
fea681da MK |
153 | .IR getdate_err . |
154 | .LP | |
68e1685c | 155 | The POSIX.1-2001 specification for |
fb186734 | 156 | .BR strptime (3) |
fea681da MK |
157 | contains conversion specifications using the |
158 | .B %E | |
159 | or | |
160 | .B %O | |
161 | modifier, while such specifications are not given for | |
63aa9df0 | 162 | .BR getdate (). |
fea681da | 163 | The glibc implementation implements |
63aa9df0 | 164 | .BR getdate () |
fea681da | 165 | using |
fb186734 | 166 | .BR strptime (3) |
fea681da MK |
167 | so that automatically precisely the same conversions are supported by both. |
168 | .LP | |
169 | The glibc implementation does not support the | |
170 | .B %Z | |
171 | conversion 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) |