Closed Herostwist closed 3 years ago
Hi Which Api are you referring to, and can you link to the Google reference where you see this?
The docs are: https://developers.google.com/maps/documentation/directions/get-directions#Legs
arrival_time contains the estimated time of arrival for this leg. This property is only returned for transit directions. The result is returned as a Time object with three properties: value the time specified as a JavaScript Date object. text the time specified as a string. The time is displayed in the time zone of the transit stop. time_zone contains the time zone of this station. The value is the name of the time zone as defined in the IANA Time Zone Database, e.g. "America/New_York".
In the duration class the time value of legs[].arrival_time.value is an integer when it should be a local DateTime or even better a DateTimeOffset combining the value and time_zone properties.
Thanks I will take a look at it.
Hi
I did a test, and the response I get actually has the value set as an integer in seconds. So I don't get null as you explain. If I change to DateTimeOffset
or TimeSpam
I get an exception when deserializing the json response. This is strange, cause based on the documentation you should be correct.
Could you try paste the DirectionsResponse.RawJson
Weird. As you say the raw json contains integers. Looking at their values and it appears they are Unix timestamps. The values appear to be within the upper bounds of a 32bit signed integer, so I'm not sure why the arrival_time is always null after deserialising.
FYI here is snippet from RAW.
"copyrights" : "Map data ©2021", "legs" : [ { "arrival_time" : { "text" : "09:57", "time_zone" : "Europe/London", "value" : 1619600250 }, "departure_time" : { "text" : "09:28", "time_zone" : "Europe/London", "value" : 1619598534 }, "distance" : { "text" : "7.4 km", "value" : 7407 }, "duration" : { "text" : "29 mins", "value" : 1716 },
Apologies, it appears the issue with deserialising may be due to some customs global configuration with Newtonsoft my end. Googel's incorrect documentation sent me in the wrong direction.
It would be nice though to have the unix timestamp automatically deserialised to a datetimeoffset, but maybe not something for this library to do.
For transit results the ArrivalTime and DepartTime in legs are deserialised to a Duration class where the value is an integer, however the JSON value is not an integer it is the time specified as a JavaScript Date object. As a result both ArrivalTime and DepartTime are always null due to deserialisation failure.