Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatDate with week and locale options returns full ISO date instead of "Week #" #7664

Open
1 task done
PooSham opened this issue Apr 26, 2024 · 0 comments
Open
1 task done

Comments

@PooSham
Copy link

PooSham commented Apr 26, 2024

Reduced Test Case

https://codepen.io/poosham/pen/RwOdeOM

Do you understand that if a reduced test case is not provided, we will intentionally delay triaging of your ticket?

  • I understand

Which connector are you using (React/Angular/etc)?

No connector (vanilla JS)

Bug Description

If I call formatDate with options week and locale, I expect to get the week number along with the word translated (may vary depending on the value of the week option). However, what I get is the current date formatted with the given locale. For example:

formatDate(new Date(), { week: 'long', locale: 'sv' })

This doesn't result in "Vecka 17" as I would have guessed, but instead I get "2024-04-27".

I've tracked down where things go wrong in the fc code. buildFormattingFunc from formatting-native.ts seems to be the issue here, notably this if-expression:

if (standardDatePropCnt === 0 && extendedSettings.week)

Here, standardDatePropCnt is 1 instead of 0, so we never hit what's inside this if-statement, which is our week formatter.

@acerix acerix changed the title formatDate with options week and locale returns current date (with year, month and dom) formatDate with week and locale options returns full ISO date instead of "Week #" May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants