Skip to main content

Start Calendars on the Right Weekday Without Hard-Coding Sunday or Monday

2026-11-26

Start Calendars on the Right Weekday Without Hard-Coding Sunday or Monday

A user in Berlin opens your booking page and sees a month grid that starts on Sunday. Every row is shifted by one column from the calendar on their wall, so they pick Tuesday the 14th when they meant Wednesday the 15th. A user in Cairo sees Saturday and Sunday shaded as the weekend, though their working week does not match. Neither bug throws an error, and both lead users to pick the wrong date.

The first day of week by locale decides how month grids, date pickers, "this week" filters, habit streaks, timesheets, and weekly reports line up. This guide is for web and mobile engineers who own those screens. It shows where the value should come from on each platform, why the app language is the wrong input, and how to keep display and stored data consistent.

The short answer

  1. Read week start and weekend days from the platform for the user's region and preference, not from the app language.
  2. Respect a user override when the OS exposes one, and offer your own setting only as a last layer.
  3. Convert every library's weekday numbering through one adapter.
  4. Pass the value to each date picker and calendar component explicitly.
  5. Keep stored weekly aggregates on a declared week definition that does not change with the viewer.
  6. Test with regions that start the week on Monday, Sunday, and Saturday.

Why calendars start on the wrong day

Most date libraries ship one default. FullCalendar documents firstDay as an integer whose default is 0, meaning Sunday, with the actual default depending on the current locale (FullCalendar: firstDay). That is reasonable only if the locale data is loaded and correct. When it is not, every user gets the US layout.

Practitioners keep running into this. A Stack Overflow question asking how to find the start of the week for a locale has a score of 59 and more than 37,000 views (Stack Overflow: Start of week for locale). Another reports that Moment.js returned Sunday as the first day of the week for European users, even after setting en-gb and fr locale files (Stack Overflow: Moment.js first day of the week incorrect). On Android, a developer reports a DatePicker calendar view that starts on Sunday on a Swiss phone (Stack Overflow: Set first day of week in DatePicker to Monday).

