Skip to content

Conversation

@devalimotahari
Copy link

Summary

This pull request fixes an issue where non-Gregorian calendars (e.g., Jalali/Persian) do not display correct day or month values when a localized language code is passed (e.g., fa-IR-u-ca-persian).

Currently, frappe-gantt relies on raw Date object values from this.get_date_values(date), which always use the Gregorian calendar. As a result, when users select languages that use calendar systems like Jalali, the day and month fields are rendered incorrectly.

Problem Example

When using:
gantt = new Gantt('#gantt', tasks, { language: 'fa-IR-u-ca-persian' });

Expected: Days and months should follow the Jalali calendar.
Actual: Days of months are displayed incorrectly (see screenshot).

Bug screenshot

Fix Implemented

  • Switched to Intl.DateTimeFormat for extracting year, month, and day values.

  • This ensures that values respect the active calendar system defined in the lang parameter.

  • The new format_map separates calendar-aware values (YYYY, MM, DD, D, MMMM, MMM) from time values (HH, mm, ss, SSS), ensuring correct rendering across different locales and calendars.

Example:
YYYY: yearFmt.format(date), MM: month2Fmt.format(date), DD: day2Fmt.format(date), D: dayFmt.format(date), MMMM: month_name_capitalized, MMM: monthShortFmt.format(date)


Requirements / Notes

  • ✅ Tested with fa-IR-u-ca-persian (Jalali calendar).

  • ✅ Backward compatible with default en (Gregorian calendar).

  • ✅ No external dependencies added — relies only on Intl.DateTimeFormat.

  • 📖 Reference: Unicode Locale Identifiers (e.g., fa-IR-u-ca-persian).


Impact

This change improves internationalization support in frappe-gantt and ensures correct date rendering for users working with non-Gregorian calendars.

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.

1 participant