svelte-datepicker icon indicating copy to clipboard operation
svelte-datepicker copied to clipboard

Use locale order when listing weekdays

Open awesomund opened this issue 3 years ago • 2 comments

Hi, thanks for a great library!

As I was trying it out, i noticed what I think is a bug when changing the locale for dayjs before rendering the Datepicker component: if the week starts on a different day for the given locale (e.g. monday), the weekdays and dates will not match.

In my example, I was setting dayjs's locale to 'nb' (norwegian bokmål) before rendering the datepicker. Names of months and weekdays are correctly set according to the given locale, but the weekdays and dates do not match since dayjs.weekdaysShort() is not called with the localeOrder-flag set to true. dayjs.weekdaysShort(true) will return a list of weekdays where the order matches the locale used (e.g. monday first).

I couldn't find any way to enforce localOrder in my own dayjs config at first glance, so this seemed like the only solution that would work for me. Sorry if I'm missing something obvious!

The localeOrder feature in dayjs: https://github.com/iamkun/dayjs/issues/936

awesomund avatar Feb 22 '22 18:02 awesomund

Hey - thanks for this!

I've not really played with locales much at the moment, though it's on my radar. I'll have a look at this and see if it is the right solution.

I might also be getting rid of dayjs because I think it's the wrong solution for a third party library.

antony avatar Feb 23 '22 10:02 antony

@beyonk-group/engineering this is probably a blocker to i18n. We probably need to start planning.

antony avatar Aug 23 '23 10:08 antony