The timestamp used in the Google Time Zone API

I want to add my flight event to Outlook using ICal.cs.

For example, I have a flight on July 10, 7:30 in the morning from Toronto, YYZ Airport.

I want to use the Google timezone API to return the original offset and DST shift, so I can calculate the local flight time in UTC and use ICal in my file.

The Google API below requires passing a timestamp. Interestingly, do they require a UTC timestamp or not?

This is their description of this value:

timestamp indicates the desired time in seconds since midnight, January 1, 1970 UTC. The timezone API uses a timestamp to determine whether summer savings should be applied. Times before 1970 can be expressed as negative values.

I can get the latitude and longitude for YYZ airport, but how can I calculate this timestamp for my flight time if I don't know the time offsets in advance?

https://maps.googleapis.com/maps/api/timezone/json?location=43.700113788,-79.416304194×tamp=1419283200&sensor=false

This is what it returns:

{"dstOffset": 0.0, "rawOffset": -18000.0, "status": "OK", "timeZoneId": "America / Toronto", "timeZoneName": "Eastern Standard Time"}

+4
source share
1 answer

The timestamp (also known as Epoch, Unix Time) is always UTC.

If it is not in UTC, you must convert it to UTC before using the API (the API itself does not offer a way to convert it)

For example, in C # to convert time to UTC, you can TimeZone class.

0
source

Source: https://habr.com/ru/post/1487552/


All Articles