Skip to content

Printing and parsing of header timestamps #270

Open
@yawaramin

Description

@yawaramin

Headers need to use a well-defined timestamp format: https://www.rfc-editor.org/rfc/rfc2616#section-3.3

E.g. Wed, 21 Oct 2015 07:28:00 GMT

Dream can already print to this format:

let expires =

It would be good to provide support in Dream itself for printing and parsing this format as other headers also need to use it, e.g.

Maybe an API like:

val timestamp : ?epoch_s:float -> unit -> string
(** [timestamp ?epoch_s] () is a string representation of [epoch_s] (epoch
    seconds) if provided, else the current timestamp. *)

val of_timestamp : string -> (float, string) result
(** [of_timestamp str] is the time in epoch seconds parsed from the [str]
    representation, or an error message if parse failed. *)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions