user2510177
user2510177

Reputation: 51

Timestamp used in Google Timezone API

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

For example, I have a flight on July 10, 7:30am from Toronto, YYZ airport.

I want to use Google Timezone API to return the raw offset and DST offset to me, so I can calculate the local flight time in UTC format and used in my ICal file.

The Google API below requires to pass the timestamp. I wonder they requires a timestamp of UTC time or not?

This is their description of this value:

timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC. The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values.

I can get latitude and longitude for YYZ airport, but how do 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&timestamp=1419283200&sensor=false

This is what it returns:

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

Upvotes: 5

Views: 3419

Answers (1)

Rafael Oltra
Rafael Oltra

Reputation: 1239

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

If it's not in UTC you should convert it to UTC before using the API (the API itself does not offer a way to convert it)

For instance in C# to convert a time to UTC you could the TimeZone class.

Upvotes: 1

Related Questions