fixdate

Package Version Hex Docs

Format and parse HTTP-date timestamps, the date format used in HTTP headers such as Date, Last-Modified, and Expires (RFC 9110 5.6.7).

gleam add fixdate
import fixdate
import gleam/time/calendar
import gleam/time/timestamp

pub fn main() -> Nil {
  let date = timestamp.from_unix_seconds(1_782_697_748)
  echo fixdate.to_string(date)
  // -> "Mon, 29 Jun 2026 01:49:08 GMT"

  // Parse an HTTP date back into a timestamp.
  let assert Ok(ts) = fixdate.parse("Mon, 29 Jun 2026 01:49:08 GMT")
  echo timestamp.to_rfc3339(ts, calendar.utc_offset)
  // -> "2026-06-29T01:49:08Z"

  Nil
}
Search Document