header-date
header-date

how header-date fits in

Install

consolepip install header-date

Use

pythonfrom header_date import InvalidHTTPDate, format, now, parse, to_timestamp

parse("Sun, 06 Nov 1994 08:49:37 GMT")            # aware datetime in UTC
parse("Mon, 06 Nov 1994 08:49:37 GMT", strict=False)  # accept the wrong weekday
format(moment)                                     # 'Sun, 06 Nov 1994 08:49:37 GMT'
now()                                              # the current time, canonical form
to_timestamp("Thu, 01 Jan 1970 00:00:00 GMT")       # 0.0

What is accepted

form example
IMF-fixdate (RFC 9110)Sun, 06 Nov 1994 08:49:37 GMT
RFC 850 (obsolete)Sunday, 06-Nov-94 08:49:37 GMT
asctime (obsolete)Sun Nov 6 08:49:37 1994

25 → 2025), as RFC 9110 asks

Limits

Development

consolepython -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest

The suite covers every line of the package (pytest --cov --cov-branch), and the examples in the docstrings run as tests through --doctest-modules.

License

MIT.

Other libraries here

One problem each, standard library only, no runtime dependencies.