Make startOfWeek locale-aware by default #3831
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses the issue raised regarding the startOfWeek function's lack of default locale awareness. Currently, the function defaults to Sunday as the start of the week, which may not align with the conventions of all locales.
Problem Statement:
The current implementation of the startOfWeek function does not consider locale-specific conventions for determining the start of the week. This poses an inconvenience for users who rely on different start-of-week conventions based on their locale.
Proposed Solution:
To address this issue, I've modified the startOfWeek function to be locale-aware by default. Now, when no explicit locale is provided, the function will automatically determine the start of the week based on the locale settings. This enhancement improves usability and ensures that the function aligns with the expectations of users across different locales.
Comments from Issue:
The original issue highlighted the need for locale-aware behavior by default, citing the inconvenience of manually specifying the week start parameter based on locale.
Comments from other contributors acknowledged the workaround of manually specifying the locale but emphasized the importance of making the function more intuitive and efficient.
Changes Made:
Modified the startOfWeek function to check for the default locale if no explicit locale is provided.
Implemented logic to determine the start of the week based on the locale settings.
Updated the documentation to reflect the changes made to the function.
Test Coverage:
Added tests to ensure that the startOfWeek function behaves correctly with different locales.
Existing tests have been updated to accommodate the changes in behavior.
Related Issue: #3829