Geo::Location::TimeZone - Find the timezone for a given location.
use Geo::Location::TimeZone; my $gltzobj = Geo::Location::TimeZone->new(); # 54.3 degrees North, 4.8 degrees East - Amsterdam-ish. my $tzname = $gltzobj->lookup( lat => 54.3, lon => 4.8 ); print "$tzname\n";
Geo::Location::TimeZone provides a basic lookup of timezone information based on a geographic location. The boundaries in the internal database are relatively coarse in order to keep the size (and lookup speed) of this library low.
The lookup is done in two parts; first a fall-back timezone is calculated, based on the 15 degree intervals of longitude. Secondly, the internal database is consulted to see if more specific data is available.
The names of the timezones returned are according to the 'posix' directory of the author's zoneinfo directory. Some of these are usable with the DateTime::TimeZone library.
This creates a new object.
This performs a lookup, and returns a text string of the timezone that the supplied location is within (or undef). No offset is returned, as that involves doing daylight savings calculations which are better done inside other modules.
A %hash is taken as arguments, being 'lat' and 'lon', corresponding to the latitude and longitude of the location, expressed in decimal degrees in the WGS84 datum. If a third argument, 'copyright' is supplied, the return value will be the copyright string attached to that particular item of data.
Note that you may not get the timezone that you were expecting, due to a shortcut taken within the code. For example, if you looked up the location for Narbonne, France, you might get back 'Europe/Andorra' instead of 'Europe/Paris'. This is because the GeoData source for the library has major timezone boundaries, not country boundaries. The coordinates of major areas are known to the library, and it finds the 'closest' one to the supplied location.
Returns the letter code for the supplied hour offset (eg, 2 will return B). This is used to work out which sub-library to load into memory to perform the lookup.
Bruce Campbell, 2007. See http://cpan.zerlargal.org/Geo::Location::TimeZone
In finding the Geodata used for this, the author ran into the common problem of Geographic data being held under very restrictive usage licenses, or being unavailable for free (as in price). Hence, we have this listing to avoid any issues.
Copyright (c) 2007 Bruce Campbell. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.
- Base Zones
Based on the work of the 1884 International Prime Meridian Conference. No copyright is claimed.
- Derived data
A number of boundaries have been derived from direct observation, or laws defining administrative boundaries. Where this is the case, no copyright is claimed on the data.
To be sourced from official seperation of states.
- UK/Ireland (GMT)
To be sourced from UK boundaries on international waters.
To be sourced from water boundaries, and border line.
- Central European Time
To be sourced from water boundaries, German/Polish border.
To be sourced from decrees in Congress.
- All other zones
Sourced from ESRI's timezone collection, which lists the following sources:
ArcWorld 1:3M 20020218, ArcUSA 1:2M, ArcAtlas, Rand McNally Int., www.nunavutcourtofjustice.ca, www.nunavut.com, www.nrc.ca, DMTI Spatial Inc. - 2 to 50 .
The following paragraph within the source data seems to cover the release of Geodata within this package:
Geodata is redistributable without a Value-Added Software Application (i.e., adding the sample data to an existing, [non]commercial data set for redistribution) with proper metadata and source/copyright attribution to the respective data vendor(s).