miércoles, 14 de mayo de 2014

[OpenWRT] Agregar Timezone de America/Santiago


Código tzdata de America/Santiago actualizado al 2014:

CLT4CLST,M9.1.0/0,M4.4.0/0


vi /usr/lib/lua/luci/sys/zoneinfo/tzdata.lua

Agregar:

        { 'America/Santarem', 'BRT3' },
      + { 'America/Santiago', 'CLT4CLST,M9.1.0/0,M4.4.0/0' },
        { 'America/Santo Domingo', 'AST4' },




vi /usr/lib/lua/luci/sys/zoneinfo/tzoffset.lua

Agregar:

        wft   =  43200, -- WFT
      + clt   = -14400, -- CLT
      + clst  = -10800, -- CLST

}    



Después es necesario reiniciar.
Done!



Para entender como crear la estructura, les dejo un fragmento del manual de "tzset":

    std offset dst [offset],start[/time],end[/time]

There are no spaces in the specification. The initial std and offset specify the standard timezone, as described above. The dst string and offset specify the name and offset for the corresponding daylight saving timezone. If the offset is omitted, it default to one hour ahead of standard time.

The start field specifies when daylight saving time goes into effect and the end field specifies when the change is made back to standard time. These fields may have the following formats:

...

Mm.w.d

This specifies day d (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12). Week 1 is the first week in which day d occurs and week 5 is the last week in which day d occurs. Day 0 is a Sunday.
The time fields specify when, in the local time currently in effect, the change to the other time occurs. If omitted, the default is 02:00:00.


[http://linux.die.net/man/3/tzset]


y... ¿por qué no aparece?

La razón, por la que Santiago no aparece en el listado de zonas horarias, se debe a que el archivo de zoneinfo, correspondiente a Santiago, no contiene la estructura que se detalló al comienzo de este post.

Existe un script, utilizado por LuCi ("zoneinfo2lua.pl"), para rescatar las estructuras de forma automática a fin de generar el listado de zonas horarias, pero al no dar con la información, descarta dichas zonas como la de Santiago (ya que hay otras que tienen el mismo problema)

El archivo de Santiago no tiene la información requerida:

(últimos bytes de /usr/share/zoneinfo/America/Santiago)
00023b0: ffff bdba 0000 ffff bdba 0004 ffff b9b0 ................
00023c0: 0008 ffff c7c0 0008 ffff c7c0 010c ffff ................
00023d0: b9b0 0008 ffff c7c0 010c ffff d5d0 010c ................
00023e0: ffff c7c0 0008 4c4d 5400 534d 5400 434c ......LMT.SMT.CL
00023f0: 5400 434c 5354 0000 0000 0000 0101 0101 T.CLST..........
0002400: 0000 0000 0001 0101 010a0a              ...........


TZ -> ""


Pero, por ejemplo, el archivo de "Santa Isabel" si lo tiene:

(últimos bytes de /usr/share/zoneinfo/America/Santa_Isabel)
00008d0: 0004 ffff 8f80 0008 ffff 9d90 010c ffff ................
00008e0: 9d90 0110 ffff 9d90 0114 4c4d 5400 4d53 ..........LMT.MS
00008f0: 5400 5053 5400 5044 5400 5057 5400 5050 T.PST.PDT.PWT.PP
0000900: 5400 0000 0000 0001 0000 0000 0001 0a50 T..............P
0000910: 5354 3850 4454 2c4d 342e 312e 302c 4d31 ST8PDT,M4.1.0,M1
0000920: 302e 352e 300a                          0.5.0.


TZ -> "PST8PDT,M4.1.0,M10.5.0"

Espero que se haya entendido.