Skip to content

Conversation

jimmystridh
Copy link

Summary

Fix calendar picker to respect user's locale settings for first day of the week by switching from navigator.language to moment.js locale detection.

Types of changes

Changes visible to users:

  • Bug fix (prefix: fix - non-breaking change which fixes an issue)

Description

Changes

  • Add getFirstDayOfWeekFromMoment() helper function using moment.locale() and moment.localeData().firstDayOfWeek()
  • Replace Intl.Locale(navigator.language).weekInfo?.firstDay approach with moment.js locale data
  • Fallback to Monday if locale detection fails

Technical Details

The previous implementation using Intl.Locale(navigator.language).weekInfo?.firstDay was not returning the correct first day of the week value according to user locale. The new implementation uses window.moment.locale() and window.moment.localeData().firstDayOfWeek() to determine the first day of the week. This leverages the existing moment.js already used throughout the plugin and provides more reliable locale detection.

Motivation and Context

The calendar picker in the Edit Task view was not respecting user's regional preferences for the first day of the week. This was caused by the navigator.language API being an incorrect way of determining the user regional settings.

How has this been tested?

  • Code compiles successfully with TypeScript
  • Calendar picker builds and renders correctly
  • Locale detection function works with moment.js locale data
  • Fallback behavior implemented and tested (defaults to Monday when locale detection fails)
  • Manual testing in Obsidian vault with different locale settings

Screenshots (if appropriate)

N/A - This is a functional fix that affects calendar behavior rather than visual appearance.

Checklist

  • My code follows the code style of this project and passes yarn run lint.
  • [-] My change requires a change to the documentation.
  • [-] I have updated the documentation accordingly.
  • My change has adequate Unit Test coverage.

Terms

Copy link

@claremacrae
Copy link
Collaborator

Hi, many thanks very much for looking at this.

Please could you edit the “How has this been tested” section to say what platforms and locales you have tested it on, and what Tasks operations you did to test it?

For the screenshots bit, you could show a screenshot of the wrong date before the fix, and the right date after the fix, saying which platform, and what Tasks action was done.

Also, please could you link to the issue(s) you are fixing, and the previous fix you referred to.

Thanks.

@claremacrae
Copy link
Collaborator

I am on a phone screen so may have misread something, but the following issue says the first day is right in the modal, but the “Motivation” here says it was wrong in the modal:

@claremacrae claremacrae added question Further information is requested scope: user interface UI other than Edit task modal, e.g. context menus, date picker labels Sep 17, 2025
@claremacrae
Copy link
Collaborator

Hi @jimmystridh, I’d love to understand and test this and get it merged.

Do you have any idea when you might be able to reply to the comments above, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested scope: user interface UI other than Edit task modal, e.g. context menus, date picker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants