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 |
- zones
GMT,UTCand numeric+0000are accepted; anything else is rejected - month and weekday names are matched case-insensitively, and full weekday names work
- a two-digit year maps to the most recent past year with those digits (
94→ 1994,
25 → 2025), as RFC 9110 asks
- impossible dates (
31 Feb,25:00:00) are rejected, not rolled over formatalways writes the canonical IMF-fixdate, converting other zones to UTC
Limits
- Only seconds resolution: HTTP dates have no fractional seconds.
- Leap seconds (
:60) are rejected. formatdoes not support years before 1000 or after 9999.
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.
- argrepair — turn a bad tool call into a message the model can act on
- backoff-headers — turn a rate-limit header into the exact time to wait
- columncheck — find the CSV defect before the pipeline does
- dir-digest — one hash for a directory tree, identical on every OS
- docanchor — catch every broken heading anchor in your docs
- envfile-diff — diff two .env files without printing the secrets
- fsync-replace — replace a file so a crash cannot leave it half-written
- junit-merge — merge JUnit XML from every job into one honest report
- npm-semver — npm semver ranges, parsed the way npm parses them
- outputcap — keep a huge tool result out of the context window
- parse-size — byte sizes in and out, MB and MiB never confused
- path-containment — keep untrusted paths inside their directory
- redactscope — stop secrets in tool results before they reach the model
- runbudget — a per-run cost cap that warns before it stops
- testflakes — rank your flaky tests from the history you already have
- tool-loop-guard — catch an agent repeating itself while it is still cheap
- toolcall-ledger — a hash-chained record of every tool call
- toolcircuit — stop retrying a tool that is down
- toolquota — client-side rate limits your agent loop can wait on
- wheeldeps — read a wheel's dependencies offline, markers included
- zip-deterministic — byte-identical archives, build after build