Corrigindo manualmente o horário de verão brasileiro no Linux

De Wiki Hackstore

Devido aos FILHOS DA PUTA do governo, que alteraram o horário de verão EM CIMA DA HORA por causa de uma porra de uma data de um ENEM, será necessário criar manualmente o arquivo de timezone visto que a IANA ainda não disponibilizou o arquivo atualizado. É de cair o cu da bunda, mas vamos lá.....

Crie um arquivo para o novo timezone brasileiro com o seguinte conteúdo:

Rule Brazil 2017 only - Feb 19 00:00 0 -
Rule Brazil 2017 only - Oct 15 00:00 1 S
Rule Brazil 2018 only - Feb 18 00:00 0 -
Rule Brazil 2018 only - Nov 04 00:00 1 S
Rule Brazil 2019 only - Feb 17 00:00 0 -
Rule Brazil 2019 only - Oct 20 00:00 1 S
Rule Brazil 2020 only - Feb 16 00:00 0 -
Rule Brazil 2020 only - Oct 18 00:00 0 -
Rule Brazil 2021 only - Feb 21 00:00 0 -
Rule Brazil 2021 only - Oct 17 00:00 1 S
Rule Brazil 2022 only - Feb 20 00:00 0 -
Rule Brazil 2022 only - Oct 16 00:00 1 S
Rule Brazil 2023 only - Feb 26 00:00 0 -
Rule Brazil 2023 only - Oct 15 00:00 1 S
Rule Brazil 2024 only - Feb 18 00:00 0 -
Rule Brazil 2024 only - Oct 20 00:00 1 S
Rule Brazil 2025 only - Feb 16 00:00 0 -
Rule Brazil 2025 only - Oct 19 00:00 1 S
Rule Brazil 2026 only - Feb 22 00:00 0 -
Rule Brazil 2026 only - Oct 18 00:00 1 S
Rule Brazil 2027 only - Feb 21 00:00 0 -
Rule Brazil 2027 only - Oct 17 00:00 1 S
Rule Brazil 2028 only - Feb 20 00:00 0 -
Rule Brazil 2028 only - Oct 15 00:00 1 S
Rule Brazil 2029 only - Feb 18 00:00 0 -
Rule Brazil 2029 only - Oct 21 00:00 1 S
Rule Brazil 2030 only - Feb 17 00:00 0 -
Rule Brazil 2030 only - Oct 20 00:00 0 -
Rule Brazil 2031 only - Feb 16 00:00 0 -
Rule Brazil 2031 only - Oct 19 00:00 1 S
Rule Brazil 2032 only - Feb 15 00:00 0 -
Rule Brazil 2032 only - Oct 17 00:00 1 S
Rule Brazil 2033 only - Feb 20 00:00 0 -
Rule Brazil 2033 only - Oct 16 00:00 1 S
Rule Brazil 2034 only - Feb 26 00:00 0 -
Rule Brazil 2034 only - Oct 15 00:00 1 S
Rule Brazil 2035 only - Feb 18 00:00 0 -
Rule Brazil 2035 only - Oct 21 00:00 1 S
Rule Brazil 2036 only - Feb 17 00:00 0 -
Rule Brazil 2036 only - Oct 19 00:00 1 S
Rule Brazil 2037 only - Feb 22 00:00 0 -
Rule Brazil 2037 only - Oct 18 00:00 1 S
Rule Brazil 2038 only - Feb 21 00:00 0 -
Rule Brazil 2038 only - Oct 17 00:00 1 S
Zone Brazil/East -3:00 Brazil BR%sT

Crie o arquivo de timezone, como root:

# zic arquivo.zic

Configure o novo timezone:

# rm -f /etc/localtime ; ln -s /usr/share/zoneinfo/Brazil/East /etc/localtime

Confira se está tudo ok:

# zdump -v /etc/localtime | egrep '2018|2019' | egrep 'Sun Nov  4|Feb 16'

A saída correta para 2018/2019 é:

/etc/localtime  Sun Nov  4 02:59:59 2018 UT = Sat Nov 17 23:59:59 2018 BRT isdst=0 gmtoff=-10800
/etc/localtime  Sun Nov  4 03:00:00 2018 UT = Sun Nov  4 01:00:00 2018 BRST isdst=1 gmtoff=-7200
/etc/localtime  Sun Feb 17 01:59:59 2019 UT = Sat Feb 16 23:59:59 2019 BRST isdst=1 gmtoff=-7200
/etc/localtime  Sun Feb 17 02:00:00 2019 UT = Sat Feb 16 23:00:00 2019 BRT isdst=0 gmtoff=-10800


Caso queira automatizar e utilizar um arquivo pronto disponibilizado pelo Área31 Hackerspace:

DAYS=$(zdump -v /etc/localtime | egrep '2018|2019' | egrep 'Sun Nov  4|Feb 16'|wc -l)

if [ ${DAYS} != "4" ]; then
        echo "corrigindo horário de verão"
        mv /usr/share/zoneinfo/America/Sao_Paulo /usr/share/zoneinfo/America/Sao_Paulo.old
        wget https://area31.net.br/downloads/localtime-america-saopaulo-2018-brazil -O /usr/share/zoneinfo/America/Sao_Paulo
        rm -f /etc/localtime
        ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
        zdump -v /etc/localtime | egrep '2018|2019' | egrep 'Sun Nov  4|Feb 16'
fi