parse

Parses timestamp, which is expected to be a HTTP compliant date/time string, and converts it to the UNIX time value.

@see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3

bool
parse
(,
ref time_t t
)

Parameters

timestamp cstring

HTTP compliant date/time string

t time_t

resulting UNIX time value; changed only if the return value is true

Return Value

Type: bool

true if the conversion succeeded or false on parse error or invalid date/time value

Examples

Using http://www.epochconverter.com/ as reference.

static immutable time_t T = 352716457;

time_t t;

bool ok = parse("Fri, 06 Mar 1981 08:47:37 GMT", t);
test (ok);
test (t == T);

ok = parse("Friday, 06-Mar-81 08:47:37 GMT", t);
test (ok);
test (t == T);

ok = parse("Fri Mar  6 08:47:37 1981", t);
test (ok);
test (t == T);

Meta