fullcalendar / temporal-polyfill

A lightweight polyfill for Temporal, successor to the JavaScript Date object
MIT License
369 stars 14 forks source link

Bug with DateTimeFormat #9

Closed mrbrianevans closed 10 months ago

mrbrianevans commented 2 years ago

Hi there, I've been using your polyfill and I think I've noticed an unexpected error that occurs when formatting a date time. This error does not occur in the spec playground.

To reproduce

Run

Temporal.Instant.from(new Date().toISOString()).toLocaleString('en-GB', {dateStyle:'long'})

Expected behaviour

In the official spec playground, the output is:

"11 May 2022" 

Actual behaviour

When run with this polyfill, it produces this error:

Uncaught TypeError: can't set option year when dateStyle is used
    buildFormat fromAndWith.ts:329
    toLocaleString intlFactory.ts:208
    <anonymous> pen.js:2
fromAndWith.ts:329
hossameldeen commented 1 year ago

I'm facing a similar issue:

This code:

console.log(
  Temporal.PlainTime.from("15:30:37").toLocaleString([], {
    timeStyle: "short"
  })
);

results in this error:

TypeError: Can't set option hour when timeStyle is used

Codesandbox link: https://codesandbox.io/s/temporal-and-lodash-update-forked-dohu6n?file=/src/index.js

Perhaps this issue is relevant?

Also, it seems to work fine with Javascript Intl. API. And tried PlainDateTime, but it's the same issue.

image

arshaw commented 1 year ago

Confirmed, I'll fix this

arshaw commented 10 months ago

This has been fixed in v0.2.0

Please lmk once you confirm. Thanks!