Artifactspublic-v0

curl

master
ply4 git calls47 ms289 KiB3 cachedprotocol v2
137 lines4.4 KiBRaw

NAME

curl_getdate - convert date string to number of seconds

SYNOPSIS

c
#include <curl/curl.h>

time_t curl_getdate(const char *datestring, const time_t *now);

DESCRIPTION

curl_getdate(3) returns the number of seconds since the Epoch, January 1st 1970 00:00:00 in the UTC time zone, for the date and time that the datestring parameter specifies. The now parameter is not used, pass a NULL there.

This function works with valid dates and does not always detect and reject wrong dates, such as February 30.

PARSING DATES AND TIMES

A "date" is a string containing several items separated by whitespace. The order of the items is immaterial. A date string may contain many flavors of items:

calendar date items

Can be specified several ways. Month names can only be three-letter English abbreviations, numbers can be zero-prefixed and the year may use 2 or 4 digits. Examples: 06 Nov 1994, 06-Nov-94 and Nov-94 6.

If the year appears to be below 100 (two-digit), any year after 70 is assumed to be 1900 + the given year. All others are 2000 + the given year.

time of the day items

This string specifies the time on a given day. You must specify it with 6 digits with two colons: HH:MM:SS. If there is no time given in a provided date string, 00:00:00 is assumed. Example: 18:19:21.

time zone items

Specifies international time zone. There are a few acronyms supported, but in general you should instead use the specific relative time compared to UTC. Supported formats include: -1200, MST, +0100.

day of the week items

Specifies a day of the week. Days of the week may be spelled out in full (using English): 'Sunday', 'Monday', etc or they may be abbreviated to their first three letters. Either way the check is case insensitive. The name of the day does not actually add any necessary information and does not have to be the correct week day of the date, it is only verified to be a correct weekday name.

pure numbers

If a decimal number of the form YYYYMMDD appears, then YYYY is read as the year, MM as the month number and DD as the day of the month, for the specified calendar date.

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  time_t t;
  t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
  t = curl_getdate("Sunday, 06-Nov-94 08:49:37 GMT", NULL);
  t = curl_getdate("Sun Nov  6 08:49:37 1994", NULL);
  t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
  t = curl_getdate("06-Nov-94 08:49:37 GMT", NULL);
  t = curl_getdate("Nov  6 08:49:37 1994", NULL);
  t = curl_getdate("06 Nov 1994 08:49:37", NULL);
  t = curl_getdate("06-Nov-94 08:49:37", NULL);
  t = curl_getdate("1994 Nov 6 08:49:37", NULL);
  t = curl_getdate("GMT 08:49:37 06-Nov-94 Sunday", NULL);
  t = curl_getdate("94 6 Nov 08:49:37", NULL);
  t = curl_getdate("1994 Nov 6", NULL);
  t = curl_getdate("06-Nov-94", NULL);
  t = curl_getdate("Sun Nov 6 94", NULL);
  t = curl_getdate("1994.Nov.6", NULL);
  t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
  t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
  t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
  t = curl_getdate("Sun, 12 Sep 2004 15:05:58 -0700", NULL);
  t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
  t = curl_getdate("20040912 15:05:58 -0700", NULL);
  t = curl_getdate("20040911 +0200", NULL);
}

STANDARDS

This parser handles date formats specified in RFC 822 (including the update in RFC 1123) using time zone name or time zone delta and RFC 850 (obsoleted by RFC 1036) and ANSI C's asctime() format.

These formats are the only ones RFC 7231 says HTTP applications may use.

%AVAILABILITY%

RETURN VALUE

This function returns -1 when it fails to parse the date string. Otherwise it returns the number of seconds as described.

On systems with a signed 32-bit time_t: if the year is larger than 2037 or less than 1903, this function returns -1.

On systems with an unsigned 32-bit time_t: if the year is larger than 2106 or less than 1970, this function returns -1.

