Posted by Almaz Mingajev – Software Engineer and Masha Khokhlova – Technical Program Manager
It's that time of year again when many of us change our clocks! Oh wait, your Android devices did it automatically, right? For Android users living in many countries, this may not be surprising. For example, the US, EU and UK governments have not changed their time laws for some time*so users wake up every morning to see the correct time.
But what happens when the laws of time change? Looking globally, governments can and do change their time laws, sometimes every year, and Android devices need to keep pace to support our global user base.
To implement a region's time law, Android devices must follow a set of coded rules. What are these rules? Let's start with why rules are necessary in the first place. Obviously, 7am in Los Angeles and 7am in London are not the same time. Furthermore, if you are in London and want to know the time in Los Angeles, you need to know how many hours to subtract, and this is not fixed all year round**. In order to determine local time (the time your watches should show), it's helpful to have a reference clock that everyone on the planet agrees on. This clock has a name UTC, coordinated universal time. Local time in London during winter matches is UTC, during summer it is calculated by adding one hour to UTC, usually called UTC+1. For Los Angeles, the local time in summer is UTC-8 (8 hours later, UTC deviation is -8 hours) and in winter it is UTC-7 accordingly. When a region changes from one offset to another, we call it a 'transition'. A combination of these shifts and rules when a transition occurs (such as “last Sunday in March” or “first Sunday on or after March 8”) defines a time zone. For some countries, the time zone rules can be very simple and mainly determined by their chosen UTC offset: “no transitions, we don't move our clocks forward and backward”.
Governments may decide to change the UTC offset for regions, introduce new time zone regions, or change the day on which daylight saving time transitions occur. When governments do this, time zone rules must be updated on each Android device, otherwise the Android device will continue to follow the old rules, which could result in users in affected areas being shown an incorrect local time.
Android isn't the only one that needs to keep track of this information. Fortunately, there is a database supported by IANA (Authority for assigned numbers over the Internet) and maintained by a small group of volunteers, known as the TZDB (Time Zone Database), which is used as the basis for local timekeeping on most modern operating systems. The TZDB contains most of the information Android needs.
There is no schedule, but typically the TZDB releases a new update 4-5 times a year. The Android team wants to release updates that affect its devices as quickly as possible.
How do these changes reach your devices?
1. The government signs a law/decree.
2. Someone inform IANA about these changes
3. Depending on how much lead time was given and changes announced by other countries, IANA will publish a new TZDB release.
4. The Android team is incorporating the TZDB release (along with a small amount of additional information we obtain from related projects and our own borrowings) into our codebase.
5. We are rolling out these updates to your devices. How the rollout takes place depends on the type and age of the Android device.
As you can see, there are quite a few steps. Applying, testing, and releasing an update can take weeks. And it's not just Android and other similar computer operating systems that need to take action. Usually there are telecom companies, banks, airlines and software companies that have to adapt their own systems and timetables. Citizens of a country need to be notified of changes so that they know what to expect, especially if they are using older devices that may not receive the necessary updates. And it all takes time and can cause problems for countless people if not handled properly. The degree of disruption caused by a change is usually determined by the clarity of the legislation and the notice period that governments provide. The TZDB volunteers are good at spotting changes, but it helps if governments notify IANA directly, especially if it is not clear exactly which regions or existing laws are affected. Unfortunately, many of the recent time zone changes were implemented with about a month's notice or less. Android has a set recommendations how much notice you need to give. Other operating systems have similar recommendations.
Android is constantly evolving. One of these improvements, Project Mainline, introduced in Android 10 has made a big difference in the way we update key parts of the Android operating system. It allows us to deliver select AOSP components directly through Google Play, making updates faster than a full OTA update and reducing duplication of effort from each OEM.
From the beginning, time zone rules were a feature in Mainline called Time zone data or tzdata module. This integration allowed us to respond to government-mandated time zone changes more quickly than before. However, until 2023, tzdata updates were still bundled with other Mainline changes, sometimes leading to testing complexity and slower deployment.
In 2023, we will have further invested in Mainline's infrastructure and disconnected the tzdata module from the other components. This isolation has given us the ability to quickly respond to changes in time zone laws, often releasing updates to Android users outside of the designated release frequency. Additionally, this change means that time zone updates can reach a much larger number of Android devices, so that as an Android user you always see the correct time.
So while your Android phone may not be able to recover that lost hour of sleep, you can rest assured that it will display the correct time, thanks to volunteers and the Android team.
Curious about the ever-changing world of time zones? Discover the IANA time zone database and learn more about how time and time zones are managed on Android.
*There were changes in Alaska in 2018-2019. This is a blog post, not technical documentation!
**Because the US and Great Britain apply their daylight saving time changes at different local times and on different days of the year.