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

First day of the week at date picker for date/time field #1152

Open
InsaneCake opened this issue Dec 9, 2024 · 3 comments
Open

First day of the week at date picker for date/time field #1152

InsaneCake opened this issue Dec 9, 2024 · 3 comments

Comments

@InsaneCake
Copy link

Is your feature request related to a problem? Please describe.
In date picker for date/time field first day of the week is sunday. It is wery confusing on some cultures.
image
Roughly 44% of world populations starts week from monday
image

Describe the solution you'd like
Give option for users to select first day of the week.
Default value may be from teable instance settings or from browser locale and ability to overwrite it for user in profile settings.
This way every member of multy-culture team will have preferred options and better defaults

Describe alternatives you've considered
Default first week day in date picker just from browser locale

Additional context
Calendar view properly localized and starts from monday on RU locale. So maybe it is just an localization bug.
image

@kpodp0ra
Copy link
Collaborator

Teable assumes that if you have selected English language, you are interested in en-US variant of calendar.
It starts week from Sunday: https://github.com/date-fns/date-fns/blob/6c70ac6d073ebe869e42795f5e71dfecf5abbea0/src/locale/en-US/index.ts#L16-L27

If we changed defaults to en-GB, it would start week from Monday: https://github.com/date-fns/date-fns/blob/6c70ac6d073ebe869e42795f5e71dfecf5abbea0/src/locale/en-GB/index.ts#L15-L26


Implementing this feature request would be straightforward, as there is an option in the upstream to overwrite locale's default behavior: https://daypicker.dev/docs/localization#first-date-of-the-week

It's very simple, you have to add weekStartsOn={ AppContext.weekStart } after:

<Calendar
locale={LOCAL_MAP[lang as keyof typeof LOCAL_MAP]}

and user setting there:

@InsaneCake
Copy link
Author

Teable assumes that if you have selected English language, you are interested in en-US variant of calendar.
It starts week from Sunday: https://github.com/date-fns/date-fns/blob/6c70ac6d073ebe869e42795f5e71dfecf5abbea0/src/locale/en-US/index.ts#L16-L27

If we changed defaults to en-GB, it would start week from Monday: https://github.com/date-fns/date-fns/blob/6c70ac6d073ebe869e42795f5e71dfecf5abbea0/src/locale/en-GB/index.ts#L15-L26

Sounds right, so in my case i should have ru-RU locale, but datepicker in cell still starts from sunday and not translated to russian.
Date selection in toolbar of calendar view is translated properly and starts from monday (пн).
I have checked additionaly - datepicker is the same for all languages.

@kpodp0ra
Copy link
Collaborator

I've added PR that fixes that issue.

Waiting for project owner's decision whether they want to have an additional field in the user settings under ‘language’ to select the user's preferred first day of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants