1a.TH  curl_getdate  3 "12 Aug 2005" "libcurl" "libcurl" curl_get‐
2date ‐ Convert a date string to number of seconds
3#include <curl/curl.h>
4
5time_t curl_getdate(char *datestring, time_t *now);

curl_getdate(3) returns the number of seconds since the Epoch,

7January  1st 1970 00:00:00 in the UTC time zone, for the date and
8time that the datestring parameter specifies. The  now  parameter
9is not used, pass a NULL there.
10
11This  function  works with valid dates and does not always detect
12and reject wrong dates, such as February 30.
13
14A "date" is a string containing several items separated by white‐
15space.  The  order  of the items is immaterial. A date string may
16contain many flavors of items: Can  be  specified  several  ways.
17Month  names can only be three‐letter English abbreviations, num‐
18bers can be zero‐prefixed and the year may use  2  or  4  digits.
19Examples: 06 Nov 1994, 06‐Nov‐94 and Nov‐94 6.  This string spec‐
20ifies the time on a given day. You must specify it with 6  digits
21with  two  colons:  HH:MM:SS.  To  not include the time in a date
22string,  will  make  the  function  assume   00:00:00.   Example:
2318:19:21.   Specifies  international  time  zone. There are a few
24acronyms supported, but in general you  should  instead  use  the
25specific  relative  time  compared  to UTC. Supported formats in‐
26clude: ‐1200, MST, +0100.  Specifies a day of the week.  Days  of
27the  week  may  be spelled out in full (using English): ‘Sunday’,
28‘Monday’, etc or they may be abbreviated  to  their  first  three
29letters. This is usually not info that adds anything.  If a deci‐
30mal number of the form YYYYMMDD appears, then YYYY is read as the
31year,  MM as the month number and DD as the day of the month, for
32the specified calendar date.
33 time_t t;
34 t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
35 t = curl_getdate("Sunday, 06‐Nov‐94 08:49:37 GMT", NULL);
36 t = curl_getdate("Sun Nov  6 08:49:37 1994", NULL);
37 t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
38 t = curl_getdate("06‐Nov‐94 08:49:37 GMT", NULL);
39 t = curl_getdate("Nov  6 08:49:37 1994", NULL);
40 t = curl_getdate("06 Nov 1994 08:49:37", NULL);
41 t = curl_getdate("06‐Nov‐94 08:49:37", NULL);
42 t = curl_getdate("1994 Nov 6 08:49:37", NULL);
43 t = curl_getdate("GMT 08:49:37 06‐Nov‐94 Sunday", NULL);
44 t = curl_getdate("94 6 Nov 08:49:37", NULL);
45 t = curl_getdate("1994 Nov 6", NULL);
46 t = curl_getdate("06‐Nov‐94", NULL);
47 t = curl_getdate("Sun Nov 6 94", NULL);
48 t = curl_getdate("1994.Nov.6", NULL);
49 t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
50 t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
51 t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
52 t = curl_getdate("Sun, 12 Sep 2004 15:05:58 ‐0700", NULL);
53 t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
54 t = curl_getdate("20040912 15:05:58 ‐0700", NULL);
55 t = curl_getdate("20040911 +0200", NULL);
56This parser handles date formats specified in RFC 822  (including
57the  update  in RFC 1123) using time zone name or time zone delta
58and RFC 850 (obsoleted by RFC 1036) and ANSI C’s  asctime()  for‐
59mat.
60
61These  formats  are the only ones RFC 7231 says HTTP applications
62may use.  Always This function returns ‐1 when it fails to  parse
63the  date  string.  Otherwise it returns the number of seconds as
64described.
65
66On systems with a signed 32 bit time_t: if  the  year  is  larger
67than 2037 or less than 1903, this function will return ‐1.
68
69On  systems with an unsigned 32 bit time_t: if the year is larger
70than 2106 or less than 1970, this function will return ‐1.
71
72On systems with 64 bit time_t: if the year  is  less  than  1583,
73this  function  will return ‐1. (The Gregorian calendar was first
74introduced 1582 so no "real" dates in this way of doing dates ex‐
75isted before then.)
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Impressum