This document summarizes the implementation of configurable first day of the week for the calendar widget. Users can now configure the calendar to start the week on any day (Sunday, Monday, Tuesday, etc.) and the calendar will properly display weekday headers and align the days accordingly.
CALENDAR_WIDGET_WEEKDAY_ABBREVIATIONS: Maps weekday names to their abbreviations (Su, Mo, Tu, etc.)
generateWeekdayHeaders(firstDayOfWeek: string): Generates HTML for weekday headers based on the selected first day of the week
- Updated the calendar modal template to dynamically generate weekday headers using the new function
- Fixed the
showCalendarModalcall to use the correct first day of week index
- Fixed the
renderCalendarDaysfunction to properly calculate the starting day offset based on the first day of week setting - The calculation now correctly handles cases where the first day of the week is different from Sunday
- The system determines the first day of the week from widget options
- It creates an ordered array of weekdays starting from the selected first day
- It generates HTML div elements for each weekday abbreviation
- Weekend days (Saturday and Sunday) are styled with red text
- The system calculates the offset for the first day of the month based on the selected first day of the week
- It adds empty cells to properly align the calendar grid
- The days are then filled in sequence
The implementation was tested with three configurations:
- Sunday as first day: Su Mo Tu We Th Fr Sa
- Monday as first day: Mo Tu We Th Fr Sa Su
- Saturday as first day: Sa Su Mo Tu We Th Fr
All configurations correctly display the weekday headers and align the calendar grid properly.
- User Configurability: Users can choose their preferred starting day of the week
- Proper Visualization: Weekend days are highlighted in red regardless of the starting day
- Correct Alignment: Calendar grid correctly aligns with the selected starting day
- Internationalization Ready: The implementation can easily support different weekday preferences from various cultures
- Add localization support for weekday abbreviations
- Implement additional styling options for different weekend days in various cultures
- Add validation for the first day of week setting