Iran Daylight Saving on March 2023

The government of Iran has announced that daylight savings will not be observed from March 2023. But apparently, this issue has not been properly coordinated with international institutions. So this was cause of many issues on public services in Iran. We did some updates and configuration changes before 22nd March 2022 and I want to share the story with you.

Iran Daylight Saving
Daylight Saving

What Should Be Updated?

Actually, Time Zone Database must be at latest version before your country or region daylight saving and time change. So, you must keep update operating systems and software or firmware on devices.

Most organizations and companies using Windows and Linux for their services, both Linux and Windows have time zone database, and any related change will be update via operating system updates.

Update Linux Time Zone Database

Updating time zone database can be done by two methods in Linux.

First Method

Updating time zone database can be performed by operating system update via package manager and operating system repositories. This way is first method and best method. So, if your operating system is supported version by vendor, update time zone database via package manager or download related packages and install manually for offline servers or clients.

Latest version of time zone database has all previous changes and you’ll be sure about time zone changes.

As an example, you can update it on RHEL based Linux by using this command: yum update tzdata

Second Method

Time zone database can be updated without package manager by downloading time zone database from IANA and update manaully.

There are three compressed files:

  • Complete Distribution (Data, Code and Extras)
  • Data Only Distribution
  • Code Only Distribution

“Data Only Distribution” is enough for update.

The below instruction has affect on regular applications and you should update Java time zone database separately. The Java Runtime Environment (JRE) includes its own, slightly different, time zone database. Thus, when the time zone definitions change, the JRE should be updated as well. Oracle provides Timezone Updater Tool on this regard.

Update Instruction are as follows for operating system and regular applications:

Notes about this process:

  1. These “manual” changes WILL be lost if updates are applied to the system that do not contain the corrected time zone information. The time zone information is included in the time zone package. Applying older versions of this or related packages should be followed by re-applying these “manual” changes.
  2. These “manual” changes do not require a reboot of the system. Some applications may have cached information in memory and will not re-read these changes. A reboot may be useful to ensure all applications have read the updated time zone data.

Detailed steps for the manual process:

  1. Download the most recent time zone data file (at the time of writing, tzdata2007b.tar.gz) from ftp://ftp.iana.org/tz/releases/ . Updates to this data file have the year and release letter updated.
  2. Copy the file to a temporary workspace of your choice on the Linux system.
  3. Extract the data with the following command: “tar xvfz tzdata2007b.tar.gz”
  4. Apply the updates for the region(s) of interest the system’s time zone data through the zic command. E.g., to update the North American data, run zic northamerica
  5. Relink the new time zone names with the old time zone names that were just updated with the following command: (See the Additional Notes below for a workaround to possible error(s) in this step.) zic backward
  6. Verify that the updates are applied correctly with the following command: zdump -v timezoneofinterest | grep yearofintereste.gzdump -v Canada/Mountain | grep 2007,the output from the previous step should look similar to this:
    Canada/Mountain Sun Mar 11 08:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 MST isdst=0 gmtoff=-25200
    Canada/Mountain Sun Mar 11 09:00:00 2007 UTC = Sun Mar 11 02:00:00 2007 MST isdst=1 gmtoff=-21600
    Canada/Mountain Sun Nov 4 07:59:59 2007 UTC = Sun Nov 4 01:59:59 2007 MST isdst=1 gmtoff=-21600
    Canada/Mountain Sun Nov 4 08:00:00 2007 UTC = Sun Nov 4 02:00:00 2007 MST isdst=0 gmtoff=-25200
  7. Relink the localtime setting (in /etc/localtime) with the corrected timezone information using the following command: zic -l timezonename e.g. zic -l Canada/Mountain

Note: If you encounter error(s) executing zic backward
Executing zic backward may return errors if other time zone data is not recent enough. One option would be to update those time zone as well in the same manner as noted in step 4 after identifying the specific time zones involved.
A workaround in this situation is to extract only the time zones from backward that need to be re-linked following execution of step 4 above. In this case that would be the time zones that are listed in the northamerica file. The following steps can be substitued for step 5 above:

