Time::Format::HTTP_DATE - Crystal 1.15.1

# module Time::Format::HTTP_DATE

##
Overview

Parse a time string using the formats specified by RFC 2616 and (non-RFC-compliant) IIS date format.

Supported formats:

- RFC 1123
- RFC 850
- IIS date format
- asctime

    Time::Format::HTTP_DATE.parse("Sun, 14 Feb 2016 21:00:00 GMT")  # => 2016-02-14 21:00:00 UTC
    Time::Format::HTTP_DATE.parse("Sunday, 14-Feb-16 21:00:00 GMT") # => 2016-02-14 21:00:00 UTC
    Time::Format::HTTP_DATE.parse("Sun, 14-Feb-2016 21:00:00 GMT")  # => 2016-02-14 21:00:00 UTC
    Time::Format::HTTP_DATE.parse("Sun Feb 14 21:00:00 2016")       # => 2016-02-14 21:00:00 UTC

    Time::Format::HTTP_DATE.format(Time.utc(2016, 2, 15)) # => "Mon, 15 Feb 2016 00:00:00 GMT"

##
Defined in:

time/format/custom/http_date.cr

##
Class Method Summary

- .format(time : Time, io : IO)

  Formats a `Time` into the given io.

- .format(time : Time) : String

  Formats a `Time` into a `String`.

- .parse(string, location = Time::Location::UTC) : Time

  Parses a string into a `Time`.

##
Class Method Detail

def self.format(time : Time, io : IO) #

Formats a `Time` into the given io.

time is always converted to UTC.

def self.format(time : Time) : String #

Formats a `Time` into a `String`.

time is always converted to UTC.

def self.parse(string, location = Time::Location::UTC) : Time #

Parses a string into a `Time`.