Skip to content

Instantly share code, notes, and snippets.

@Tes3awy
Last active April 28, 2023 11:57
Show Gist options
  • Save Tes3awy/e4ba708ae063c84c34bb8e90c179cad2 to your computer and use it in GitHub Desktop.
Save Tes3awy/e4ba708ae063c84c34bb8e90c179cad2 to your computer and use it in GitHub Desktop.
Check and update tzdata

Check and update tzdata

Brief

The Egyptian government announced in March 2023 the return of DST (Daylight Saving Time). Thus, on April, 27th 23:59:59 midnight, this announcement will have an impact on all NTP-synced networks.

To begin with, since all time calculations on NTP servers are done in UTC (Coordinated Universal Time), a NTP server does not directly deal with time zones, but it does indirectly assist in maintaining accurate time across different time zones. By using NTP to synchronize the clocks of clients with an accurate UTC reference, it ensures that clients in different time zones have a consistent and accurate time base to work from. As you should never change time manually, unless there is no other way to do it, you need to let the NTP server handle this update to sync all clients within a network.

Fortunately, the TZ database is regularly updated. On March 28th, 2023 an update release (2023c) that handles the Egyptian DST change, was published on the internet by IANA. Check Time Zone Database update

What is the TZ database?

The Time Zone Database (usually referred to as tz, zoneinfo, tzdata) contains both code and data that represent the history of locale time for many representative locations around the globe. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules. Its management procedure is documented in BCP 175.

So, is there any way to update the TZ database? Definitely, yes.

In the reamining part of the gist, I'll go through updating the TZ database on Ubuntu assuming NTP, chrony, service is enabled and running on appropriate server and/or clients and UDP port 123 is allowed if ufw is enabled.

On all Linux distributions, tzdata is a package that is available to handle time zone and daylight-saving time data.

A new upstream release (LP#2012599) upgrades the TZ database on April 3rd, 2023. Check the tzdata package changelog.

Yet, before updating the TZ database, you are strongly advised to do some checks (Not required but recommended):

The following procedures are almost the same on other Linux distros (Such as RHEL, Oracle Linux, etc)

Steps

  1. Check tzdata version.
  2. Check current timezone (Africa/Cairo).
  3. Update tzdata package. Required
  4. Check the new update.

Check tzdata version

Typically, on fresh Ubuntu installations, you get tzdata package installed automatically.

$ sudo apt list -a tzdata
Listing... Done
tzdata/jammy-updates,jammy-security,now 2022g-0ubuntu0.22.04.1 all [installed,automatic]
tzdata/jammy 2022a-0ubuntu1 all

As noticed here, the tzdata installed version is 2022g

If the version installed is 2023c, you can skip the rest of the gist.

If not installed, run

$ sudo apt install -y tzdata

Check current timezone

$ sudo timedatectl status
<output_truncated>
                Time zone: Africa/Cairo (EET, +0200)
<output_truncated>

If not Africa/Cairo, then you need to set it to using

$ sudo timedatectl set-timezone Africa/Cairo

You need to check if tzdata includes the latest update or not. The zdump is a shell program that prints the current time in each timezone named on the command line.

$ zdump -v Africa/Cairo
<output_truncated>
Africa/Cairo  Thu May 15 22:00:00 2014 UT = Fri May 16 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 20:59:59 2014 UT = Thu Jun 26 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 21:00:00 2014 UT = Thu Jun 26 23:00:00 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 21:59:59 2014 UT = Thu Jul 31 23:59:59 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 22:00:00 2014 UT = Fri Aug  1 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 20:59:59 2014 UT = Thu Sep 25 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 21:00:00 2014 UT = Thu Sep 25 23:00:00 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  9223372036854689407 = NULL
Africa/Cairo  9223372036854775807 = NULL

As you might have noticed in the output, the last time DST has been adjusted in tzdata package version 2022g was in 2014 and no future DST updates are listed.

So, how can I update the TZ database? You can easily do the update.

Update tzdata package

$ sudo apt update && sudo apt upgrade -y tzdata

In order to avoid any breaking changes, only the tzdata package is upgraded in case the NTP server is running other services (which is not recommended by the way)

Check the tzdata new update

$ zdump -v Africa/Cairo | grep -E '2014|2023'
Africa/Cairo  Thu May 15 21:59:59 2014 UT = Thu May 15 23:59:59 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu May 15 22:00:00 2014 UT = Fri May 16 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 20:59:59 2014 UT = Thu Jun 26 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Jun 26 21:00:00 2014 UT = Thu Jun 26 23:00:00 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 21:59:59 2014 UT = Thu Jul 31 23:59:59 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Jul 31 22:00:00 2014 UT = Fri Aug  1 01:00:00 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 20:59:59 2014 UT = Thu Sep 25 23:59:59 2014 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Sep 25 21:00:00 2014 UT = Thu Sep 25 23:00:00 2014 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Apr 27 21:59:59 2023 UT = Thu Apr 27 23:59:59 2023 EET isdst=0 gmtoff=7200
Africa/Cairo  Thu Apr 27 22:00:00 2023 UT = Fri Apr 28 01:00:00 2023 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Oct 26 20:59:59 2023 UT = Thu Oct 26 23:59:59 2023 EEST isdst=1 gmtoff=10800
Africa/Cairo  Thu Oct 26 21:00:00 2023 UT = Thu Oct 26 23:00:00 2023 EET isdst=0 gmtoff=7200

You can now see that DST for 2014 (previously displayed for version 2022g) and for 2023 are now displayed. DST for FY23 starts from Friday April, 28th and ends on Thursday October, 26th.

This update can be deployed for the following Ubuntu releases:

  1. Bionic 18.04 LTS
  2. Focal 20.04 LTS
  3. Jammy 22.04 LTS
  4. Kinetic 22.10
  5. Lunar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment