App-olson
view release on metacpan or search on metacpan
},
build_requires => {
"Module::Build" => 0,
"Test::More" => 0,
"perl" => "5.006",
"strict" => 0,
"warnings" => 0,
},
requires => {
"Date::ISO8601" => 0,
"DateTime::TimeZone::Olson" => "0.003",
"DateTime::TimeZone::SystemV" => "0.002",
"DateTime::TimeZone::Tzfile" => "0.007",
"Getopt::Std" => "1.02",
"Params::Classify" => 0,
"Time::OlsonTZ::Data" => "0.201012",
"Time::Unix" => "1.02",
"integer" => 0,
"perl" => "5.006",
"strict" => 0,
"warnings" => 0,
},
dynamic_config => 0,
"requires" : {
"Module::Build" : 0,
"perl" : "5.006",
"strict" : 0,
"warnings" : 0
}
},
"runtime" : {
"requires" : {
"Date::ISO8601" : 0,
"DateTime::TimeZone::Olson" : "0.003",
"DateTime::TimeZone::SystemV" : "0.002",
"DateTime::TimeZone::Tzfile" : "0.007",
"Getopt::Std" : "1.02",
"Params::Classify" : 0,
"Time::OlsonTZ::Data" : "0.201012",
"Time::Unix" : "1.02",
"integer" : 0,
"perl" : "5.006",
"strict" : 0,
"warnings" : 0
}
}
},
"provides" : {
"App::olson" : {
"file" : "lib/App/olson.pm",
"version" : 0
},
"App::olson::LocalDateTime" : {
"file" : "lib/App/olson.pm",
"version" : 0
},
"App::olson::UtcDateTime" : {
"file" : "lib/App/olson.pm",
"version" : 0
}
},
"release_status" : "stable",
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
generated_by: 'Module::Build version 0.4, CPAN::Meta::Converter version 2.112621'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: App-olson
provides:
App::olson:
file: lib/App/olson.pm
version: 0
App::olson::LocalDateTime:
file: lib/App/olson.pm
version: 0
App::olson::UtcDateTime:
file: lib/App/olson.pm
version: 0
requires:
Date::ISO8601: 0
DateTime::TimeZone::Olson: 0.003
DateTime::TimeZone::SystemV: 0.002
DateTime::TimeZone::Tzfile: 0.007
Getopt::Std: 1.02
Params::Classify: 0
Time::OlsonTZ::Data: 0.201012
Time::Unix: 1.02
integer: 0
perl: 5.006
strict: 0
warnings: 0
resources:
license: http://dev.perl.org/licenses/
Which timezones have jumped westward across the International Date Line
since 1900?
olson list 'o@1900z < -08' 'o@now > +08' k
=back
=head1 SEE ALSO
L<DateTime::TimeZone::Olson>,
L<Time::OlsonTZ::Data>
=head1 AUTHOR
Andrew Main (Zefram) <zefram@fysh.org>
=head1 COPYRIGHT
Copyright (C) 2012 Andrew Main (Zefram) <zefram@fysh.org>
lib/App/olson.pm view on Meta::CPAN
=cut
package App::olson;
{ use 5.006; }
use warnings;
use strict;
use Date::ISO8601 0.000 qw(ymd_to_cjdn present_ymd);
use DateTime::TimeZone::Olson 0.003 qw(
olson_version olson_all_names olson_canonical_names olson_links
olson_country_selection olson_tz
);
use DateTime::TimeZone::SystemV 0.002 ();
use DateTime::TimeZone::Tzfile 0.007 ();
use Params::Classify 0.000 qw(is_string);
use Time::OlsonTZ::Data 0.201012 ();
use Time::Unix 1.02 qw(time);
our $VERSION = "0.000";
#
# list utilities
#
lib/App/olson.pm view on Meta::CPAN
$expect_rx\ in\ the\ [!-~]+\ timezone
\ due\ to\ (offset\ change|zone\ disuse|missing\ data)\b
/x) {
return $translate_exception{$1};
} else {
die $err;
}
}
{
package App::olson::UtcDateTime;
sub new {
my($class, $rdns) = @_;
return bless({ rdn => $rdns->[0], sod => $rdns->[1] }, $class);
}
sub utc_rd_values { ($_[0]->{rdn}, $_[0]->{sod}, 0) }
}
sub _handle_forward_exception($$) {
return _handle_exception($_[0],
qr/time [-:TZ0-9]+ is not represented/, $_[1]);
}
{
package App::olson::LocalDateTime;
sub new {
my($class, $rdns) = @_;
return bless({ rdn => $rdns->[0], sod => $rdns->[1] }, $class);
}
sub local_rd_values { ($_[0]->{rdn}, $_[0]->{sod}, 0) }
}
sub _handle_backward_exception($$) {
return _handle_exception($_[0],
qr/local time [-:T0-9]+ does not exist/, $_[1]);
lib/App/olson.pm view on Meta::CPAN
};
$attrclass{o} = $attrclass{offset} = {
desc => "offset",
params => { "\@" => "absolute_time" },
type => "offset",
cost => 10,
get_needs => { z=>undef },
curry_get => sub {
my($when) = $_[0]->{"\@"};
my $whendt = App::olson::UtcDateTime->new($when);
return sub {
my $zone = olson_tz($_[0]->{z});
return _handle_forward_exception(eval {
local $SIG{__DIE__};
0+$zone->offset_for_datetime($whendt);
}, $@);
};
},
};
$attrclass{i} = $attrclass{initialism} = {
desc => "initialism",
params => { "\@" => "absolute_time" },
type => "initialism",
cost => 10,
get_needs => { z=>undef },
curry_get => sub {
my($when) = $_[0]->{"\@"};
my $whendt = App::olson::UtcDateTime->new($when);
return sub {
my $zone = olson_tz($_[0]->{z});
return _handle_forward_exception(eval {
local $SIG{__DIE__};
$zone->short_name_for_datetime($whendt);
}, $@);
};
},
};
$attrclass{d} = $attrclass{dst_status} = {
desc => "DST status",
params => { "\@" => "absolute_time" },
type => "truth",
cost => 10,
get_needs => { z=>undef },
curry_get => sub {
my($when) = $_[0]->{"\@"};
my $whendt = App::olson::UtcDateTime->new($when);
return sub {
my $zone = olson_tz($_[0]->{z});
return _handle_forward_exception(eval {
local $SIG{__DIE__};
$zone->is_dst_for_datetime($whendt) ? 1 : 0;
}, $@);
};
},
};
lib/App/olson.pm view on Meta::CPAN
# top-level commands
#
my %command;
$command{version} = sub {
die "bad arguments\n" if @_;
print "modules:\n";
foreach my $mod (qw(
App::olson
DateTime::TimeZone::Olson
DateTime::TimeZone::SystemV
DateTime::TimeZone::Tzfile
Time::OlsonTZ::Data
)) {
no strict "refs";
print " $mod ${qq(${mod}::VERSION)}\n";
}
print "Olson database: @{[olson_version]}\n";
};
$command{list} = sub {
my(@criteria, @output_attrs, @display_attrs, @sort_attrs);
lib/App/olson.pm view on Meta::CPAN
};
sub run(@) {
my $cmd = shift(@_);
defined $cmd or die "no subcommand specified\n";
($command{$cmd} || sub { die "unrecognised subcommand\n" })->(@_);
}
=head1 SEE ALSO
L<DateTime::TimeZone::Olson>,
L<Time::OlsonTZ::Data>,
L<olson>
=head1 AUTHOR
Andrew Main (Zefram) <zefram@fysh.org>
=head1 COPYRIGHT
Copyright (C) 2012 Andrew Main (Zefram) <zefram@fysh.org>
t/version.t view on Meta::CPAN
use App::olson ();
my $stdout = "";
close STDOUT;
open(STDOUT, ">", \$stdout) or die;
App::olson::run("version");
like $stdout, qr/^ \Q$_\E [0-9]+\.[0-9]+$/m foreach qw(
App::olson
DateTime::TimeZone::Olson
DateTime::TimeZone::SystemV
DateTime::TimeZone::Tzfile
Time::OlsonTZ::Data
);
like $stdout, qr/^Olson database: [0-9]{4}[a-z]$/m;
1;
( run in 0.455 second using v1.01-cache-2.11-cpan-05444aca049 )