Time Zones¶
Timezone
¶
Timezone(maps: Map)
Google time zone client.
Purpose
Retrieves timezone identifiers, UTC offsets, and time-enriched location records.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
Optional[int]
|
Unix timestamp used for timezone lookup. |
maps |
Optional[Map]
|
Google Maps gateway used for timezone requests. |
latitude |
Optional[float]
|
Current latitude in decimal degrees. |
longitude |
Optional[float]
|
Current longitude in decimal degrees. |
data |
Optional[Dict]
|
Most recent timezone API payload. |
offset |
Optional[float]
|
Computed UTC offset including daylight saving time. |
local |
Optional[str]
|
Last computed local datetime representation. |
rows |
Optional[list]
|
Input rows for batch enrichment. |
lat_field |
Optional[str]
|
Latitude field name for batch enrichment. |
lng_field |
Optional[str]
|
Longitude field name for batch enrichment. |
utc_datetime |
Optional[datetime]
|
UTC datetime used for local time conversion. |
Initialize timezone lookup state for the supplied Maps gateway.
Purpose
Initialize timezone lookup state for the supplied Maps gateway.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maps
|
Map
|
Initialized Google Maps API gateway. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Initializes instance state. |
Source code in mapping.py
Methods:¶
validate_coordinates
¶
Purpose
Validate and normalize a latitude and longitude pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees. |
required |
lng
|
float
|
Longitude in decimal degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple
|
Validated latitude and longitude. |
Source code in mapping.py
lookup
¶
Purpose
Fetch the full Google Time Zone API response for a coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude. |
required |
lng
|
float
|
Longitude. |
required |
Returns:
| Type | Description |
|---|---|
Dict | None
|
Dict | None: Full time zone response payload, including timeZoneId, timeZoneName, rawOffset, dstOffset, and status when available. |
Source code in mapping.py
get_id
¶
Purpose
Fetch the IANA time zone id for a coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude. |
required |
lng
|
float
|
Longitude. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Time zone id string or None if unavailable. |
Source code in mapping.py
offset_hours
¶
Purpose
Fetch the total UTC offset in hours for a coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude. |
required |
lng
|
float
|
Longitude. |
required |
Returns:
| Type | Description |
|---|---|
Optional[float]
|
Optional[float]: Total UTC offset in hours, including daylight-saving offset when returned by the API. |
Source code in mapping.py
local_time
¶
Purpose
Convert a UTC datetime into local time at a coordinate using the Google Time Zone API rawOffset and dstOffset fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude. |
required |
lng
|
float
|
Longitude. |
required |
utc_datetime
|
Optional[datetime]
|
Optional UTC datetime. If None, the current UTC time is used. |
None
|
Returns:
| Type | Description |
|---|---|
Dict | None
|
Dict | None: Dictionary containing timezone metadata, UTC time, local time, and total offset hours. |
Source code in mapping.py
batch_lookup
¶
Purpose
Enrich a list of row dictionaries with Google Time Zone API fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
list
|
List of dictionaries containing latitude and longitude fields. |
required |
lat_field
|
str
|
Latitude field name. |
'lat'
|
lng_field
|
str
|
Longitude field name. |
'lng'
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
List of copied row dictionaries with timezone fields appended. |
Source code in mapping.py
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | |