tzif_loader
This package is a utility to load IANA Time Zone database files from the local
filesystem into TzDatabase records that can be used by the tzif
time zone package.
Add to your project with the command:
gleam add tzif_loader@1
Installing the zoneinfo data files
Time zone information is frequently updated, therefore it makes sense to use the
package manager for your operating system to keep the time zone database up to
date. All common unix variants have time zone database packages and install the
time zone database files into the /usr/share/zoneinfo directory by default.
If, however, your system does not have time zone data installed, you can use
the zones package to install a database of
timezone data as a gleam library and dependency. To use the zones timezone
data get the database using the zones.database function rather than
loader.load_from_os or loader.load_from_path.
MacOS
The files should be included in your operating system by default. Check the
/usr/share/zoneinfo directory and see if they are present.
Ubuntu/Debian Linux Systems
The APT package manager can be used to install the compiled TZif files with the following command:
sudo apt install tzdata
Debian based docker containers
Installing and configuring the time zone database on a Debian or Ubuntu based
docker container can be done by adding the following to your Dockerfile:
# Use an ARG for the timezone, with a default of UTC
ARG TIMEZONE=Etc/UTC
# Set the TZ environment variable and install tzdata
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
ln -fs /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
apt-get install -y tzdata && \
dpkg-reconfigure --frontend noninteractive tzdata
Alpine Linux Systems
The Alpine Package Keeper can install the time zone database using the command:
sudo apk add tzdata
Alpine based docker containers
Installing and configuring the time zone database on an Alpine based docker
container can be done by adding the following to your Dockerfile:
# Use an ARG for the timezone, with a default of UTC
ARG TIMEZONE=Etc/UTC
# 1. Install the tzdata package
# 2. Copy the correct timezone file to /etc/localtime
# 3. Set the TZ environment variable to be used by applications
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
echo "${TIMEZONE}" > /etc/timezone
Red Hat/Rocky/Alma Linux Systems
You can use the YUM package manager or DNF to install the time zone database on Red Hat variants. To use YUM run the command:
sudo yum install tzdata
Similarly, using DNF:
sudo dnf install tzdata
Further documentation can be found at https://tzif-loader.hexdocs.pm/.