grep ‘America’ backward > backward.america
zic backward.america

Change related time zone name in the above commands.

Please consider that don’t use CP command to update /etc/localtime and use soft link always.

Update Windows Time Zone Database

Updating Windows time zone database is so complicated, and I strongly recommend that wait for Microsoft update. But as an alternative solution, if you have Active Directory and machines are joined to domain, disable daylight saving on servers and clients by GPO. If machines are workgroup disable it via registry or manually.

Create Customized Time Zone

Even after disabling daylight saving option on Windows, user will face with some issue on browsers. Browsers will display time incorrectly.

Still I recommend that wait for Microsoft update but if you accept the risks, you can make customized time zone via current time zones and import it to registry.

Time zone data stored on this path in registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones

You can export your current time zone as REG file and modifying time zone information and import it again.

There is TZI value that important value for time zone and define how system clock should acting and converting UTC to your local time.

The TZI value is a binary value stored in the Windows registry that represents the time zone information for a particular time zone. The TZI value consists of a 44-byte binary structure that contains the following fields:

typedef struct _REG_TZI_FORMAT
{
    LONG Bias;
    LONG StandardBias;
    LONG DaylightBias;
    SYSTEMTIME StandardDate;
    SYSTEMTIME DaylightDate;
} REG_TZI_FORMAT; 

  • Bias: The number of minutes the time zone is offset from UTC (Coordinated Universal Time).
  • StandardBias: The number of minutes the time zone’s standard time is offset from UTC.
  • DaylightBias: The number of minutes the time zone’s daylight saving time is offset from UTC.
  • StandardDate: A SYSTEMTIME structure that specifies the date and time when the time zone switches to standard time.
  • DaylightDate: A SYSTEMTIME structure that specifies the date and time when the time zone switches to daylight saving time.

The SYSTEMTIME structure has the following format:

typedef struct _SYSTEMTIME {
  WORD wYear;
  WORD wMonth;
  WORD wDayOfWeek;
  WORD wDay;
  WORD wHour;
  WORD wMinute;
  WORD wSecond;
  WORD wMilliseconds;
} SYSTEMTIME;

Each field in the SYSTEMTIME structure represents a component of a date or time. For example, wYear represents the year, wMonth represents the month, wDay represents the day of the month, wHour represents the hour, and so on.

Here’s an example TZI REG_BINARY value in PowerShell:

$tzi = [byte[]]@(0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)

This TZI value represents a time zone with a Bias of 16 minutes (or UTC-00:16), a StandardBias and DaylightBias of -1 minutes (or UTC-00:01), and no specified start or end dates for daylight saving time.

You can also find information about any TZI value in registry by using this PowerShell script:

Replace the bytes in the first line of the script with the TZI value in REG_BINARY format that you want to convert. The output of the script will include the time zone’s standard bias from UTC, standard offset from UTC, daylight saving time bias from UTC, and start times for both standard and daylight saving time.

Iran Customized Time Zone – No Daylight Saving

I’ve created customized time zone for using in Windows for Iran standard time and you can use it but using it at own risk.

Conclusion

Operating system’s clock is based on UTC and time zone convert UTC to local time. Any changes from governments need to changes on time zone database by international organizations and also provides updates from OS vendors.

In addition of my story and my experiences, I hope that post useful for other administrators and help them to be prepared for same time zone changes in future.

Further Reading

Create Your Own Time Zone in Linux

Network Time System Software

NTP Software Implementations Comparison

Configure NTP on iLO via HPE Scripting Tools for Windows PowerShell

Linux KickStart – Automated Installation

Davoud Teimouri

Professional blogger, vExpert 2015/2016/2017/2018/2019/2020/2021/2022/2023, vExpert NSX, vExpert PRO, vExpert Security, vExpert EUC, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

1 Response

  1. David Refoua says:

    Great article, would also appreciate any information on updating Android’s tz data as well.

Leave a Reply

Your email address will not be published. Required fields are marked *