On systems with 64-bit time_t: if the year is less than 1583, this function returns -1. (The Gregorian calendar was first introduced 1582 so no "real" dates in this way of doing dates existed before then.)

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_getdate
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_TIMECONDITION (3)
9 - CURLOPT_TIMEVALUE (3)
10 - curl_easy_escape (3)
11 - curl_easy_unescape (3)
12Protocol:
13 - All
14Added-in: 7.1
15---
17# NAME
19curl_getdate - convert date string to number of seconds
21# SYNOPSIS
23~~~c
24#include <curl/curl.h>
26time_t curl_getdate(const char *datestring, const time_t *now);
27~~~
29# DESCRIPTION
31curl_getdate(3) returns the number of seconds since the Epoch, January
321st 1970 00:00:00 in the UTC time zone, for the date and time that the
33*datestring* parameter specifies. The *now* parameter is not used,
34pass a NULL there.
36This function works with valid dates and does not always detect and reject
37wrong dates, such as February 30.
39# PARSING DATES AND TIMES
41A "date" is a string containing several items separated by whitespace. The
42order of the items is immaterial. A date string may contain many flavors of
43items:
45## calendar date items
47Can be specified several ways. Month names can only be three-letter English
48abbreviations, numbers can be zero-prefixed and the year may use 2 or 4
49digits. Examples: 06 Nov 1994, 06-Nov-94 and Nov-94 6.
51If the year appears to be below 100 (two-digit), any year after 70 is assumed
52to be 1900 + the given year. All others are 2000 + the given year.
54## time of the day items
56This string specifies the time on a given day. You must specify it with 6
57digits with two colons: HH:MM:SS. If there is no time given in a provided date
58string, 00:00:00 is assumed. Example: 18:19:21.
60## time zone items
62Specifies international time zone. There are a few acronyms supported, but in
63general you should instead use the specific relative time compared to
64UTC. Supported formats include: -1200, MST, +0100.
66## day of the week items
68Specifies a day of the week. Days of the week may be spelled out in full
69(using English): 'Sunday', 'Monday', etc or they may be abbreviated to their
70first three letters. Either way the check is case insensitive. The name of the
71day does not actually add any necessary information and does not have to be
72the correct week day of the date, it is only verified to be a correct weekday
73name.
75## pure numbers
77If a decimal number of the form YYYYMMDD appears, then YYYY is read as the
78year, MM as the month number and DD as the day of the month, for the specified
79calendar date.
81# %PROTOCOLS%
83# EXAMPLE
85~~~c
86int main(void)
88 time_t t;
89 t = curl_getdate("Sun, 06 Nov 1994 08:49:37 GMT", NULL);
90 t = curl_getdate("Sunday, 06-Nov-94 08:49:37 GMT", NULL);
91 t = curl_getdate("Sun Nov 6 08:49:37 1994", NULL);
92 t = curl_getdate("06 Nov 1994 08:49:37 GMT", NULL);
93 t = curl_getdate("06-Nov-94 08:49:37 GMT", NULL);
94 t = curl_getdate("Nov 6 08:49:37 1994", NULL);
95 t = curl_getdate("06 Nov 1994 08:49:37", NULL);
96 t = curl_getdate("06-Nov-94 08:49:37", NULL);
97 t = curl_getdate("1994 Nov 6 08:49:37", NULL);
98 t = curl_getdate("GMT 08:49:37 06-Nov-94 Sunday", NULL);
99 t = curl_getdate("94 6 Nov 08:49:37", NULL);
100 t = curl_getdate("1994 Nov 6", NULL);
101 t = curl_getdate("06-Nov-94", NULL);
102 t = curl_getdate("Sun Nov 6 94", NULL);
103 t = curl_getdate("1994.Nov.6", NULL);
104 t = curl_getdate("Sun/Nov/6/94/GMT", NULL);
105 t = curl_getdate("Sun, 06 Nov 1994 08:49:37 CET", NULL);
106 t = curl_getdate("06 Nov 1994 08:49:37 EST", NULL);
107 t = curl_getdate("Sun, 12 Sep 2004 15:05:58 -0700", NULL);
108 t = curl_getdate("Sat, 11 Sep 2004 21:32:11 +0200", NULL);
109 t = curl_getdate("20040912 15:05:58 -0700", NULL);
110 t = curl_getdate("20040911 +0200", NULL);
112~~~
114# STANDARDS
116This parser handles date formats specified in RFC 822 (including the update in
117RFC 1123) using time zone name or time zone delta and RFC 850 (obsoleted by
118RFC 1036) and ANSI C's *asctime()* format.
120These formats are the only ones RFC 7231 says HTTP applications may use.
122# %AVAILABILITY%
124# RETURN VALUE
126This function returns -1 when it fails to parse the date string. Otherwise it
127returns the number of seconds as described.
129On systems with a signed 32-bit time_t: if the year is larger than 2037 or
130less than 1903, this function returns -1.
132On systems with an unsigned 32-bit time_t: if the year is larger than 2106 or
133less than 1970, this function returns -1.
135On systems with 64-bit time_t: if the year is less than 1583, this function
136returns -1. (The Gregorian calendar was first introduced 1582 so no "real"
137dates in this way of doing dates existed before then.)
Diagnostics4 git calls · 47 ms
CallStatusSizeTime047 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=4
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit24 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=24
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.9 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=19
git.response.bytes=1982
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=427fc9ed32806a8101133cfa7c80c6ce581e9906
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1982
git.pkt.payload.max=1961
git.sideband.band1.bytes=1960
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e310751a41bdc9
Request
a81901d6…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format