fix: rate times parse leniently via new Date (local time, 2026-02-30, T24:00)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- rust, typescript
- Domain
- data
Research direction
Start in src/rate.ts at toIsoString, which handles the date-only regex branch and falls back to new Date(text). Run the repro strings from the issue under TZ=UTC and TZ=America/New_York to confirm the current behaviour. Done means the accepted formats are restricted as proposed, bad input throws RangeError, and tests cover the repros, with the CHANGELOG and upgrade guide updated for 0.5. The proposal is a breaking change, the Rust port is included, and the thread has no decision yet, so check with maintainers first.
Written by the indexing model from the issue text.
Description
toIsoString in src/rate.ts keeps any string matching ^\d{4}-\d\d-\d\d$ as a date unchecked, and passes everything else to new Date(text). So the times a Rate, a RateTable and a lookup take (asOf, availableAt, validUntil, a query's asOf, isExpired(now), isAvailable(at)) accept whatever the JavaScript engine's date parser accepts. Some of those strings mean different instants on different machines, and some aren't dates at all.
Repros
These were run against src/rate.ts on main with node 24, first with TZ=UTC and then with TZ=America/New_York:
import { exchangeRate, toIsoString } from './src/rate.js';
toIsoString('2026-11-06T15:00:00'); // TZ=UTC: '2026-11-06T15:00:00.000Z'
// TZ=America/New_York: '2026-11-06T20:00:00.000Z'
toIsoString('2026-02-30'); // '2026-02-30' (kept as a date, unchecked)
toIsoString('2026-11-06T24:00:00Z'); // '2026-11-07T00:00:00.000Z'
toIsoString('2026-11-06t15:00:00z'); // '2026-11-06T15:00:00.000Z' (lowercase t and z)
toIsoString('+002026-11-06T15:00:00Z'); // '2026-11-06T15:00:00.000Z' (expanded year)
toIsoString('2026-11-06T15:00:00.9999Z'); // '2026-11-06T15:00:00.999Z' (digits past ms truncated)
toIsoString('2026-11-06 15:00:00Z'); // '2026-11-06T15:00:00.000Z' (space for T)
toIsoString('Nov 6 2026 15:00 GMT'); // '2026-11-06T15:00:00.000Z' (not ISO 8601)
toIsoString('2026-11'); // '2026-11-01T00:00:00.000Z' (a month, read as an instant)
exchangeRate('EUR', 'USD', '1.1', { validUntil: '2026-02-30' }).isExpired('2026-03-01'); // true
- Offset-less date-times are read in the machine's local time zone. The same rate data gives different
asOf,availableAtandvalidUntilinstants, and so different lookups and expiries, depending onTZ. - Impossible dates (
2026-02-30) are stored as given and compared as strings. T24:00, lowercaset/z, a space forT, expanded years, non-ISO forms and partial dates (2026-11) are accepted by V8's parser, and other engines may differ.- Fractions past milliseconds are truncated silently.
Proposal
Accept only YYYY-MM-DD (a real calendar day), or YYYY-MM-DDTHH:MM[:SS[.sss]] followed by Z or ±HH:MM. Throw RangeError for anything else; a Date object stays accepted as it is. The Rust port in rust/ will parse this strictly from the start, and document it as a deliberate divergence until ducat does the same.
This is a behaviour change: input that ducat 0.4 accepts would throw. It belongs in 0.5, with a CHANGELOG entry under Changed and a note in the upgrade guide.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 35m
- Merged PRs (30d)
- 242
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from public/ducat
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
area: core
Difficulty 4/5 3-5 days Newbie friendliness 43/100
Maintainers usually reply within 1 day
-
area: tests
Difficulty 3/5 1-2 days Newbie friendliness 56/100
Maintainers usually reply within 1 day
-
area: core
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
area: core
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
software-mansion/argent#1946 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
podman-desktop/podman-desktop#20216 ·
Maintainers usually reply within 1 day
-
[Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
WordPress/ai#1386 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
omdsh-dev/DSH-better-sidebar#1205 ·
Maintainers usually reply within 3 days