deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

datetime/parse: cannot parse ISO week date

Open scarf005 opened this issue 1 year ago • 7 comments

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

scarf005 avatar Dec 11 '23 13:12 scarf005

I think one would use ww tokens e.g. parse("2023-W50", "yyyy-ww"). But they are not supported atm.

timreichen avatar Dec 11 '23 16:12 timreichen

Is the datetime module deprecated? because https://github.com/denoland/deno_std/pull/3615 suggests that it is.

syhol avatar Dec 24 '23 14:12 syhol

We are planning to deprecate what overlaps with Temporal when it's shipped to V8

kt3k avatar Dec 25 '23 07:12 kt3k

See https://github.com/denoland/deno/pull/21738

iuioiua avatar Jan 11 '24 22:01 iuioiua

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

jsejcksn avatar Jan 12 '24 01:01 jsejcksn

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 avatar Jan 12 '24 02:01 iuioiua

@iuioiua https://github.com/denoland/deno_std/pull/4198

timreichen avatar Jan 15 '24 00:01 timreichen