deno_std
deno_std copied to clipboard
datetime/parse: cannot parse ISO week date
Describe the bug
parse() cannot parse ISO week date such as 2023-W50.
Steps to Reproduce
import { parse } from "https://deno.land/[email protected]/datetime/parse.ts"
parse("2023-W50", "yyyy-MM-dd")
Expected behavior
it returns 2023-12-11. however, it errors with
Uncaught Error: value not valid for token { month undefined } W20
at DateTimeFormatter.parseToParts (https://deno.land/[email protected]/datetime/_common.ts:562:15)
at parse (https://deno.land/[email protected]/datetime/parse.ts:28:27)
at <anonymous>:1:22
Environment
- OS: Ubuntu 23.10
- deno version: 1.38.5+e9ab9ba canary
- std version: 0.208.0
I think one would use ww tokens e.g. parse("2023-W50", "yyyy-ww"). But they are not supported atm.
Is the datetime module deprecated? because https://github.com/denoland/deno_std/pull/3615 suggests that it is.
We are planning to deprecate what overlaps with Temporal when it's shipped to V8
See https://github.com/denoland/deno/pull/21738
See https://github.com/denoland/deno/pull/21738
@iuioiua I don't think the Temporal proposal supports ISO week dating at this point. Ref:
- https://github.com/js-temporal/proposal-temporal-v2/issues/11
Ah, yes. I was looking at the spec and wondering about that. Thanks for the reference! I'll submit a PR shortly that more definitively defines what these std/datetime deprecations would look like. Anyway... That's enough hijacking this issue 😆
@iuioiua https://github.com/denoland/deno_std/pull/4198