An article dated 2026-08-12T21:23:00-04:00 belongs at an August 12 URL. Its publication instant is August 13 at 01:23 UTC. A publishing system needs both values: the calendar date the author supplied and the moment represented by the timestamp.
My publishing code previously replaced authored times and offsets with noon UTC when preparing machine-readable dates. Rebuilding the old code for a Codex-assisted repair succeeded, but a rendered-page check found 2026-08-12T12:00:00.000Z where it expected 2026-08-13T01:23:00.000Z.
For developers maintaining a Markdown or CMS publishing pipeline, the repair starts with deciding what each output promises. Converting every date to UTC would preserve the instant but could change an article's route or displayed day. Keeping only the date characters would preserve those surfaces while losing the instant.
Assign a meaning to each output
For the timestamp above, this is the contract:
| Output | Expected value | Meaning |
|---|---|---|
| Article route | /blog/2026/08/12/example/ | Authored calendar day |
| Visible article, card and search date | August 12, 2026 | Authored calendar day |
| HTML publication metadata | 2026-08-13T01:23:00.000Z | Publication instant |
JSON-LD datePublished | 2026-08-13T01:23:00.000Z | Publication instant |
RSS pubDate | Thu, 13 Aug 2026 01:23:00 GMT | Publication instant at the feed's precision |
The route and visible label should agree with the written date. Machine-readable consumers can compare instants across offsets. These are separate expectations even though the source stores them in one string.
Give Codex a task with those separate requirements:
Preserve the source's authored calendar day in routes and visible labels. Preserve an explicit timestamp's instant in publication metadata and JSON-LD. Trace the same source through the feed and search endpoint. Define how unzoned and date-only inputs behave, and test those policies in multiple host time zones.
The data-contract article addresses representation at an interface; here the same source intentionally produces different representations for different readers.
Declare what older input means
The archive also contains timestamps with no offset, including a space between the date and time. A parser cannot recover a missing time zone from those characters. The selected policy interprets these legacy values as UTC:
2025-12-19 21:33:00 -> 2025-12-19T21:33:00.000Z
2025-12-19T21:33 -> 2025-12-19T21:33:00.000Z
A date-only value gets a noon-UTC fallback. That is a declared convention for systems that require an instant. It does not establish when an old article was actually published. The original date still controls the route and label.
Leaving an unzoned date-time to JavaScript's default interpretation would make the result depend on the host. The ECMAScript specification interprets a conforming date-time without an offset as local time, while a date-only form uses UTC. The application therefore normalizes its supported forms before constructing a Date. ECMAScript 2025, Date.parse specifies that distinction.
The parser also checks that the calendar day survives a UTC round trip. An impossible date such as February 30 must fail, rather than become a different date through normalization. This site's contract rejects hour 24 and accepts at most three fractional digits; those choices belong to the application, not to every possible date standard.
Format the calendar day without the host's calendar
Extracting year, month and day avoids converting the publication instant into the wrong displayed date. It still leaves a trap if the formatter reconstructs those components as a host-local instant.
Under the Apia time-zone rules used in the test runtime, this expression produces December 31:
new Date(2011, 11, 30, 12).toLocaleDateString('en-US');
The requested December 30 does not exist in that local civil calendar. That need not prevent an archive from displaying an authored date of December 30. Construct the validated calendar components with an explicit UTC offset and format them explicitly in UTC:
const label = new Date(`${authoredDay}T12:00:00Z`)
.toLocaleDateString('en-US', {
year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC'
});
The Date here is a formatting vehicle for the calendar components. It is separate from the publication instant. Using the real publication instant in this expression would turn the August 12 example's label into August 13.
Match the feed's precision deliberately
HTML metadata and JSON-LD can retain the milliseconds in 2026-08-13T01:23:00.123Z. The actual RSS serializer tested in this repair emitted whole seconds. An assertion demanding millisecond equality from that feed would reject its intended representation.
The feed expectation therefore uses the start of the containing second:
const rssMilliseconds = Math.floor(instant.getTime() / 1000) * 1000;
The direction matters before the Unix epoch. 1969-12-31T23:59:59.999Z is minus one millisecond. Flooring it to a whole second yields 1969-12-31T23:59:59.000Z. Truncating toward zero would incorrectly move it to January 1, 1970.
Keep full precision for sorting and for outputs that preserve it. Only the feed comparison adopts the serializer's second precision. Applying the same rounding to every output would hide a different loss of information.
Run the reader example
The complete JavaScript example contains the parser, a miniature renderer, eight literal fixtures and executable tests. It adapts the reviewed date policy into a standalone module. Its HTML, RSS and search records are synthetic; it does not include the site's Astro build or RSS package.
With Node.js installed, run from the extracted folder:
node demo.mjs
node --test test.mjs
TZ=UTC node demo.mjs '2026-08-12T21:23:00-04:00'
TZ=America/New_York node demo.mjs '2026-08-12T21:23:00-04:00'
TZ=Pacific/Apia node demo.mjs '2011-12-30'
The default demonstration prints the August 12 route and label, the August 13 UTC instant, and the generated outputs. The tests inspect the serialized HTML metadata, visible <time> element, JSON-LD, feed date and search record. Their expected values are literals in the fixture file.
All eight test groups passed locally. They run the eight valid output chains in UTC, New York and Apia, reject twelve invalid date strings through the command-line program, and check unsupported input types and route slugs. They also retain failing controls for the noon-only conversion, the Apia local-date construction and the pre-epoch truncation error.
For your own system, replace the miniature renderer with the actual page and feed path. Keep the literal expected values. A shared parser can be correct while one consumer continues to call an older helper.
Check the repaired site through its actual outputs
Independent agent review found two problems in the first patch: a feed test that expected unsupported precision and a formatter that could change a skipped calendar day. The feed expectation and formatter were corrected, and the focused recheck passed.
The repaired local checkout passed these checks:
| Check | Recorded result |
|---|---|
| Complete repository test command | 19 tests passed, including date and feed tests |
| Full build and output inspection in UTC, New York and Apia | Each build checked 489 article chains, 489 search date labels and 2,601 card date labels |
| Independent focused parser, route and label review | 13 valid cases in five time zones; 19 malformed inputs rejected |
| Independent feed and search execution | Actual handlers exercised with 12 synthetic published records; feed used the installed RSS library |
These counts cover the local checkout and its corpus. The downloadable example tests the same date policy with synthetic outputs.
Choose a fixture whose offset crosses midnight before asking the agent to change the parser. Require the old build to fail that assertion, then retain the same expected value as the implementation changes.