From a2aa7c155496d3dcd02113479dfedbd220c4144b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 16 Dec 2014 23:14:35 +0200 Subject: Add cow_http_hd:parse_date/1 From RFC7231. --- src/cow_http_hd.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/cow_http_hd.erl') diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index 89f9ac9..d2107cf 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -21,6 +21,7 @@ -export([parse_connection/1]). -export([parse_content_length/1]). -export([parse_content_type/1]). +-export([parse_date/1]). -export([parse_expect/1]). -export([parse_if_modified_since/1]). -export([parse_if_unmodified_since/1]). @@ -942,6 +943,20 @@ horse_parse_content_type() -> ). -endif. +%% @doc Parse the Date header. + +-spec parse_date(binary()) -> calendar:datetime(). +parse_date(Date) -> + http_date(Date). + +-ifdef(TEST). +parse_date_test_() -> + Tests = [ + {<<"Tue, 15 Nov 1994 08:12:31 GMT">>, {{1994, 11, 15}, {8, 12, 31}}} + ], + [{V, fun() -> R = parse_date(V) end} || {V, R} <- Tests]. +-endif. + %% @doc Parse the Expect header. -spec parse_expect(binary()) -> continue. -- cgit v1.2.3