Case study · Productivity

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
Overview

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.

The problem

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.json holds 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.
Architecture

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.

Roozaneh architecture: the RoozaneCalendar app target and the RoozaneWidget extension each bundle their own copy of calendar_1405.json; the App Group UserDefaults bridge carries the app's daily data to the widget as a fallback only. APP TARGET HomeScreen Daily/Monthly VMs Calendar Services SwiftData Store WidgetDataSync SHARED DATA BRIDGE App Group UserDefaults group.rouzaneh.calendar.widget Birthdays · cow art · gradient · language calendar_1405.json 365 days · Persian year 1405 Bundled independently into both targets WIDGET EXTENSION Provider TimelineProvider · now + 7 midnights WidgetCalendarStore Independent decode of calendar_1405.json SimpleEntry Cow art · gradient · birthday per entry writes + reloads fallback only
The widget reads every date, including future midnights, from its own bundled copy of calendar_1405.json. The App Group is only a fallback, so the widget never depends on the app having run that day.

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.

Decisions

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.

What it cost

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.

What it cost

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.

What it cost

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.

What it cost

If it ever grows a team, that will need to change.

Hard parts

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.

By the numbers

What exists, and what does not

60
Swift files
About 6,300 lines across the app and the widget.
365
Bundled days
One full Persian year (1405), with O(1) lookup.
0
Network calls
No backend, no accounts, no analytics. Data stays on the device in SwiftData.
Looking back

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.