Jump to content
The simFlight Network Forums

Can I get the FS local time of any airport?


Recommended Posts

Not via offsets. The best you can do is the local time at the players location.

If you use the Airports Database built into the DLL you can get the Lon/Lat of the airport.

With this you can use a NuGet package called GeoTimeZone to get the time zone at that location.

https://github.com/mattjohnsonpint/GeoTimeZone

You can then use another NuGet package called TimeZoneConverter to convert this to the normal .NET TimeZoneInfo class.

https://github.com/mattjohnsonpint/TimeZoneConverter

You can then use that to work out the local time from the UTC Simulator time from the DLL: (FSUIPCConnection.UTCDateTime).

Something like this:

string timeZoneIANA = TimeZoneLookup.GetTimeZone(apLat, apLon).Result;
TimeZoneInfo tzInfo = TZConvert.GetTimeZoneInfo(timeZoneIANA);
DateTime airportLocalTime = TimeZoneInfo.ConvertTimeFromUtc(FSUIPCConnection.UTCDateTime, tzInfo);

Paul

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.