Two ways to build a calendar app
There are broadly two ways an app can show you today’s timings:
- Ask a server. The app sends your location and date to a server, which looks up or calculates the answer and sends it back. Simple to build, but the app is only as reliable as your connection and the server.
- Calculate on the phone. The app contains the astronomical and calendar formulas, and works the answer out itself from your location and the date.
OIOA takes the second approach: calendar calculations run on your device, with no daily API dependence.
Text version of this diagram
- Your location, from the phone or a city you pick.
- The date and time, from the phone’s clock.
- Astronomical and calendar calculations, run on the phone.
- Today’s timings: panchang, prayer times and calendar days.
A network is used for things involving other people, such as groups and sharing, and for app updates.
The inputs
Almost every calendar timing needs just three things:
- Where you are: latitude and longitude, from the phone’s location service, which works by satellite without data, or a city you choose.
- When it is: the date and time from the phone’s clock, and your time zone.
- Which method you follow: for example a prayer-time method, a Parsi calendar or a Jain sect calendar.
The astronomy
From those inputs, a phone can compute:
The Sun’s position. Using well-established formulas for the Earth’s orbit, the app finds the Sun’s position in the sky for any moment, which gives:
- sunrise and sunset, and everything derived from them: Rahu Kaal, Choghadiya, Hora, Abhijit, Navkarshi,
- solar noon (Dhuhr), and the times when the Sun reaches set angles below the horizon (Fajr and Isha),
- shadow lengths for Asr,
- sankrantis, when the Sun enters each sidereal zodiac sign.
The Moon’s position. Using a series of terms that describe the Moon’s complex orbit, the app finds the Moon’s position, which gives:
- the tithi (the Moon–Sun angle),
- the nakshatra (the Moon’s sidereal position),
- Panchak (the Moon in the last five nakshatras),
- the new moon and full moon, the basis of lunar months.
Geometry. The Qibla is a great-circle bearing between two coordinates: a few lines of trigonometry.
Arithmetic calendars. Some calendars are pure arithmetic once their rules are known: the Parsi calendars (30-day months plus Gatha days, with or without leap days), tabular Islamic calendars, and the original Nanakshahi calendar’s fixed month starts.
How accurate is it?
Modern astronomical algorithms, of the kind published for practical use by astronomers, are accurate to well within a minute for sunrise, sunset and the Moon’s position over many centuries, far more precise than the conventions that define the timings themselves. In practice, differences between calendars come from:
- definitions (does sunrise mean the Sun’s top edge or its centre?),
- conventions (which twilight angle, which ayanamsha, which festival rule?),
- location (which city the calendar was made for),
rather than from the calculation itself. That’s why OIOA lets you choose your method and uses your location.
What still needs a network
Some things genuinely involve other people or updates:
- Groups and sharing, which connect you with others.
- Signing in and account features.
- App updates from the store.
The core calendar, the thing you need most often and in the least connected places, doesn’t.
Speed and battery
These calculations are tiny by a phone’s standards. Computing a whole day’s timings involves a few thousand arithmetic operations, much less than loading an image.
Privacy
Calculating on your device also means your location doesn’t need to be sent anywhere to show you today’s timings. The privacy policy lists what is processed only on your device and what is stored with our processors.
Keep your clock right
Because everything depends on the phone’s clock, the most common cause of “wrong” timings in any offline app is a phone with the wrong time zone or a manually set clock. Set your phone to automatic date and time.
In OIOA
See offline use for what works without a connection in OIOA, across every community.
Common questions
Do offline calendar apps need updating?
The astronomy doesn’t change, but apps are updated for new features, fixes, new communities and methods, and occasionally for changes made by authorities, such as a new holiday list or a revised calendar convention. Keep the app updated from the store.
How can an app know festival dates without the internet?
Many festival dates follow directly from the calendar rules: a tithi in a lunar month, a Roj and Mah, a Nanakshahi date. Once the rules are built in, the dates can be calculated. Dates that depend on announcements, such as moon sighting, or on government notification, such as holidays, need confirmation from the relevant authority.
Is satellite location accurate enough?
Yes, many times over. Timings change by about four minutes for every degree of longitude, which is roughly 100 km in India. Even a rough location, accurate to a few kilometres, gives timings accurate to within seconds.
Does calculating on the phone use my data allowance?
No. Calculations happen on the phone itself without any network traffic.
Can I trust an on-device calculation over a printed calendar?
Both can be right. A printed calendar is calculated for a particular place with particular conventions. If you follow a printed calendar for your community’s observances, keep following it; use an app for your exact location and for everyday timings.
What astronomical algorithms are typically used?
Widely used published methods for the positions of the Sun and Moon, refined by astronomers for practical computation, give accuracy far beyond what calendar timings need. The exact choices vary by app.
Key terms
- On-device: calculated by the phone itself, without a server.
- Ephemeris: a table or formula giving the positions of the Sun, Moon and planets over time.
- Refraction: the bending of light by the atmosphere, which makes the Sun visible slightly before it rises geometrically.
- Time zone: the offset of local clock time from UTC; IST is UTC+5:30.