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

Have calendar - locale aware #1696

Open
Emacdyz opened this issue Jan 10, 2023 · 0 comments
Open

Have calendar - locale aware #1696

Emacdyz opened this issue Jan 10, 2023 · 0 comments
Assignees

Comments

@Emacdyz
Copy link
Contributor

Emacdyz commented Jan 10, 2023

Improvement description

Atm the calendar always starts the week on a Monday but for some countries, the week starts on a Sunday. It would be nice to have a calendar that updates the first day of the week depending on the local

Expected behavior

Something like this would work, but not yet supported on firefox

const getWeekdays = (locale: string) => {
  const weekdays = []
  const localeWeek = new Intl.Locale(locale)
  const firstDayOfTheWeek = localeWeek.weekInfo.firstDay

  for (let i = 0; i < 7; i++) {
    const weekday = new Date(2021, 5, i).toLocaleString(locale, {
      weekday: 'short',
    })

    weekdays.push(weekday)
  }

  if (firstDayOfTheWeek === 7) {
    return weekdays
      .slice(firstDayOfTheWeek - 1)
      .concat(weekdays.slice(0, firstDayOfTheWeek - 1))
  }

  return weekdays
}
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

5 participants