Skip to content

Instantly share code, notes, and snippets.

@noquierouser
Forked from tgirardi/os-x-update-tzdata.sh
Last active January 30, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noquierouser/69a12371db4f129e70f495c28060deeb to your computer and use it in GitHub Desktop.
Save noquierouser/69a12371db4f129e70f495c28060deeb to your computer and use it in GitHub Desktop.
Actualiza los datos de tzdata e ICU en OS X para arreglar problemas con información de zonas horarias obsoletas. Necesita reiniciar el equipo después de aplicarse.
#!/bin/bash
# author: Tomás Girardi
# Based on http://helw.net/2011/04/28/updating-osx-for-egypts-dst-changes/ by Ahmed El-Helw
# CHANGE THIS:
# go to https://www.iana.org/time-zones and get the URL for the last DATA
# release
URLTZDATASRC=https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz
# BACKUP your current icu file first
cp /usr/share/icu/*.dat ~
ICUVERSION=`ls /usr/share/icu/*.dat | grep -o "\(\d\d\)l\.dat" | grep -o "^\d\d"`
URLICUSRC="http://download.icu-project.org/files/icu4c/${ICUVERSION}.1/icu4c-${ICUVERSION}_1-src.zip"
### update tzdata
cd /tmp
mkdir tzdata
cd tzdata
curl -O "${URLTZDATASRC}"
tar -xzf tzdata-latest.tar.gz
sudo zic africa
sudo zic antarctica
sudo zic asia
sudo zic australasia
sudo zic backward
sudo zic etcetera
sudo zic europe
sudo zic factory
sudo zic northamerica
sudo zic pacificnew
sudo zic southamerica
sudo zic systemv
### update ICU data
cd /tmp
mkdir icu4c
cd icu4c
curl "${URLICUSRC}" -O icusrc.tar.gz
tar xzf icusrc.tar.gz
cd icu/source/tools/tzcode
# ./icuSources/tools/tzcode/readme.txt tells us that placing a tzdata
# file in the tzcode directory will compile with that zoneinfo database
# download latest tzdata
curl -O "${URLTZDATASRC}"
cd ../..
# compile
./runConfigureICU MacOSX --with-data-packaging=archive
gnumake
# replace the data file only
sudo install -o root -g wheel -m 0644 -Sp "data/out/icudt${ICUVERSION}l.dat" "/usr/share/icu/icudt${ICUVERSION}l.dat"
# NOW REBOOT!!!
@noquierouser
Copy link
Author

Agregué cambios para poder utilizar el tzdata-latest de la IANA, y así siempre actualizar a los últimos datos disponibles.

@noquierouser
Copy link
Author

He actualizado el script para que utilice curl -O en vez de wget, ya que aparentemente wget no viene por omisión en macOS. Gracias a Fabián en 8gigas.com por apuntar sobre esto, además de agregar que esto requiere tener Xcode instalado, al menos las herramientas CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment