Net::DNS::GuessTZ - guess the time zone of a host
version 0.005
use Net::DNS::GuessTZ qw(tz_from_host); my $tz = tz_from_host('cr.yp.to');
Brazenly stolen from Plagger::Plugin::Filter::GuessTimeZoneByDomain, this module makes an effort to guess an appropriate time zone for a given host. It will look up the location of the IP addresses owner and it will also consider the country code top-level domain, if the host is under one.
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
my $tz_name = Net::DNS::GuessTZ->tz_from_host($hostname, %arg);
This routine returns a guess at the given host's time zone, or false if no guess can be made.
Valid arguments are:
priority - which method to give priority to: "cc" or "ip"; default: ip ip_country - whether to check the IP address's owner with IP::Country; defaults to true
Unlike the Plagger plugin, this routine will gladly make a guess when the country it finds has more than three time zones.
This is fine if you don't really care too much about being correct. It's probably better than just always assuming local time.
Still, if possible, ask the user for his time zone when you can!
Ricardo SIGNES <cpan@semiotic.systems>
Ricardo Signes <rjbs@semiotic.systems>
This software is copyright (c) 2008 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::DNS::GuessTZ, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::DNS::GuessTZ
CPAN shell
perl -MCPAN -e shell install Net::DNS::GuessTZ
For more information on module installation, please visit the detailed CPAN module installation guide.