Time in phones: what and how it works

Surely many noticed problems with the readings of the built-in clock. Someone may have noticed oddities with the display of time related to SMS. This is especially noticeable immediately after the days when in many countries there is a transition to winter or summer time.
To understand how all this works, you will need to dig a little into the architecture. Let's try to figure out why such problems can occur, which affects the time, and what can be done if the phone suddenly started to show the wrong time.
Standard time
About what the geographical and administrative “time zones” or “time zones” are, as it is now called in Federal Law No. 107-FZ of 2011 “On the Calculation of Time,” I will not talk about it because it is on Wiki.
From this basic information, it is important to remember that the difference between the standard time and the “universal” (UTC) (in everyday life equivalent to the “Greenwich” - GMT) is the result of purely administrative actions of the authorities. What difference will be assigned to a particular locality of power, so it will be. First, let's try to figure out the functions of time processing in network equipment.
Time and SMS
In the text message sent from the telephone (SMS-SUBMIT), there is no place for time information at all.
Only at the moment a message arrives at the SMS center, it acquires a time stamp field - TP-Service-Center-Time-Stamp (TP-SCTS), consisting of 7 octets with rearranged half-octets (GSM 03.40, TS 23.040) and represent the information in binary decimal code (BCD), that is, each half octet encodes one digit.
The first 6 octets represent the year, month, day, hour, minute, and second of the local time of the sender.
The seventh octet contains information about the time zone, and indicates the difference between local time and UTC (GMT). The unit of time difference is the 15 minute interval, and the third bit (the most significant in the right half octet) indicates the algebraic sign of the difference (“0” is positive, “1” is negative).
“Summer time” should be taken into account in the meaning of the time zone information. For example, in the UK, the time zone octet value is 00000000b (UTC + 00: 00) during winter time, and 01000000b (4 x 15 minutes, that is, UTC + 01: 00) during summer time.
In the structure of a short message delivered to the recipient’s telephone (SMS-DELIVER), information about the time of arrival of the message to the SMS center is already present, and can be used by the phone when the user is displayed information about the message.
What information about the current time the mobile network can tell the phone
In 1996, in the GSM specifications (GSM 02.42, 04.08, etc.), tools appeared that allowed mobile operators to deliver information on the date, time and time zone to their phones. For this, in the signaling messages intended for Mobility Management, there are several information elements that can be used by the operator at his discretion, since they are optional.
First of all, this is the IE “Time Zone and Time” information element . It contains the entire complex of data (year, month, day, hour, minutes and seconds) indicating the moment when the network transmits an alarm message, as well as a value indicating the time zone in which the base station is located.
The values of the year, month, day, hour, minutes and seconds, as in the case of SMS, are transmitted in BCD encoding with rearrangement of half octets, but unlike the timestamp of the SMS center, they indicate universal time (UTC), not local!
The part of the information element indicating the time zone is transmitted in the same encoding as in the case of the time stamp of the SMS center.
Here is how the block of information transferred to the phone at a particular point in time looks like:
Octet value / interpretation
47 Код, означающий, что дальше идут 7 октетов IE «Time Zone and Time»
11 YEAR: 11
20 MONTH: 02
71 DAY: 17
70 HOUR: 07
71 MINUTE: 17
30 SECOND: 03
21 TIME ZONE: 12 = GMT+03:00
49 Код, означающий, что дальше идет IE «Daylight Saving Time»
01 Длина IE «Daylight Saving Time» = 1 октету
00 Значение, указывающее отсутствие сдвига из-за «летнего времени»Since in this information element the network transmits the value of “universal time” - UTC, in order for the phone to display local time, it must adjust the UTC by the value corresponding to the time offset in the time zone in which the phone is located. In this particular case, the case took place in Moscow, even before the adoption of the law "On the calculation of time" and the cancellation of the transition to winter time.
Thus, the time transmitted by the network corresponded to 10 hours 17 minutes and 3 seconds in the morning of Moscow time on February 17, 2011. For comparison, the block of information transmitted to the phone recently:
The value of the octet / its interpretation
47 Код, означающий, что дальше идут 7 октетов IE «Time Zone and Time»
21 YEAR: 12
40 MONTH: 04
81 DAY: 18
80 HOUR: 08
45 MINUTE: 54
44 SECOND: 44
61 TIME ZONE: 16 = GMT+04:00
49 Код, означающий, что дальше идет IE «Daylight Saving Time»
01 Длина IE «Daylight Saving Time» = 1 октету
00 Значение, указывающее отсутствие сдвига из-за «летнего времени»
Этот информация была передана в Москве в 12:54:44 18 апреля 2012 года.In addition to the “Time Zone and Time” information element, the specifications also provide for a separate 8-bit information element designed to transmit information about the time zone only ( “Time Zone” IE ).
The information in it is encoded in the same way as the value of the time zone at the mark of the SMS center.
However, it makes little sense to transmit “Time Zone” along with “Time Zone and Time”.
There is also a separate information element ( “Daylight Saving Time” IE ), which, if transmitted, indicates the value of the time shift caused by the use of “summer time”, which was taken into account when calculating the value of the time zone field.
A specific value may indicate the absence of a shift (“00b”), a shift of +1 hour (“01b”), and a shift of even +2 hours (“10b”).
According to the GSM / 3GPP specifications, time information should be delivered to a mobile phone as soon as possible, when the telephone is registered on the network, the time zone changes, or the switch to summer or winter time is performed.
Thus, using the means described above, the network can supply the telephones with all the information necessary for the correct installation and indication of the current time, as well as the time associated with short messages.
But, according to the provisions of the standards, the use of this information is intended solely at the discretion of the phone manufacturer .
However, users may experience some problems for reasons completely or partially independent of the phones and their manufacturers.
For example, an SMS center serving several time zones must take into account the time at the location of the sending telephone. Otherwise, the SMS sending time will be fixed with an error equal to the time difference in the time zones where the SMS center and the sending phone are located. In areas located near the borders of time zones, the operator must ensure that the base stations transmit the value of the time zone in whose territory the base stations are located. Of course, operators take these features into account when planning and setting up the network.
However, due to the laws of propagation of radio waves, operators cannot give a full guarantee of the correctness of the time information delivered to the telephone. After all, a phone located near the administrative border of time zones can receive signals and use information about the date and time from base stations located in the neighboring time zone and transmitting relevant information.
For the same reason, the SMS center may incorrectly determine the time zone where the telephone is actually located if the SMS was transmitted through a base station located in the neighboring time zone.
In addition, short-term problems are potentially possible due to the fact that the software of the network equipment and SMS centers will automatically switch to summer / winter time in spite of the new Russian realities, or it was incorrectly configured at the time of commissioning. But such "nuances" are usually quickly corrected by maintenance personnel.
Other sources of time and place information
There are other channels for delivering information about the date, time and place of stay in mobile phones.
Many phones have navigator functionality and can use time and location information from positioning systems (GPS, GLONASS, etc.).
Phones (tablets) connected to the Internet can use additional time information using NTP or SNTP, as well as information about the location of the “binding” of public IP addresses.
Along with the manual settings of the time and time zone, such an abundance of initial information in some cases can cause problems for the phone with a choice - what information about the time and location to use.
How phones use time information
In phones, the clock first appeared in a fairly simple configuration - it simply showed the time on the display. In case of moving or changing the time to summer or winter, it was enough just to set the clock in accordance with the new realities.
Naturally, the possibility of manually setting the date and time parameters in the phones is preserved at the present time.
In manual settings, the user himself enters the current date, time and location (time zone) and is responsible for the accuracy of the entered information.
It would seem that everything is simple and unambiguous?
But in the manual configuration option, problems may arise if the phone’s software has an incorrect correspondence between the time zone and the city that the user specified as his location.
If you use the wrong value for the time zone, subsequently, when moving to another city / country and the corresponding change in the value of the time zone, you may find that the time in the phone is different from the real administrative time in a new place.
As the performance of processors and the capacity of memory elements increased, phones began to incorporate more and more complex functions related to time, dates and calendar.
And now the situation with the automatic mode for setting the date and time looks much more interesting.
If the GSM / UMTS mobile communication network in which the telephone is registered does not transmit information about the current date and time, then the telephone should seem to display the data entered by the user in manual mode, despite the fact that the automatic mode is set. However, it cannot be completely ruled out that developers of some models may use information from positioning systems or from the Internet.
In cases where the operator in the signal traffic transmits information about the date, time and time zone, the most logical way would be to use this information - to display the local time calculated on the basis of the UTC values and the time zone shift received from the operator.
However, in practice, some manufacturers (their software developers) began to take not always a reasonable initiative in attracting other sources of information. For example, it was noticed that in the automatic time correction mode, some models, for some reason, instead of using the time zone information transmitted by the network, use the value set by the user in the manual setting mode!
In connection with the change of time zones in the Russian Federation under Federal Law No. 107-ФЗ of 2011 “On Calculation of Time”, in phones whose software was developed earlier, data on time zones in many Russian cities have now become incorrect. As a result, if such a phone uses the value set in the manual settings instead of the information about the time zone received from the network, it may display the time incorrectly.
Obviously, the phone manufacturer should be responsible for correcting such errors, which is responsible for using the information received from the operator.
However, in the face of fierce competition, manufacturers, seeking to ensure the release of more and more new models, quickly stop making changes to the software of previously released models.
In such cases, the manual setting of the time zone value, adjusted in accordance with the above Federal Law, can help.
For example, for Moscow, you can set not the old value UTC + 03: 00, but UTC + 04: 00, without paying attention to the name of the city (for example, Baku, Yerevan or Tbilisi).
Some older phones may display the time incorrectly because they treat the time value received from the network as local rather than universal time. Obviously, in this case as well, only the manufacturer could fix the problem by developing a new version of the software. The truth is hard to hope for.
Some problems with the interpretation of the time of sending SMS are also known. The recipient telephone receives in SMS information about the local time and time zone in which the sending telephone was located on one side, as well as the UTC and time zone values from the network at the SMS receiving location.
Further, the recipient phone can do with this information everything that is intended by the manufacturer - the way it will process all this information before showing it to the owner, the standards are attributed exclusively to the responsibility of the phone manufacturer.
Unfortunately, the software developers of some models made mistakes when processing the parameters of the SMS sending time, and they mislead the user.
Without claiming to be an exhaustive description of all the possible problems with time display, I tried to describe the mechanisms, the knowledge of which can help to understand the causes of the problem in a particular case and find an acceptable solution.