Skip to content

httpDate

const httpDate: RegExp = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;

RegExp matching RFC 9110 §5.6.7 IMF-fixdate — the only form GMT’s formatHttpDate emits and the preferred HTTP-date form. Day, year, and time-of-day fields are all fixed-width per the grammar (unlike RFC 5322’s leniently-sized day); the trailing “GMT” literal is mandatory, never a numeric offset.

import { httpDate } from "@northguild/gmt";
httpDate.test("Wed, 09 Jun 2021 10:18:14 GMT") // true
httpDate.test("Jun 09 2021 10:18:14 GMT") // false (missing day-of-week)
httpDate.test("Wed, 9 Jun 2021 10:18:14 GMT") // false (single-digit day)
httpDate.test("Wed, 09 Jun 2021 10:18:14 +0000") // false (numeric offset)
httpDate.test("Wednesday, 09-Jun-21 10:18:14 GMT") // false (rfc850-date: parseHttpDate reads it)

regex/http-date.ts