1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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";
|