summaryrefslogtreecommitdiffhomepage
path: root/build/zoneinfo2lua.pl
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-12-06 03:18:14 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-12-06 03:18:14 +0000
commitcbdc5af52ef0eeae955753ab0a8a0df650027b55 (patch)
treea3e44a2525b853f9bf83aed03606dccc2a35ea2d /build/zoneinfo2lua.pl
parent21da2f7c9c00eb812c0d503d73dca7f1e4dd5047 (diff)
build: generate timezone offsets too in zoneinfo2lua.pl
libs/http: drop zoneinfo information in luci.http.protocol.data, use luci.sys.zoneinfo instead libs/sys: refresh zoneinfo information
Diffstat (limited to 'build/zoneinfo2lua.pl')
-rw-r--r--build/zoneinfo2lua.pl70
1 files changed, 70 insertions, 0 deletions
diff --git a/build/zoneinfo2lua.pl b/build/zoneinfo2lua.pl
index fdcc3d60ec..7e772c0aff 100644
--- a/build/zoneinfo2lua.pl
+++ b/build/zoneinfo2lua.pl
@@ -65,4 +65,74 @@ foreach my $zone ( sort keys %TZ ) {
printf "\t{ '%s', '%s' },\n", $zone, $TZ{$zone}
}
+print <<HEAD;
+}
+
+OFFSET = {
+HEAD
+
+my %seen;
+foreach my $tz ( sort keys %TZ ) {
+ my $zone = $TZ{$tz};
+
+ if( $zone =~ /^
+ ([A-Z]+)
+ (?:
+ ( -? \d+ (?: : \d+ )? )
+ (?:
+ ([A-Z]+)
+ ( -? \d+ (?: : \d+ )? )?
+ )?
+ )?
+ \b /xo ) {
+ my ( $offset, $s, $h, $m ) = ( 0, 1, 0, 0 );
+ my ( $std, $soffset, $dst, $doffset ) = ( $1, $2, $3, $4 );
+
+ next if $seen{$std}; # and ( !$dst or $seen{$dst} );
+
+ if ( $soffset ) {
+ ( $s, $h, $m ) = $soffset =~ /^(-)?(\d+)(?::(\d+))?$/;
+
+ $s = $s ? 1 : -1;
+ $h ||= 0;
+ $m ||= 0;
+
+ $offset = $s * $h * 60 * 60;
+ $offset += $s * $m * 60;
+
+ printf("\t%-5s = %6d,\t-- %s\n",
+ lc($std), $offset, $std);
+
+ $seen{$std} = 1;
+
+ if( $dst ) {
+ if( $doffset ) {
+ ( $s, $h, $m ) = $doffset =~ /^(-)?(\d+)(?::(\d+))?$/;
+
+ $s = $s ? 1 : -1;
+ $h ||= 0;
+ $m ||= 0;
+
+ $offset = $s * $h * 60 * 60;
+ $offset += $s * $m * 60;
+ } else {
+ $offset += 60 * 60;
+ }
+
+ printf("\t%-5s = %6d,\t-- %s\n",
+ lc($dst), $offset, $dst);
+
+ $seen{$dst} = 1;
+ }
+ }
+ else {
+ printf("\t%-5s = %6d,\t-- %s\n",
+ lc($std), $offset, $std);
+
+ $seen{$std} = 1;
+ }
+
+ }
+}
+
print "}\n";