BlogForms

A country gives the timezone picker its options

Use Country.timezones to offer choices in an office-hours editor, then keep the selected zone or resolve the office's known coordinates.

An office-hours editor asks for a country before asking for a timezone. That is useful context for narrowing the choices. It becomes a problem when selecting a country silently sets the office's timezone to the first entry in a list.

The Country API includes timezones in its basic response. For GET /country/{code}, the field is an array of IANA timezone identifiers recorded for the country, or null when the list is unavailable. The identifiers give your editor values it can offer. Their position in the array isn't a determination of where the office is.

Build the menu from the returned list and ask the user to choose when there are several options. If the list has one entry, the editor can prefill that option and let the user confirm it. If the list is unavailable, keep a way to choose a timezone directly. None of those cases requires treating timezones[0] as the country's default clock.

For an office with known coordinates, ask a more specific question instead. This request uses API 2.0.0 and a fixed instant so its displayed offset can be reproduced:

GET /time?lat=34.0522&lon=-118.2437&at=2026-01-15T12:00:00Z
X-API-Version: 2.0.0

The Time API resolves that point to America/Los_Angeles. The following response excerpt omits the other clock and coordinate fields:

{
  "timezone": "America/Los_Angeles",
  "offset": "-08:00"
}

The country list answers which recorded zones belong in a country's choices. The coordinate lookup answers which zone applies at the supplied point. Use the latter to propose the office's timezone when you have its point, rather than replacing that location with a country-wide guess.

Save the chosen identifier as the office's timezone setting. The country and the timezone should remain separate values, so changing a display label or rearranging the options doesn't change the office's schedule. When the user changes the country, review the previous timezone choice with them instead of quietly installing the new list's first entry.