diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-11-06 17:48:47 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-11-06 17:48:47 +0000 |
commit | 0d00e3b691146fbd0f51b0782988a62621a72b88 (patch) | |
tree | 6575494ba480d8f396973f7d2037787c2e678a8d | |
parent | 0969279c41a31733a4c1b6c9a9fa769a6bbc7ee9 (diff) |
* luci/build: add zoneinfo2lua.pl utility
-rw-r--r-- | build/zoneinfo2lua.pl | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/build/zoneinfo2lua.pl b/build/zoneinfo2lua.pl new file mode 100644 index 0000000000..fdcc3d60ec --- /dev/null +++ b/build/zoneinfo2lua.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl +# zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo +# Execute from within /usr/share/zoneinfo +# $Id$ + +use strict; + +my %TZ; + +local $/ = "\012"; +open( ZTAB, "< ./zone.tab" ) || die "Unable to open zone.tab: $!"; + +while( ! eof ZTAB ) { + chomp( my $line = readline ZTAB ); + next if $line =~ /^#/ || $line =~ /^\s+$/; + + my ( undef, undef, $zone, @comment ) = split /\s+/, $line; + + printf STDERR "%-40s", $zone; + + if( open ZONE, "< ./$zone" ) { + seek ZONE, -2, 2; + + while( tell(ZONE) > 0 ) { + read ZONE, my $char, 1; + ( $char eq "\012" ) ? last : seek ZONE, -2, 1; + } + + chomp( my $tz = readline ZONE ); + print STDERR ( $tz || "(no tzinfo found)" ), "\n"; + close ZONE; + + if( $tz ) { + $zone =~ s/_/ /g; + $TZ{$zone} = $tz; + } + } + else + { + print STDERR "Unable to open $zone: $!\n"; + } +} + +close ZTAB; + + +print <<HEAD; +--[[ +LuCI - Autogenerated Zoneinfo Module + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +module "luci.sys.zoneinfo" + +TZ = { +HEAD + +foreach my $zone ( sort keys %TZ ) { + printf "\t{ '%s', '%s' },\n", $zone, $TZ{$zone} +} + +print "}\n"; |