TimeZone::TimeZoneDB - Interface to https://timezonedb.com for looking up Timezone data
Version 0.01
use TimeZone::TimeZoneDB; my $tzdb = TimeZone::TimeZoneDB->new(key => 'XXXXXXXX'); my $tz = $tzdb->get_time_zone({ latitude => 0.1, longitude => 0.2 });
TimeZone::TimeZoneDB provides an interface to timezonedb.com to look up timezones.
my $tzdb = TimeZone::TimeZoneDB->new(); my $ua = LWP::UserAgent::Throttled->new(); $ua->env_proxy(1); $tzdb = TimeZone::TimeZoneDB->new(ua => $ua, key => 'XXXXX'); my $tz = $tzdb->tz({ latitude => 51.34, longitude => 1.42 })->{'zoneName'}; print "Ramsgate's timezone is $tz.\n";
use Geo::Location::Point; my $ramsgate = Geo::Location::Point->new({ latitude => 51.34, longitude => 1.42 }); # Find Ramsgate's timezone $tz = $tzdb->get_time_zone($ramsgate)->{'zoneName'}, "\n";
Accessor method to get and set UserAgent object used internally. You can call env_proxy for example, to get the proxy information from environment variables:
$tzdb->ua()->env_proxy(1);
Free accounts are limited to one search a second, so you can use LWP::UserAgent::Throttled to keep within that limit.
use LWP::UserAgent::Throttled; my $ua = LWP::UserAgent::Throttled->new(); $ua->throttle('timezonedb.com' => 1); $tzdb->ua($ua);
Nigel Horne, <njh@bandsman.co.uk>
<njh@bandsman.co.uk>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Lots of thanks to the folks at https://timezonedb.com.
TimezoneDB API: https://timezonedb.com/api
Copyright 2023 Nigel Horne.
This program is released under the following licence: GPL2
To install TimeZone::TimeZoneDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TimeZone::TimeZoneDB
CPAN shell
perl -MCPAN -e shell install TimeZone::TimeZoneDB
For more information on module installation, please visit the detailed CPAN module installation guide.