james7132/Hourai

Add timezone converter

Opened this issue · 4 comments

~time [city] Displays UTC timezone for , followed by the current time in military format

User: "~time Paris"

Hourai: "[UTC+1:00] Paris, France (5:00)"

~time [country] Displays all UTC timezones relative to large cities in the specified country's timezones

User: "~time USA"

Hourai:
"[UTC-10:00] Honolulu, Hawaii (17:46)"
"[UTC-9:00] Anchorage, Alaska (18:46)"
"[UTC-7:00] Los Angeles, California (20:46)"
"[UTC-5:00] Chicago, Illinois (10:46)"
"[UTC-4:00] New York City, New York (00:46)"

~time [continent] Displays all UTC timezone in the continent followed by the largest city in each timezone, followed by the current time in military format.

User: "~time Europe"

Hourai:
"[UTC+0:00] London, England (4:46)"
"[UTC+1:00] Paris, France (5:46)"
"[UTC+2:00] Warsaw, Poland (6:46)"
"[UTC+3:00] Moscow, Russia (7:46)"

This can be a particular issue since the popular APIs I was considering using like Google Map's Time Zone API allows easy fetching, but is only 2,500 requests per day free. Either I'll need to very strictly rate limit this, or be willing to fork up a bit cash, even with caching.

https://developers.google.com/maps/documentation/timezone/usage-limits

Why not just calculate the time locally? Time zones in continents don't change so the only requests that you'd ever need to make is for specific cities, rather than countries and continents which would only return the most populated cities' time zones.

If Hourai knows what time it is locally, she can do a conversion to the user specified time zones as long as the UTC+X:00 timezone for both areas is stored locally, after compensating for DST, which can be checked for with just one request every day. Then, all she'd have to do is get the local time and add or subtract for each field.

It'd only really become much of an issue if people make requests for specific cities that aren't ones like Paris, LA, or London, as the time zones for those large cities would be stored locally.

The problem is mapping a text location to a time zone is not so simple: i.e. how does Hourai know that "Atlanta" is in the same time zone as "40.730610, -73.935242"?

If operating purely on a time zone descriptor to time zone descriptor basis (for example: PST to EST), that might be easier, but also pretty poor UX.

What if Hourai was set to only accept locations in a valid "City, State/Province, Country" form?

Update: #26