Aryan And Arya AI
Search…
⌃K

Time Across Globe Flow

Aryan executes this flow to answers questions such as
  • Current Time in Paris?
  • Current Time in PST?
  • What is CST Time?
  • Current Time in Tokyo?

Identify the Time Zone

First step is to Identify the Time Zone Based on Human Input. For Human request to get the Time Zone for CST, IST, PST, EST, CET, Human speech is checked to Identify these Zones and thereafter Time Zones are decided.
For Example for CST, Time Zone would be 'US/Central'
text2 = text1.lower().lstrip().rstrip()
if subStrCheck(text2,"cst") or subStrCheck(text2,"cdt"):
Zone = ""
timezoneinput= 'US/Central'
elif subStrCheck(text2,"pst") or subStrCheck(text2,"pdt"):
Zone = ""
timezoneinput= 'US/Pacific'
elif subStrCheck(text2,"est") or subStrCheck(text2,"et") :
Zone = ""
timezoneinput= 'US/Eastern'
elif subStrCheck(text2,"cet") or subStrCheck(text2,"cest"):
Zone = ""
timezoneinput= 'CET'
elif subStrCheck(text2,"ist"):
Zone = ""
timezoneinput= 'Asia/Kolkata'
If the Human Speech isn't matching with any of the above Time Zone Keyword, then geography is used to identify the place and thereafter get the City Name.
  • Flow to Identify the City Name is mentioned here in the Time Zone Flow
  • If City Name is Human Default Home City Name
    • Then getDefaultTimeZone Flow is executed mentioned in the Time Basic Process Flow
    • Else Latitude and Longitude are identified and getTimeZoneValue flow is executed to get the TimeZone. Flow Details in Time Zone Flow
else:
places = geograpy.get_geoPlace_context(text=text1)
city_name = GetCityName(places)
if city_name == homeCityName:
Zone = homeCityName
timezoneinput = getDefaultTimeZone()
else:
LatitudeValue,LongitudeValue = geoLocateLatitudeLongitude(city_name)
Zone = city_name
timezoneinput = getTimeZoneValue(LatitudeValue, LongitudeValue)

Get the Current Time on basis of Time Zone

Once Time Zone of the required location is identified, It is passed in date astimezone object to get the date, which is then converted into required Date Format to provide the current time to user.
Snippet below
date_format='%H:%M %Z on %d %B %Y '
date = datetime.datetime.now(tz=utc)
date = date.astimezone(timezone(timezoneinput))
ZoneDateTime=date.strftime(date_format)
return Zone, ZoneDateTime