package http-date

  1. Overview
  2. Docs
HTTP Datetime encoder/decoder

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.2.tar.gz
md5=c05dd250cd2bcef94b9dedc0fda6202d
sha512=00cf1c4c6ca9dd95042707fb9b815bdd30532f3d0830a846bbbc46e6fc064a7565484241d8f8c2f517c9b1184492eeb2b8ff3efa6831cfe42e6c00fc69b3e162

doc/http-date/Http_date/index.html

Module Http_dateSource

HTTP timestamp decoders and encoders complaint to RFC 9110 (HTTP Semantics).

The current supported formats for decoding/encoding are as follows:

  • IMF(Internet Message Format) date, eg "Sun, 06 Nov 1994 08:49:37 GMT"
  • RFC 850 date, eg "Sunday, 06-Nov-94 08:49:37 GMT" Obsolete
  • asctime date, eg "Sun Nov 6 08:49:37 1994" Obsolete

HTTP timestamps are always in GMT/UTC

References

Sourcetype dayname = [
  1. | `Mon
  2. | `Tue
  3. | `Wed
  4. | `Thu
  5. | `Fri
  6. | `Sat
  7. | `Sun
]

dayname is the day name of the week, e.g. "Mon", "Monday", "Tue" .etc

Sourcetype date = int * int * int

(year, month, day)

Sourcetype time = int * int * int

(hour, minute, seconds)

Sourcetype datetime = dayname * date * time
Sourcetype t = [
  1. | `IMF of datetime
    (*

    Internet Message Format fixdate, eg "Sun, 06 Nov 1994 08:49:37 GMT"

    *)
  2. | `RFC850 of datetime
    (*

    RFC 850 date, eg "Sunday, 06-Nov-94 08:49:37 GMT" Obsolete

    *)
  3. | `ASCTIME of datetime
    (*

    asctime date, eg "Sun Nov 6 08:49:37 1994" Obsolete

    *)
]
Sourceval decode : string -> t

decode s decodes HTTP date value in s to (date, time).

  • raises Invalid_argument

    if s doesn't contain valid date in the format of IMF, RFC850 or ASCTIME.

Sourceval encode : t -> string

encode t is t in its string representation format.

Pretty Printing timestamps

Sourceval pp : Format.formatter -> t -> unit

pp fmt t pretty prints t into a HTTP date time string format.