agentleFS
randommoniclerandommonicle/claude-skills/date-parse-utc-safe/SKILL.md

date-parse-utc-safe

Skill27 starsChanged 18 days agoApache-2.0View on GitHub

In a UTC server or serverless runtime, new Date("YYYY-MM-DD") is UTC midnight and renders as the previous day in western timezones. Parse date-only strings into explicit local components (new Date(y, m-1, d)) anywhere a date becomes a display string or a day-of-week. Triggers when parsing a date-only string server-side or computing a printed day from one. Does not fire on full ISO timestamps carrying explicit timezones.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never construct a Date from a bare YYYY-MM-DD string for display or day-of-week.

    line 15
  2. Distinctive:

    Test the boundary: a date rendered at local midnight in the runtime's timezone is where the off-by-one appears.

    line 23

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Date parsing, UTC-safe

One rule, endlessly rediscovered: new Date("YYYY-MM-DD") parses as UTC midnight. In a UTC runtime (serverless platforms run UTC) rendered through a western timezone, that is the previous day — bookings display on the wrong date, day-of-week computes wrong, and the bug never reproduces on a developer machine in the same timezone as the users.

The rule

Never construct a Date from a bare YYYY-MM-DD string for display or day-of-week. Decompose to explicit local components:

const [y, m, d] = dateStr.split('-').map(Number);
const date = new Date(y, m - 1, d); // local midnight, not UTC midnight

Test the boundary: a date rendered at local midnight in the runtime's timezone is where the off-by-one appears.

Why

The failure only exists in the deployed runtime's timezone, so it survives local testing by construction. Evidence: ICC LESSONS_LEARNED L-005.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.