1curl_getdate(3) libcurl Manual curl_getdate(3)
2
3
4
6 curl_getdate - Convert an date string to number of seconds since Janu‐
7 ary 1, 1970
8
10 #include <curl/curl.h>
11
12 time_t curl_getdate(char *datestring, time_t *now );
13
15 This function returns the number of seconds since January 1st 1970 in
16 the UTC time zone, for the date and time that the datestring parameter
17 specifies. The now parameter is not used, pass a NULL there.
18
19 NOTE: This function was rewritten for the 7.12.2 release and this docu‐
20 mentation covers the functionality of the new one. The new one is not
21 feature-complete with the old one, but most of the formats supported by
22 the new one was supported by the old too.
23
25 A "date" is a string containing several items separated by whitespace.
26 The order of the items is immaterial. A date string may contain many
27 flavors of items:
28
29 calendar date items
30 Can be specified several ways. Month names can only be three-
31 letter english abbrivations, numbers can be zero-prefixed and
32 the year may use 2 or 4 digits. Examples: 06 Nov 1994,
33 06-Nov-94 and Nov-94 6.
34
35 time of the day items
36 This string specifies the time on a given day. You must specify
37 it with 6 digits with two colons: HH:MM:SS. To not include the
38 time in a date string, will make the function assume 00:00:00.
39 Example: 18:19:21.
40
41 time zone items
42 Specifies international time zone. There are a few acronyms
43 supported, but in general you should instead use the specific
44 relative time compared to UTC. Supported formats include:
45 -1200, MST, +0100.
46
47 day of the week items
48 Specifies a day of the week. Days of the week may be spelled
49 out in full (using english): `Sunday', `Monday', etc or they
50 may be abbreviated to their first three letters. This is usu‐
51 ally not info that adds anything.
52
53 pure numbers
54 If a decimal number of the form YYYYMMDD appears, then YYYY is
55 read as the year, MM as the month number and DD as the day of
56 the month, for the specified calendar date.
57
59 Sun, 06 Nov 1994 08:49:37 GMT
60 Sunday, 06-Nov-94 08:49:37 GMT
61 Sun Nov 6 08:49:37 1994
62 06 Nov 1994 08:49:37 GMT
63 06-Nov-94 08:49:37 GMT
64 Nov 6 08:49:37 1994
65 06 Nov 1994 08:49:37
66 06-Nov-94 08:49:37
67 1994 Nov 6 08:49:37
68 GMT 08:49:37 06-Nov-94 Sunday
69 94 6 Nov 08:49:37
70 1994 Nov 6
71 06-Nov-94
72 Sun Nov 6 94
73 1994.Nov.6
74 Sun/Nov/6/94/GMT
75 Sun, 06 Nov 1994 08:49:37 CET
76 06 Nov 1994 08:49:37 EST
77 Sun, 12 Sep 2004 15:05:58 -0700
78 Sat, 11 Sep 2004 21:32:11 +0200
79 20040912 15:05:58 -0700
80 20040911 +0200
81
83 This parser was written to handle date formats specified in RFC 822
84 (including the update in RFC 1123) using time zone name or time zone
85 delta and RFC 850 (obsoleted by RFC 1036) and ANSI C's asctime() for‐
86 mat. These formats are the only ones RFC2616 says HTTP applications may
87 use.
88
90 This function returns -1 when it fails to parse the date string. Other‐
91 wise it returns the number of seconds as described.
92
93 If the year is larger than 2037 on systems with 32 bit time_t, this
94 function will return 0x7fffffff (since that is the largest possible
95 signed 32 bit number).
96
97 Having a 64 bit time_t is not a guarantee that dates beyond 03:14:07
98 UTC, January 19, 2038 will work fine. On systems with a 64 bit time_t
99 but with a crippled mktime(), curl_getdate will return -1 in this case.
100
102 The former version of this function was built with yacc and was not
103 only very large, it was also never quite understood and it wasn't pos‐
104 sible to build with non-GNU tools since only GNU Bison could make it
105 thread-safe!
106
107 The rewrite was done for 7.12.2. The new one is much smaller and use
108 simpler code.
109
110
111
112libcurl 7.0 12 Aug 2005 curl_getdate(3)