feat: add Saturday as first day of week option#5893
Conversation
Thank you for exposing the info. Did you check the code yourself? Which regions use Saturday as first day of the week? |
| } | ||
|
|
||
| public function __construct(?DateTimeZone $timezone = null, bool $startOnSunday = false) | ||
| public function __construct(?DateTimeZone $timezone = null, string $firstDayOfWeek = 'monday') |
There was a problem hiding this comment.
This is a critical BC and needs to be changed. Make it bool|string and adjust the code accordingly. True = Sunday, False = Monday.
Also add a deprecation in case of bool.
|
Yes, I reviewed the changes. The Saturday is the first day of the week in several countries, mostly in the Middle East and North Africa - Afghanistan, Egypt, Iran, Iraq, Libya, Qatar, and Somalia. The work week starts Saturday and Friday is the weekend (Islamic prayer day). I'll sign the CLA now. |
Summary
Adds Saturday as an option for the first day of the week, alongside the existing Monday and Sunday options. Useful for regions where the work week starts on Saturday.
Changes
src/Form/Type/FirstWeekDayType.php: Added'Saturday' => 'saturday'to the choices arraysrc/Timesheet/DateTimeFactory.php: Refactored frombool $startOnSundaytostring $firstDayOfWeekwithmatchexpressions for Monday/Sunday/Saturday week boundary calculationssrc/Entity/User.php: AddedisFirstDayOfWeekSaturday()method, keptisFirstDayOfWeekSunday()for backward compatibilitysrc/Command/InvoiceCreateCommand.php: Updated to pass$user->getFirstDayOfWeek()instead of$user->isFirstDayOfWeekSunday()Backward compatibility
The
isFirstDayOfWeekSunday()method is preserved. TheDateTimeFactoryconstructor now accepts a string ('monday','sunday','saturday') instead of a boolean, but the default behavior ('monday') matches the previous default (false).Fixes #4017
This contribution was developed with AI assistance (Codex).