Jump to content
The simFlight Network Forums

Problem getting Zulu Date & Time

Recommended Posts

While I have no problems getting the local date and time from the flight simulator, I am having an issue trying to get the zulu (or GMT) data and time from the flight simulator.

Here is my code (C#):

Offset<byte[]> FSUIPCGMTDateTime = new Offset<byte[]>("FSUIPCGMTDateTime", 0x023B, 10);

string stringFSGMTDateTime; 
string stringFSGMTDate;
string stringFSGMTTime;

FSUIPCConnection.Process(new string[] {"FSUIPCGMTDateTime" });
short GMTYear = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 8);
DateTime FSGMTTime = new DateTime(GMTYear, 1, 1, FSUIPCGMTDateTime.Value[0], FSUIPCGMTDateTime.Value[1], FSUIPCGMTDateTime.Value[2]);
short GMTDayNo = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 6);
FSGMTTime = FSGMTTime.Add(new TimeSpan(GMTDayNo - 1, 0, 0, 0));
stringFSGMTDateTime = "[" + FSGMTTime.ToString("yyyy/MM/dd HH:mm") + "]";
stringFSGMTDate = FSGMTTime.ToString("yyyy MM dd");
stringFSGMTTime = FSGMTTime.ToString("HH:mm");

I should be getting something like:
[2016/07/14 22:13]

What I am getting is:
[1801/12/05 22:13]

What am I missing?



Share this post

Link to post
Share on other sites

Offset<byte[]> FSUIPCGMTDateTime = new Offset<byte[]>("FSUIPCGMTDateTime", 0x023B, 10);

short GMTYear = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 8);
short GMTDayNo = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 6);

The year starts at offset 0x2040 which is 5 bytes in from 0x023B. So this line should be:

short GMTYear = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 5); 

The day number is 3 bytes in:

short GMTDayNo = BitConverter.ToInt16(FSUIPCGMTDateTime.Value, 3); 

Looks like you were counting the first 3 time offsets in that block as 2 bytes each.


Share this post

Link to post
Share on other sites

Thanks Paul,

That was indeed the problem.

I am now getting the proper display data and time display in zulu.

Really appreciate the help,



Share this post

Link to post
Share on other sites

Hi Paul,

I have a problem with Zulu Time and Local Time :

I choose an airport on US, (KVPS for example)

Local Time = 30 may 2017 18:59:30

Zulu Time = 30 may 2017 23:59:30

and have a timer to update values each second. All is ok but when Zulu Time = 31 may 2017 00:00:01, date for Local Time is now =31 may 2017 19:00:01. For Local Time date must be 30 may and not 31 may.

Here is the code :

private Offset<byte[]> fsLocalDateTime = new Offset<byte[]>(0x0238, 10);
        private Offset<byte[]> fsZuluDateTime = new Offset<byte[]>(0x023B, 10);

        private Offset<byte> zmin = new Offset<byte>(0x23c);
        private Offset<byte> zhour = new Offset<byte>(0x23b);
        private Offset<byte> second = new Offset<byte>(0x23a);

        private void timer1_Tick(object sender, EventArgs e)
            // Process the default group

                // get local Time
                short year = BitConverter.ToInt16(fsLocalDateTime.Value, 8);
                DateTime fsTime = new DateTime(year, 1, 1, fsLocalDateTime.Value[0], fsLocalDateTime.Value[1], fsLocalDateTime.Value[2]);
                short dayNo = BitConverter.ToInt16(fsLocalDateTime.Value, 6);
                fsTime = fsTime.Add(new TimeSpan(dayNo - 1, 0, 0, 0));
                lblLocalTime.Text = (fsTime.ToString("F", CultureInfo.CreateSpecificCulture("fr-FR")));

                // get Zulu Time
                short year2 = BitConverter.ToInt16(fsZuluDateTime.Value, 5);
                DateTime fsZuluTime = new DateTime(year2, 1, 1, zhour.Value, zmin.Value, second.Value);
                short zuludayNo = BitConverter.ToInt16(fsZuluDateTime.Value, 6);
                fsZuluTime = fsZuluTime.Add(new TimeSpan(dayNo - 1, 0, 0, 0));
                lblZuluTime.Text = (fsZuluTime.ToString("F", CultureInfo.CreateSpecificCulture("fr-FR")));

            catch (Exception ex)
                MessageBox.Show("Error : " + ex.Message);



Thank you for your help.

Share this post

Link to post
Share on other sites


Here's some code that will get both Zulu and Local into a .net DateTime. (This works with FSUIPC3 as well as it doesn't use any of the new date/time fields in FSUIPC4).

        private Offset<ushort> zuluYear = new Offset<ushort>("DateTime", 0x0240);
        private Offset<ushort> zuluDayNumber = new Offset<ushort>("DateTime", 0x023E);
        private Offset<byte> zuluHour = new Offset<byte>("DateTime", 0x023B);
        private Offset<byte> zuluMin = new Offset<byte>("DateTime", 0x023C);
        private Offset<byte> zuluSec = new Offset<byte>("DateTime", 0x023A);
        private Offset<short> localOffset = new Offset<short>("DateTime", 0x0246);
// Create datetime for Zulu
DateTime zuluDateTime = new DateTime(zuluYear.Value, 1, 1, zuluHour.Value, zuluMin.Value, zuluSec.Value).AddDays((double)(zuluDayNumber.Value - 1));
// Create datetime for Local
DateTime localDateTime = zuluDateTime.AddMinutes(localOffset.Value * -1);



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now