Storing locations and timezones for calendar apps
October 9, 2026 · Updated November 9, 2026
Every value in a panchang depends on two facts about the user: where they are, which fixes sunrise and sunset, and which clock they live by, which turns instants into local times. Get either wrong and every date downstream can be off. This post covers how to collect, store and maintain both in a calendar app, with the trade-offs we have seen.
What to store
For each user (or each saved place, if users can save several):
type Place = {
label: string; // what the user picked, e.g. "Edison, New Jersey"
latitude: number; // decimal degrees, rounded (see below)
longitude: number;
timeZone: string; // IANA name, e.g. "America/New_York"
source: "search" | "device" | "manual";
updatedAt: string; // ISO timestamp
};Three rules matter more than the rest.
1. Store the IANA zone name, never an offset
"UTC−5" is right for New York in winter and wrong in summer. "EST" is ambiguous and not a zone. America/New_York captures the full history and future rules, including daylight saving, and lets your runtime compute the right offset for any date. See daylight saving pitfalls.
2. Do not derive the zone from the offset
A browser can report its current offset, but many zones share an offset with different DST rules. Use the zone name the platform gives you:
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone; // e.g. "Europe/London"On iOS use TimeZone.current.identifier; on Android ZoneId.systemDefault().id.
3. Store coordinates, not just a city name
City names are ambiguous (there are many Springfields), and sunrise depends on coordinates. Resolve the user's choice to latitude and longitude once, at selection time, and store the numbers.
How to collect it
City search is the friendliest default. A user types a city and picks from a list; you store the city's coordinates and zone. A geocoding dataset that includes IANA zones avoids a second lookup. Check the license and attribution requirements of whatever dataset you use.
Device location is convenient but should be optional. Ask for it only when the user chooses "use my location", explain why, and round before storing.
Manual coordinates help users in small towns that a city list misses. Validate ranges: latitude −90 to 90, longitude −180 to 180, and the zone against your runtime's list of IANA names.
How precise to be
Sunrise changes by about four seconds per kilometer east or west near the equator, and less in most other situations. Two decimal places of latitude and longitude, about one kilometer, change sunrise by seconds, well within any almanac tolerance.
Rounding helps in three ways:
- Privacy: a rounded point identifies an area, not a house.
- Caching: users in the same area share results.
- Stability: small GPS jitter does not create new cache entries.
Store the rounded values only. If you never had the precise location, you cannot leak it.
When the zone and the location disagree
A user in Detroit may have a phone set to Chicago time, or a traveler may keep their home zone. Decide which wins:
- For "today" views, use the zone of the place being shown, not the device zone. A family checking their parents' city wants that city's times.
- For reminders, schedule in the zone of the place the reminder is about, and let the OS show it in device time.
Show the zone abbreviation next to every time (14:32 EDT) so mismatches are visible.
Handling travel
Families travel, often to India for festivals. Options:
- Follow the device: recompute when the device zone or location changes. Accurate, but dates can move under the user's feet.
- Fixed home place: always show the saved place. Consistency over accuracy while traveling.
- Ask: when the device zone changes, offer "Show dates for your current location?"
Option 3 is usually best. Whichever you choose, make the active place visible on every screen: "Dates for Houston".
Keeping timezone data current
The IANA database changes several times a year as governments change rules. Your server runtime, your mobile apps and your data provider each bundle a copy, possibly different versions. Keep runtimes updated, log the version used for calculations, and prefer computing local times on the server with a known version for anything you store.
Multiple saved places
Many diaspora users want two calendars side by side: their own city and their parents' city in India, or a sibling's city on another continent. Model places as a list from the start, each with its own zone, and let users mark one as default. Cache results per place, not per user. When showing two places together, label each column with its city and zone, because the same festival can fall on different dates in each.
Privacy checklist
- Collect location only to compute the calendar, and say so.
- Round coordinates before storing or sending them to any third-party service.
- Keep a city label rather than an address.
- Let users delete saved places.
- Do not send anything else about the user to calendar data providers; the result depends only on place, date and settings. (This is why TithiKit's planned API takes no personal data at all; see why TithiKit never asks for a birth date.)
Summary
- Store IANA zone names and rounded coordinates, resolved once at selection time.
- Show the active place and zone abbreviation everywhere.
- Decide explicitly how travel works.
- Keep timezone data current and record its version.
TithiKit is a planned Hindu calendar API that takes coordinates and an IANA zone and returns the calendar in local time. Join early access for a key at launch.