View Source XHTTP (XHTTP v0.1.0)
XHTTP is a library that defines the Response and
ResponseDocument protocols.
Summary
Functions
Parse a HTTP date into a DateTime struct.
Functions
@spec parse_http_date(date :: String.t() | nil) :: {:ok, DateTime.t()} | {:error, :invalid_date}
Parse a HTTP date into a DateTime struct.
Requires one of the optional dependencies: :timex, http_date
Returns {:ok, datetime} if input date was parsed successfully, {:error, :invalid_date} otherwise.
Examples
iex> XHTTP.parse_http_date("Mon, 29 Jan 2024 05:29:00 GMT")
{:ok, ~U[2024-01-29 05:29:00Z]}
iex> XHTTP.parse_http_date(nil)
{:error, :invalid_date}
iex> XHTTP.parse_http_date("Something else")
{:error, :invalid_date}