Skip to main content

Module date

Module date 

Source
Expand description

The proleptic Gregorian calendar and HTTP-date (RFC 9110 section 5.6.7).

§Examples

use parse_net as pn;

let d = pn::HttpDate::parse_imf_fixdate(b"Sun, 06 Nov 1994 08:49:37 GMT")?;
assert_eq!(d.unix(), 784_111_777);
assert_eq!(&d.format(), b"Sun, 06 Nov 1994 08:49:37 GMT");

let now = 1_792_540_800; // 2026-10-21
assert_eq!(pn::http_date_at(b"Sun Nov  6 08:49:37 1994", now)?, d);
assert_eq!(pn::http_date_at(b"Wednesday, 01-Jan-76 00:00:00 GMT", now)?.civil().year, 2076);
assert_eq!(pn::http_date_at(b"Saturday, 01-Jan-77 00:00:00 GMT", now)?.civil().year, 1977);

Structs§

Civil
A broken-down UTC time.
HttpDate
A point in time with one-second resolution, from year 1 to year 9999, UTC; the value of HTTP-date fields (Date, Last-Modified, Expires).
MailDate
A point in time with a zone offset, from an email Date or Received field (RFC 5322 section 3.3).

Enums§

DateFormat
The HTTP-date format a value was written in.

Functions§

civil_from_days
The civil date (year, month, day) for a day count since 1970-01-01, after Howard Hinnant’s civil_from_days.
days_from_civil
Days since 1970-01-01 for a civil date, after Howard Hinnant’s days_from_civil.
days_in_month
The number of days in month (1 to 12) of year; 0 for any other month.
http_datestd
Parses an HTTP-date in any format, resolving RFC 850 years against the system clock.
http_date_at
Parses an HTTP-date in any format, resolving RFC 850 years against now.
is_leap_year
Whether year is a leap year in the proleptic Gregorian calendar.
weekday_from_days
The ISO 8601 weekday (1 = Monday … 7 = Sunday) of a day count since 1970-01-01.