RFC 2822
datetime.timestamp.rfc_2822Email header datetime format. Used in SMTP, HTTP headers, and RSS feeds. Includes abbreviated weekday and month names.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As TIMESTAMPTZ |
|---|---|
| Tue, 15 Jan 2024 10:30:00 +0000 | 2024-01-15 10:30:00+00 |
| Sun, 31 Dec 2023 23:59:59 +0000 | 2023-12-31 23:59:59+00 |
- %a
- abbreviated weekday
- %d
- day of month, two digits
- %b
- abbreviated month name
- %Y
- four-digit year
- %H
- hour, 24-hour clock
- %M
- minutes
- %S
- seconds
- %z
- UTC offset
Written by
- Python
email.utils.format_datetime()
Shape
^[A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d{2}:\d{2}:\d{2} .+$| Value | Length | Shape |
|---|---|---|
| Tue, 15 Jan 2024 10:30:00 +0000 | 31 | matches |
| Sun, 31 Dec 2023 23:59:59 +0000 | 31 | matches |
| tue, 15 jan 2024 10:30:00 +0000 | 31 | rejected: lower-cased |
Background
Origin
RFC 2822, Internet Message Format, was published in April 2001 as a Standards Track document.[1] RFC 2822 was edited by P. Resnick of QUALCOMM Incorporated.[1] RFC 2822 obsoletes RFC 822.[1] RFC 2822 was in turn obsoleted by RFC 5322, published in October 2008.[2]
RFC 822, the Standard for the Format of ARPA Internet Text Messages, is dated August 13, 1982.[3] RFC 822's preface says that by 1977 the Arpanet employed several informal standards for the text messages sent among its host computers.[3] RFC 822's date syntax used a two-digit year, with 20 Jun 82 as its example.[3] RFC 822 took two of its time zone forms from ANSI standard X3.51-1975.[3] RFC 2822 lists two-digit years and non-numeric time zones among the older forms that can no longer be generated.[1]
RFC 2822 says the form +0000 should be used to indicate a time zone at Universal Time.[1] RFC 2822 says -0000 also indicates Universal Time but means the date-time contains no information about the local time zone.[1] RFC 2822 says the date and time-of-day should express local time.[1] RFC 2822 requires the day of the week, if included, to be the day implied by the date.[1] RFC 2822 allows the time-of-day to run up to 23:59:60, to allow for a leap second.[1]
Use
RFC 2822 says obsolete syntactic forms must not be generated but must be accepted and parsed by a conformant receiver.[1] RFC 2822's obsolete syntax lists alphabetic zones such as UT, GMT, EST and PDT.[1] RFC 2822 says UT and GMT in the obsolete zone are both semantically identical to +0000.[1] RFC 2822 says a two-digit year between 00 and 49 is interpreted by adding 2000, and one between 50 and 99 by adding 1900.[1]
RFC 9110, HTTP Semantics, defines HTTP's preferred date format, IMF-fixdate, as a fixed length, zone and capitalisation subset of the RFC 5322 format.[4] RFC 9110 requires a recipient parsing an HTTP timestamp to accept all three HTTP-date formats.[4]
The RSS 2.0 specification says all date-times in RSS conform to the Date and Time Specification of RFC 822.[5] The RSS 2.0 specification makes one exception: the year may be expressed with two characters or four characters, four preferred.[5]
Python's email.utils.format_datetime writes the conventional -0000 for a naive datetime.[6] Python's email.utils.format_datetime writes the numeric offset for an aware datetime.[6] Python's email.utils.format_datetime can write GMT instead of a numeric offset for an aware datetime with offset zero, when usegmt is set.[6] Python's email.utils.parsedate_to_datetime returns a naive datetime when the input has a timezone of -0000.[6]
Before parsing a column of these, check whether every zone is numeric or whether some end in letters, and whether any years have only two digits. (Meridian's view) Treat -0000 as a time whose local zone is unknown rather than as a confirmed UTC reading, and keep that distinction if it matters downstream. (Meridian's view) A day name that disagrees with its date is worth raising with whoever produced the data, rather than silently trusting one part over the other. (Meridian's view)
Where you'll meet it
NASA's RSS feed at www.nasa.gov/feed/ writes each item's pubDate in this form with a numeric +0000 offset.[7]
Sources
- [1]Internet Message Formatstandard
- [2]Internet Message Formatstandard
- [3]STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGESstandard
- [4]HTTP Semanticsstandard
- [5]RSS 2.0 Specification (Current)documentation
- [6]email.utils: Miscellaneous utilitiesdocumentation
- [7]NASAdataset
Use it
$ finetype infer -i "Tue, 15 Jan 2024 10:30:00 +0000" --mode column
→ datetime.timestamp.rfc_2822
SELECT ft_infer('Tue, 15 Jan 2024 10:30:00 +0000');
-- → 'datetime.timestamp.rfc_2822'strptime({col}, '%a, %d %b %Y %H:%M:%S %z')
-- Format: %a, %d %b %Y %H:%M:%S %zSchema
https://meridian.online/schemas/datetime.timestamp.rfc_2822 · Frictionless type datetime · %a, %d %b %Y %H:%M:%S %z
finetype taxonomy datetime.timestamp.rfc_2822 -o json-schema