Framework issue trackers show the same pattern. Angular Material's native date adapter cannot detect the first day of week from the user's locale; a reporter with a Russian locale sees Sunday-first pickers, and the issue has been open since 2021 (GitHub: angular/components #23073). These are author reports with a shared cause. The component either has no access to week data or receives the wrong locale.

Where week data actually lives

Week rules are regional data in Unicode CLDR. UTS 35 defines firstDay, weekendStart, weekendEnd, and minDays as maps from territory to value (Unicode UTS 35 Part 4: Dates). The excerpt in the specification shows Monday as the world default (001), Friday for Bangladesh and the Maldives, and Saturday for a list that includes the UAE, Algeria, Egypt, Iraq, Iran, and Jordan. Weekends vary too: the same excerpt lists a Thursday weekend start for Afghanistan, Algeria, Iran, Oman, Saudi Arabia, and Yemen, a Friday start for the UAE and Bahrain, and a Sunday start for India.

Platforms expose this data through their own APIs, and each one reads it slightly differently.

Web and Node.js

Intl.Locale.prototype.getWeekInfo() returns an object with firstDay, weekend, and minimalDays (MDN: Intl.Locale.prototype.getWeekInfo()). firstDay is an integer from 1 (Monday) to 7 (Sunday). weekend is an array of day numbers. minimalDays is the minimum number of days a first week of a month or year needs, which drives week-of-year numbering.

Support arrived in stages. MDN's compatibility data lists the method in Chrome 130, Safari 17, Firefox 153, and Node.js 24, with an earlier weekInfo accessor property in Chrome 99 and Node.js 18 (MDN browser-compat-data: Intl.Locale). MDN notes that the accessor was replaced because it returned a new object on each access. Code that targets older runtimes needs both paths and a fallback:

function weekRules(tag) {
  const locale = new Intl.Locale(tag);
  if (typeof locale.getWeekInfo === "function") return locale.getWeekInfo();
  if (locale.weekInfo) return locale.weekInfo;
  return null; // use a small reviewed table keyed by region
}

If you need the fallback table, key it by region code and generate it from CLDR at build time rather than typing it by hand.

iOS, iPadOS, and macOS

Foundation exposes Calendar.firstWeekday, documented as the first day of the week for the calendar, with both a getter and a setter (Apple: Calendar.firstWeekday). Read it from Calendar.current or Calendar.autoupdatingCurrent, which reflect the user's system settings, rather than from a calendar you built from the app's language alone.

SwiftUI's DatePicker lays out its grid from the current locale. One practitioner asks how to apply an app-level week-start preference to it, which shows the gap between what the OS knows and what an app setting wants (Stack Overflow: Custom week start in SwiftUI DatePicker). If you offer your own setting, set firstWeekday on a calendar copy and inject it into every calendar-driven view, then verify the result on your minimum supported OS version. That is a recommendation to test, not a documented guarantee for every control.

Android and the JVM

java.time.temporal.WeekFields defines a week by its first day and the minimal number of days in the first week, and WeekFields.of(Locale) returns the rules for a locale (Android: java.time.temporal.WeekFields). The same page notes that ISO-8601 starts on Monday and requires at least four days in the first week.

Android 14 added Regional preferences that let users personalize temperature units, the first day of the week, and numbering systems. Android's own example is a European living in the US who wants Monday as the start of the week instead of the US default of Sunday (Android 14: Regional preferences). AndroidX LocalePreferences.getFirstDayOfWeek reads that preference from the default locale's first-day-of-week subtag, and with resolved set to false it returns an empty string when the user has not set one (AndroidX: LocalePreferences).

fun firstDayOfWeek(locale: Locale): DayOfWeek {
    val pref = LocalePreferences.getFirstDayOfWeek(false)
    if (pref.isNotEmpty()) return mapPreference(pref) // your mapping from the FirstDayOfWeek constants
    return WeekFields.of(locale).firstDayOfWeek
}

Use the region, not the app language

Code that builds week rules from the app language looks locale-aware, so it tends to pass review.

UTS 35 spells out how the first day is chosen from a locale identifier. A valid -u-fw- value wins. Otherwise a -u-rg- region override is used, then a calendar that defines its own first day, then an explicit region subtag, then a subdivision, then the region produced by the Add Likely Subtags algorithm, and finally the world default (Unicode UTS 35 Part 4: Dates). Language never appears in that list on its own.

That has a practical consequence for apps with an in-app language picker. When a user in Ireland chooses "English" and your code builds new Intl.Locale("en") or Locale("en"), the region comes from likely subtags, not from Ireland. The same happens with ar, which can stand for users in Morocco, Egypt, or Saudi Arabia whose weeks differ. In both cases the in-app language picker gives the user a worse calendar than the system default would have.

Week start comes from the user's region and their own override, not from the app language, so carry the region whenever you build a locale from an in-app language choice. The fix is small once the locale model has a place for the region.

What to do differently:

  • Keep the user's region separate from their UI language in your locale model. When the app language is overridden, rebuild the tag as language plus the original region, or add -u-rg- with that region.
  • When the OS exposes a first-day preference, as Android 14 does, carry it forward with -u-fw- or read it directly instead of recomputing from the language.
  • Treat an app-level "week starts on" setting as the final layer, stored per user, not as a replacement for the region default.

A cal.com feature request describes the cost on a shared booking page. It points out that the page already converts times to the viewer's time zone but still shows the owner's week start, which is "very disorienting" when the viewer works with a Monday-first calendar all day (GitHub: calcom/cal.diy #14517). Shared pages should use the viewer's week rules, just as they use the viewer's time zone.

Normalize weekday numbers in one place

Each library numbers weekdays its own way. getWeekInfo() uses 1 for Monday and 7 for Sunday (MDN: Intl.Locale.prototype.getWeekInfo()). MUI X's date picker documentation shows dayjs weekStart and date-fns weekStartsOn with Sunday as 0 and Monday as 1, while Luxon's defaultWeekSettings uses 7 for Sunday (MUI X: Date pickers localized dates). FullCalendar's firstDay uses 0 for Sunday (FullCalendar: firstDay). Apple's firstWeekday is an integer index into Foundation's own weekday numbering (Apple: Calendar.firstWeekday).

The two conventions agree for Monday through Saturday and differ only for Sunday. Passing getWeekInfo().firstDay straight into date-fns works for German, British, and Egyptian users, then hands date-fns a 7 for a Sunday-first region such as the US, which is outside its 0 to 6 range. The bug hides in exactly the region most teams treat as the default and test least deliberately, and when it does show up it looks like a plausible grid to anyone not reading the dates closely.

Date libraries number weekdays differently and agree on every day except Sunday, so route week start through one adapter with a Sunday test. Our recommendation is a single adapter with an explicit internal enum:

type Weekday = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";

const fromIso: Weekday[] = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];

export function weekStart(tag: string): Weekday {
  const info = weekRules(tag);
  return info ? fromIso[info.firstDay - 1] : "mon";
}

// date-fns and dayjs: Sunday = 0
export const toSundayZero = (d: Weekday) => (fromIso.indexOf(d) + 1) % 7;
// Luxon and getWeekInfo: Monday = 1, Sunday = 7
export const toIso = (d: Weekday) => fromIso.indexOf(d) + 1;

Then write one table-driven test per library that asserts Monday, Saturday, and Sunday convert to the integer that library documents. If a dependency upgrade changes a convention, the test fails before users see a shifted grid.

Pass the value to every component

Do not assume a component reads week data on its own. The Angular Material and Moment.js reports above are both cases where the developer expected the locale to carry week start and it did not. Give each picker and grid the converted value directly:

  • date-fns based components: weekStartsOn, or a locale object whose options.weekStartsOn you override, as MUI documents (MUI X: Date pickers localized dates).
  • dayjs: updateLocale with weekStart.
  • Luxon: Settings.defaultWeekSettings with firstDay, minimalDays, and weekend.
  • FullCalendar: firstDay.
  • Android: firstDayOfWeek on the calendar view, from the function above.
  • Apple platforms: a calendar copy with firstWeekday set, injected into your calendar views.

Do the same for weekend shading. Highlighting Saturday and Sunday by default is wrong for users whose weekend starts on Friday or Thursday. Use weekend from getWeekInfo() on the web and a region-keyed table on platforms without a direct API.

Keep stored weeks separate from displayed weeks

A month grid is presentation. A weekly total in a dashboard, a "7-day streak", or a timesheet is data. If you compute "this week" from the viewer's week start, two people looking at the same team report will see different numbers, and a streak can break when a user travels or changes their region.

Keep the week definition used for stored weekly totals separate from the week start used for display, so a viewer's calendar layout never changes shared reports. This is a recommendation from first principles, supported by how the specs define weeks. WeekFields and getWeekInfo() both make week boundaries depend on two locale values, the first day and the minimal days in the first week (Android: java.time.temporal.WeekFields). Anything stored with "week" in its key inherits those values unless you fix them.

What to do:

  • Pick a storage week definition and write it down, for example ISO-8601 weeks starting Monday with four minimal days, or a per-account setting chosen by an admin.
  • Store daily rows and aggregate into weeks with that definition on the server.
  • Use the viewer's week start only to lay out grids and label ranges.
  • When a product needs a user's own week, such as a personal habit tracker, store the chosen first day with the user and use it for both display and aggregation, so the two never drift apart.

Failure handling and tradeoffs

Older runtimes will not have getWeekInfo. A generated region table is a safe fallback, but it ages with CLDR, so regenerate it when you update your CLDR or ICU dependency. Hard-coding Monday as the fallback is defensible because it is the CLDR world default, but log when the fallback is used so you know how often it happens.

User overrides can conflict. If Android reports a first-day preference and your app also has a setting, decide the order once: the explicit in-app choice, then the OS preference, then the region default. Show the effective value in your settings screen so support can see what a user saw.

Locale data differs between test environments and devices. JVM unit tests and browsers in CI ship their own ICU data. Run week-start assertions on real devices or emulators for the OS versions you support, not only in a JVM.

A related setting, the 12-hour or 24-hour clock, follows the same pattern of regional default plus user override. Format times through platform APIs and avoid deriving the hour cycle from language, as covered in our guide to localizing app dates, times, and numbers.

Test week start in every launch region

A short suite catches most regressions:

  1. For en-US, en-GB, ar-EG, and fa-IR, assert the first day your adapter returns matches CLDR, and compare against a snapshot generated from the same data.
  2. Build an app-language override for a user whose region is Ireland and assert the week start still follows Ireland, not the default region for en.
  3. On Android 14 or later, set a first-day preference in Regional preferences and assert the calendar follows it.
  4. For each date library you use, assert Monday, Saturday, and Sunday convert to the documented integer.
  5. Render a month grid and assert the first column header matches the expected weekday name for each test region.
  6. Assert weekend shading for a Friday-start region and a Sunday-only weekend region.
  7. Load a shared weekly report as two viewers with different week starts and assert the totals match.

Common mistakes

  • Hard-coding Sunday or Monday in a shared calendar component.
  • Building the locale for week rules from the app language without the user's region.
  • Passing getWeekInfo().firstDay directly to a Sunday-zero library.
  • Expecting a date picker to read week start from a locale object it never received.
  • Shading Saturday and Sunday as the weekend for every user.
  • Aggregating stored weekly data with the viewer's week start.
  • Testing only in a JVM or a single browser.

What to do next

Search your codebase for weekStartsOn, firstDay, firstWeekday, firstDayOfWeek, and literal weekday indexes, and list every component that decides where a week starts. Replace those decisions with one adapter that reads week rules from the user's region and preference, then add the region and numbering tests above to CI. If your app also renders non-Gregorian calendars, review how week rules interact with them in our guide to supporting non-Gregorian calendars.