Skip to content

feat: add Jalali (Persian/Shamsi) calendar support with Saturday as week start#490

Open
hamedf62 wants to merge 4 commits into
bulwarkmail:mainfrom
hamedf62:feature/jalali-calendar
Open

feat: add Jalali (Persian/Shamsi) calendar support with Saturday as week start#490
hamedf62 wants to merge 4 commits into
bulwarkmail:mainfrom
hamedf62:feature/jalali-calendar

Conversation

@hamedf62

@hamedf62 hamedf62 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds Jalali (Persian/Shamsi) calendar support and Saturday as first day of week to Bulwark Webmail.

What is the Jalali calendar?

The Jalali (also known as Persian or Shamsi) calendar is the official calendar of Iran and Afghanistan. It's a solar calendar with 12 months (Farvardin through Esfand) and is one of the most accurate calendar systems in use today. The week in Iran starts on Saturday (شنبه).

Key Features

  1. Automatic calendar switching: When the locale is set to fa (Persian/Farsi), the calendar automatically displays Jalali months and dates
  2. Saturday as week start: FirstDayOfWeek setting now supports Saturday (6) alongside Sunday (0) and Monday (1)
  3. Display-only conversion: All internal date handling remains Gregorian (ISO 8601) for JMAP protocol compatibility — Jalali conversion happens only at the UI layer
  4. Full Persian locale: Includes complete fa translations for the entire UI

Changes

New Files

  • lib/jalali-utils.ts — Gregorian ↔ Jalali conversion utilities using jalaali-js
  • hooks/use-calendar-locale.ts — Unified calendar locale hook abstracting Gregorian/Jalali differences
  • locales/fa/common.json — Full Persian (Farsi) locale with ~3200 translations

Modified Files

File Change
stores/settings-store.ts FirstDayOfWeek type expanded to 0 | 1 | 6
components/settings/language-settings.tsx Added Saturday to first-day picker
components/calendar/calendar-month-view.tsx Uses useCalendarLocale for Jalali-aware rendering
components/calendar/calendar-week-view.tsx Supports weekStartsOn: 6
components/calendar/mini-calendar.tsx Jalali month grid, headers, month picker
components/calendar/calendar-toolbar.tsx Jalali month/year/week labels
hooks/use-format-event-date.ts Shows Jalali dates for fa locale
package.json Added jalaali-js dependency
All 20 locales/*/common.json Added Jalali month name keys

How It Works

┌──────────────────────────────────────────────────┐
│                    UI Layer                       │
│  ┌────────────────────┐  ┌────────────────────┐  │
│  │  Gregorian (en)    │  │  Jalali (fa)       │  │
│  │  "June 2026"       │  │  "تیر ۱۴۰۵"        │  │
│  │  Mon Tue Wed ...   │  │  ش  ی  د  س ...    │  │
│  └────────┬───────────┘  └────────┬───────────┘  │
│           │                       │               │
│           │    useCalendarLocale() │               │
│           │                       │               │
│  ┌────────┴───────────────────────┴───────────┐  │
│  │          Internal Date (Gregorian)          │  │
│  │          ISO 8601 / JMAP compatible         │  │
│  └─────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────┘

Testing

  • ✅ TypeScript compilation: no new errors
  • ✅ All calendar views render correctly with Saturday-first ordering
  • ✅ Jalali month grid shows correct day counts (including leap years)
  • ✅ Today detection works for both calendars
  • ✅ Month/year navigation works correctly
  • ✅ Event date formatting shows Jalali dates for fa locale
  • ✅ Week numbers display correctly for all week-start options

Known Interactions

Notes for Reviewers

  • The fa locale file is included as a new addition to support Persian language users
  • jalaali-js is a lightweight (no dependencies), well-maintained library for calendar conversion
  • The hook-based architecture (useCalendarLocale) keeps the calendar system abstraction clean and makes it easy to add support for other non-Gregorian calendars in the future

hamedf62 and others added 4 commits June 24, 2026 23:26
…eek start

- Add jalaali-js library for Gregorian ↔ Jalali date conversion
- Create lib/jalali-utils.ts with Jalali calendar utilities
- Create hooks/use-calendar-locale.ts for unified calendar locale handling
- Expand FirstDayOfWeek type to include 6 (Saturday)
- Update all calendar views (month, week, day, mini, toolbar) to support
  Jalali calendar display and Saturday-first week ordering
- Add Jalali month names (Farvardin … Esfand) to all locale files
- Add Persian (fa) locale with full translations
- Update settings UI to include Saturday as first day of week option
- Update useFormatEventDate to show Jalali dates when locale is fa
- Auto-detect Jalali calendar when fa locale is active

The calendar system automatically switches to Jalali when the locale is
set to Persian (fa). All internal date handling remains Gregorian (ISO
8601) for JMAP protocol compatibility; Jalali conversion is purely at
the display layer.
@shukiv

shukiv commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Ahalan wasahalan :-)

@hamedf62

Copy link
Copy Markdown
Contributor Author

Alaikum Salam

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.

2 participants