X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=build%2Fzoneinfo2lua.pl;h=1a0bee1c68afb4722531538b046950c6c707e4c5;hp=7e772c0aff39c1d52dfd536e8d00a699b31ae8b2;hb=94ea9077076d98374a331131fb7c9fc57df370a6;hpb=cbdc5af52ef0eeae955753ab0a8a0df650027b55 diff --git a/build/zoneinfo2lua.pl b/build/zoneinfo2lua.pl old mode 100644 new mode 100755 index 7e772c0af..1a0bee1c6 --- a/build/zoneinfo2lua.pl +++ b/build/zoneinfo2lua.pl @@ -1,14 +1,17 @@ #!/usr/bin/perl # zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo -# Execute from within /usr/share/zoneinfo +# Execute from within root of Luci feed, usually feeds/luci # $Id$ use strict; my %TZ; +my $tzdin = $ARGV[0] || "/usr/share/zoneinfo"; +my $tzdout = $ARGV[1] || "./modules/luci-base/luasrc/sys/zoneinfo"; + local $/ = "\012"; -open( ZTAB, "< ./zone.tab" ) || die "Unable to open zone.tab: $!"; +open( ZTAB, "< $tzdin/zone.tab" ) || die "open($tzdin/zone.tab): $!"; while( ! eof ZTAB ) { chomp( my $line = readline ZTAB ); @@ -18,7 +21,7 @@ while( ! eof ZTAB ) { printf STDERR "%-40s", $zone; - if( open ZONE, "< ./$zone" ) { + if( open ZONE, "< $tzdin/$zone" ) { seek ZONE, -2, 2; while( tell(ZONE) > 0 ) { @@ -37,36 +40,69 @@ while( ! eof ZTAB ) { } else { - print STDERR "Unable to open $zone: $!\n"; + print STDERR "open($tzdin/$zone): $!\n"; } } close ZTAB; +# Add Etc/GMT zones from manually as they are not in zone.tab +$TZ{"Etc/GMT"} = "GMT0"; +$TZ{"Etc/GMT-1"} = "<+01>-1"; +$TZ{"Etc/GMT-2"} = "<+02>-2"; +$TZ{"Etc/GMT-3"} = "<+03>-3"; +$TZ{"Etc/GMT-4"} = "<+04>-4"; +$TZ{"Etc/GMT-5"} = "<+05>-5"; +$TZ{"Etc/GMT-6"} = "<+06>-6"; +$TZ{"Etc/GMT-7"} = "<+07>-7"; +$TZ{"Etc/GMT-8"} = "<+08>-8"; +$TZ{"Etc/GMT-9"} = "<+09>-9"; +$TZ{"Etc/GMT-10"} = "<+10>-10"; +$TZ{"Etc/GMT-11"} = "<+11>-11"; +$TZ{"Etc/GMT-12"} = "<+12>-12"; +$TZ{"Etc/GMT-13"} = "<+13>-13"; +$TZ{"Etc/GMT-14"} = "<+14>-14"; +$TZ{"Etc/GMT+1"} = "<-01>1"; +$TZ{"Etc/GMT+2"} = "<-02>2"; +$TZ{"Etc/GMT+3"} = "<-03>3"; +$TZ{"Etc/GMT+4"} = "<-04>4"; +$TZ{"Etc/GMT+5"} = "<-05>5"; +$TZ{"Etc/GMT+6"} = "<-06>6"; +$TZ{"Etc/GMT+7"} = "<-07>7"; +$TZ{"Etc/GMT+8"} = "<-08>8"; +$TZ{"Etc/GMT+9"} = "<-09>9"; +$TZ{"Etc/GMT+10"} = "<-10>10"; +$TZ{"Etc/GMT+11"} = "<-11>11"; +$TZ{"Etc/GMT+12"} = "<-12>12"; + +open(O, "> $tzdout/tzdata.lua") || die "open($tzdout/tzdata.lua): $!\n"; + +print STDERR "Writing time zones to $tzdout/tzdata.lua ... "; +print O < $tzdout/tzoffset.lua") || die "open($tzdout/tzoffset.lua): $!\n"; -foreach my $zone ( sort keys %TZ ) { - printf "\t{ '%s', '%s' },\n", $zone, $TZ{$zone} -} +print STDERR "Writing time offsets to $tzdout/tzoffset.lua ... "; +print O <