#!/usr/bin/perl # zoneinfo2lua.pl - Make Lua module from /usr/share/zoneinfo # Execute from within /usr/share/zoneinfo # $Id: zoneinfo2lua.pl 3860 2008-12-06 03:18:14Z jow $ 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 <