2 # zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo
3 # Execute from within /usr/share/zoneinfo
11 open( ZTAB, "< ./zone.tab" ) || die "Unable to open zone.tab: $!";
14 chomp( my $line = readline ZTAB );
15 next if $line =~ /^#/ || $line =~ /^\s+$/;
17 my ( undef, undef, $zone, @comment ) = split /\s+/, $line;
19 printf STDERR "%-40s", $zone;
21 if( open ZONE, "< ./$zone" ) {
24 while( tell(ZONE) > 0 ) {
25 read ZONE, my $char, 1;
26 ( $char eq "\012" ) ? last : seek ZONE, -2, 1;
29 chomp( my $tz = readline ZONE );
30 print STDERR ( $tz || "(no tzinfo found)" ), "\n";
40 print STDERR "Unable to open $zone: $!\n";
49 LuCI - Autogenerated Zoneinfo Module
51 Licensed under the Apache License, Version 2.0 (the "License");
52 you may not use this file except in compliance with the License.
53 You may obtain a copy of the License at
55 http://www.apache.org/licenses/LICENSE-2.0
59 module "luci.sys.zoneinfo"
64 foreach my $zone ( sort keys %TZ ) {
65 printf "\t{ '%s', '%s' },\n", $zone, $TZ{$zone}
75 foreach my $tz ( sort keys %TZ ) {
81 ( -? \d+ (?: : \d+ )? )
84 ( -? \d+ (?: : \d+ )? )?
88 my ( $offset, $s, $h, $m ) = ( 0, 1, 0, 0 );
89 my ( $std, $soffset, $dst, $doffset ) = ( $1, $2, $3, $4 );
91 next if $seen{$std}; # and ( !$dst or $seen{$dst} );
94 ( $s, $h, $m ) = $soffset =~ /^(-)?(\d+)(?::(\d+))?$/;
100 $offset = $s * $h * 60 * 60;
101 $offset += $s * $m * 60;
103 printf("\t%-5s = %6d,\t-- %s\n",
104 lc($std), $offset, $std);
110 ( $s, $h, $m ) = $doffset =~ /^(-)?(\d+)(?::(\d+))?$/;
116 $offset = $s * $h * 60 * 60;
117 $offset += $s * $m * 60;
122 printf("\t%-5s = %6d,\t-- %s\n",
123 lc($dst), $offset, $dst);
129 printf("\t%-5s = %6d,\t-- %s\n",
130 lc($std), $offset, $std);