Changeset 6666
- Timestamp:
- 01/02/11 18:52:06 (2 years ago)
- Files:
-
- 1 modified
-
luci/trunk/build/zoneinfo2lua.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/build/zoneinfo2lua.pl
r6665 r6666 7 7 8 8 my %TZ; 9 my $tzdir = $ARGV[0] || "/usr/share/zoneinfo";10 9 11 chdir($tzdir) || die "chdir($tzdir): $!\n"; 10 my $tzdin = $ARGV[0] || "/usr/share/zoneinfo"; 11 my $tzdout = $ARGV[1] || "./libs/sys/luasrc/sys/zoneinfo"; 12 12 13 13 local $/ = "\012"; 14 open( ZTAB, "< ./zone.tab" ) || die "Unable to open zone.tab: $!";14 open( ZTAB, "< $tzdin/zone.tab" ) || die "open($tzdin/zone.tab): $!"; 15 15 16 16 while( ! eof ZTAB ) { … … 22 22 printf STDERR "%-40s", $zone; 23 23 24 if( open ZONE, "< ./$zone" ) {24 if( open ZONE, "< $tzdin/$zone" ) { 25 25 seek ZONE, -2, 2; 26 26 … … 41 41 else 42 42 { 43 print STDERR " Unable to open $zone: $!\n";43 print STDERR "open($tzdin/$zone): $!\n"; 44 44 } 45 45 } … … 48 48 49 49 50 print <<HEAD; 50 open(O, "> $tzdout/tzdata.lua") || die "open($tzdout/tzdata.lua): $!\n"; 51 52 print STDERR "Writing time zones to $tzdout/tzdata.lua ... "; 53 print O <<HEAD; 51 54 --[[ 52 55 LuCI - Autogenerated Zoneinfo Module … … 60 63 ]]-- 61 64 62 module "luci.sys.zoneinfo "65 module "luci.sys.zoneinfo.tzdata" 63 66 64 67 TZ = { … … 66 69 67 70 foreach my $zone ( sort keys %TZ ) { 68 printf "\t{ '%s', '%s' },\n", $zone, $TZ{$zone}71 printf O "\t{ '%s', '%s' },\n", $zone, $TZ{$zone} 69 72 } 70 73 71 print <<HEAD; 72 } 74 print O "}\n"; 75 close O; 76 77 print STDERR "done\n"; 78 79 80 open (O, "> $tzdout/tzoffset.lua") || die "open($tzdout/tzoffset.lua): $!\n"; 81 82 print STDERR "Writing time offsets to $tzdout/tzoffset.lua ... "; 83 print O <<HEAD; 84 --[[ 85 LuCI - Autogenerated Zoneinfo Module 86 87 Licensed under the Apache License, Version 2.0 (the "License"); 88 you may not use this file except in compliance with the License. 89 You may obtain a copy of the License at 90 91 http://www.apache.org/licenses/LICENSE-2.0 92 93 ]]-- 94 95 module "luci.sys.zoneinfo.tzoffset" 73 96 74 97 OFFSET = { … … 104 127 $offset += $s * $m * 60; 105 128 106 printf ("\t%-5s = %6d,\t-- %s\n",107 lc($std), $offset, $std );129 printf O "\t%-5s = %6d,\t-- %s\n", 130 lc($std), $offset, $std; 108 131 109 132 $seen{$std} = 1; … … 123 146 } 124 147 125 printf ("\t%-5s = %6d,\t-- %s\n",126 lc($dst), $offset, $dst );148 printf O "\t%-5s = %6d,\t-- %s\n", 149 lc($dst), $offset, $dst; 127 150 128 151 $seen{$dst} = 1; … … 130 153 } 131 154 else { 132 printf ("\t%-5s = %6d,\t-- %s\n",133 lc($std), $offset, $std );155 printf O "\t%-5s = %6d,\t-- %s\n", 156 lc($std), $offset, $std; 134 157 135 158 $seen{$std} = 1; … … 139 162 } 140 163 141 print "}\n"; 164 print O "}\n"; 165 close O; 166 167 print STDERR "done\n";
