Roozaneh
A Persian calendar for iPhone and iPad that shows Jalali, Gregorian and Hijri dates together, in Persian or English, with a home-screen widget. A personal project, fully offline.
- Role
- Solo developer, personal project
- When
- Feb to Jun 2026
- Stack
- Swift · SwiftUI · SwiftData · WidgetKit
- Size
- 60 Swift files · ~6,300 lines
One calendar, three date systems, two directions
Roozaneh is a Persian (Jalali) calendar for iPhone and iPad. It has daily and monthly views, a home-screen widget, birthdays, notes and countdowns, and it shows the Persian, Gregorian and Hijri dates side by side, in Persian (right to left) or English (left to right).
It is my own project, outside any client or employer work. I built it in bursts between February and June 2026, and I wanted something I would actually use every day.
Why a calendar is harder than it looks
For many Persian speakers, every day has three dates: Jalali, Gregorian and Hijri, each with its own holidays and occasions. Getting the Persian side right meant shipping a pre-computed table instead of computing dates and occasions at runtime.
The Hijri side has no reliable offline source. iOS's built-in Umm al-Qura calendar is arithmetic, not based on moon sighting, and it can be a day off from the calendar Iran actually observes.
Direction is more than mirrored text. Scroll direction, the order of weekday columns and page swiping all flip too, and the user can switch language at runtime.
And the widget has to show the same "today" as the app, from a separate target that cannot import the app's code, and it has to be right at every midnight even if I have not opened the app that day.
Constraints
- iOS 17 and up, iPhone and iPad.
- The widget cannot see the app's code. Anything it needs has to be duplicated, not shared through a framework.
- One bundled year.
calendar_1405.jsonholds exactly one Persian year, 365 entries. A new year means new data and an app update. - Fully offline. There is no server, so a data correction has to ship as an update.
Two targets, one data file, no shared code
The app uses per-feature folders with SwiftData repositories and observable view models. The widget cannot compile against any of that, so it decodes its own copy of the same calendar data.
At launch, PersianCalendarService loads calendar_1405.json into a dictionary keyed by a packed year, month and day number, so lookups are O(1). The home screen then fetches birthdays from SwiftData, picks today's illustration and gradient, and hands it all to WidgetDataSync, which writes it to the App Group and reloads the widget. The daily and monthly view models cache each page by offset so scrolling does not recompute dates on every frame.
The widget builds entries for now and the next seven midnights, and reads each day from its own bundled copy of the calendar first. The App Group is only a fallback, so a future midnight is still right even if the app has not run.
Including the one I reversed
A JSON file instead of parsing a spreadsheet at runtime
The calendar used to ship as a 15 MB spreadsheet, unzipped and parsed on the device by a 206-line parser and the ZIPFoundation dependency. Both are gone. The app decodes one JSON file directly.
The data has to be exported from the source spreadsheet every year.
A hand-written Hijri table, built and reverted the same day
I built a corrected Hijri calendar from a table of observed month lengths. About seven hours later I removed it. Its last entry said "placeholder, confirm before issuing", which tells you how much I trusted it.
The app uses Umm al-Qura and can be a day off. It is documented as a known limitation in the code.
The widget bundles its own calendar
The widget is right at midnight even if I have not opened the app in days.
The calendar data ships twice in the binary, and any correction has to go into both.
Feature folders, no formal architecture
No layers or DI container, just shared singletons. For a solo project this size, less ceremony meant more progress.
If it ever grows a team, that will need to change.
Backwards in two files at once
Right-to-left, set backwards
The layout direction was mapped the wrong way round (Persian to left-to-right, English to right-to-left) in both the daily and monthly screens at the same time. Until I fixed it, the paged calendar scrolled the wrong way for Persian users. When a bug is symmetric across two files, both look "consistent", which is why it slipped through.
Matching the app without sharing code
Getting the widget's illustration and background to match the app took at least three commits, because the logic had to be written separately in two places.
Paging past the data
The first pager allowed more days than the bundled year actually had. Two later commits clamped daily and monthly paging to the current Persian year.
What exists, and what does not
What I would tell myself before the reversal
- A hand-maintained lunar table is a trap. The built-in calendar is less accurate and much easier to keep correct.
- Duplicating reference data was the right call for two targets. It is what keeps the widget correct at midnight.
- Test each language direction on purpose. A symmetric bug looks consistent, and consistent looks correct.