Skip to content

fix: prevent toCalendarSystem() from mutating global locale state#19

Merged
amirhmoradi merged 1 commit into
mainfrom
claude/investigate-issue-18-pH77G
Jan 25, 2026
Merged

fix: prevent toCalendarSystem() from mutating global locale state#19
amirhmoradi merged 1 commit into
mainfrom
claude/investigate-issue-18-pH77G

Conversation

@amirhmoradi

Copy link
Copy Markdown
Contributor

The instance method toCalendarSystem() was incorrectly calling dayjsFactory.updateLocale() which mutated the global locale dictionary. This caused all subsequent dayjs instances to use the calendar-specific month names, making it impossible to use multiple calendar systems simultaneously.

Changes:

  • Remove global updateLocale() call from instance toCalendarSystem()
  • Store calendar-specific locale data on instance ($calendarLocale)
  • Override $locale() to merge instance-specific locale when available
  • Update locale() to regenerate $calendarLocale when locale changes

Fixes #18

The instance method toCalendarSystem() was incorrectly calling
dayjsFactory.updateLocale() which mutated the global locale dictionary.
This caused all subsequent dayjs instances to use the calendar-specific
month names, making it impossible to use multiple calendar systems
simultaneously.

Changes:
- Remove global updateLocale() call from instance toCalendarSystem()
- Store calendar-specific locale data on instance ($calendarLocale)
- Override $locale() to merge instance-specific locale when available
- Update locale() to regenerate $calendarLocale when locale changes

Fixes #18
@github-actions

Copy link
Copy Markdown
Contributor

✅ All CI checks have passed! This PR is ready for review.

@amirhmoradi amirhmoradi merged commit 004c26d into main Jan 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instance method toCalendarSystem() mutates global calendar system instead of only converting the instance

2 participants