# Time Zone Process Flow

## **Overall Flow**

**getTimeZone** flow is consists of the following steps.

* Identify the City Name using from raw speech communicated  by Human
* Get the Latitude and Longitude of the City Name.
* Get the Time Zone

```python
places = geograpy.get_geoPlace_context(text=rawspeech)
city_name = GetCityName(places)

LatitudeValue,LongitudeValue =  geoLocateLatitudeLongitude(city_name)
timeZone = getTimeZoneValue(LatitudeValue, LongitudeValue)
```

## Identify the City Name

Once the **getTimeZone** flow is triggered raw speech is passed to **geography** package geoPlace Function to identify the place from the raw speech.

```python
places = geograpy.get_geoPlace_context(text=rawspeech)
city_name = GetCityName(places)
```

Once the location is identified, **GetCityName** flow is used to get the name of the city from places list. First occurrence of the city is selected.

In case of no city identified, an exception is raised and is handled by defaulting the city to home city.

```python
try:
    city_name = places.cities[0]
    return city_name
except Exception as e:
    city_name = homeCityName
    return city_name
```

{% hint style="info" %}
[geograpy ](https://pypi.org/project/geograpy3/)extracts place names from a URL or text, and adds context to those names -- for example distinguishing between a country, region or city.

The extraction is a two step process.&#x20;

* The first process is a Natural Language Processing task which analyzes a text for potential mentions of geographic locations.&#x20;
* In the next step the words which represent such locations are looked up using the Locator.

If you already know that your content has geographic information you might want to use the Locator interface directly.
{% endhint %}

## Identify Latitude and Longitude

**geoLocateLatitudeLongitude** flow is executed to Identify the Latitude and Longitude, City Name is passed to geopy package to identify the Latitude and Longitude of the given City.

{% hint style="info" %}
[geopy ](https://pypi.org/project/geopy/)makes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources.

geopy includes geocoder classes for the [OpenStreetMap Nominatim](https://nominatim.org/), [Google Geocoding API (V3)](https://developers.google.com/maps/documentation/geocoding/), and many other geocoding services.
{% endhint %}

**How it works using geopy?**

* Once geopy package is installed.
* Import Nominatim from geopy- Nominatim is a free service or tool or can be called as API with no keys that provides you with the data after providing it with name and address and vice versa.
* On calling Nomination tool which accepts an argument of **user\_agent** you can give any name as it considers it to be the name of the app to which it is providing its services. Here we are using user\_agent Name as Aryan.
* The **geocode()** function accepts the location name and returns a geodataframe that has all the details and since it’s a dataframe we can get the address, latitude and longitude by simply calling it as in snippet below.

```python
geolocator = Nominatim(user_agent="Aryan")
LatitudeValue = geolocator.geocode(city_name).latitude
LongitudeValue = geolocator.geocode(city_name).longitude
```

## Get Time Zone using Latitude and Longitude

Once Latitude and Longitude are Identified **getTimeZoneValue** flow is executed and using **tzwhere** package time zone is identified and returned to the user for the requested place

```
timezoneobject = tzwhere.tzwhere()
timezone = timezoneobject.tzNameAt(LatitudeValue, LongitudeValue)
```

{% hint style="info" %}
[tzwhere ](https://pypi.org/project/tzwhere/)is a Python library to lookup the timezone for a given Latitude and Longitude entirely offline.
{% endhint %}

Time Zone is returned to the user and Control passed to NextStep.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aryanai.gitbook.io/docs.aryanandarya/my-skills/time-zone-of-mumbai/process-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
