Jump to content
The simFlight Network Forums

Get Zulu Time


Recommended Posts

Hi,

 

Thank you for your client of FSUIPC for dotnet programer :rolleyes:

 

I have started to use it and try to get Zulu Time like this :

        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
            try
            {
                FSUIPCConnection.Process();

 

            // 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));
                this.textBox1.Text = fsTime.ToString("dddd, MMMM dd yyyy hh:mm:ss");

 

 

             // get Zulu Time
                year = BitConverter.ToInt16(fsZuluDateTime.Value, 8);

                DateTime fsZuluTime = new DateTime(year, 1, 1, fsZuluDateTime.Value[0], fsZuluDateTime.Value[1], fsZuluDateTime.Value[2]);
                short zuludayNo = BitConverter.ToInt16(fsZuluDateTime.Value, 6);
                fsZuluTime = fsTime.Add(new TimeSpan(dayNo - 1, 0, 0, 0));
                this.textBox2.Text = fsTime.ToString("dddd, MMMM dd yyyy hh:mm:ss");

           

           // or like this

                year = BitConverter.ToInt16(fsZuluDateTime.Value, 8);
                DateTime fsZuluTimeBis = new DateTime(year, 1, 1, zhour.Value, zmin.Value, second.Value);

                this.textBox3.Text = fsZuluTimeBis.ToString("dddd, MMMM dd yyyy hh:mm:ss");

            }

       }

 

but with this code the local time = zulu time even if my aircraft is on airport in GMT+8

 

Thank you for youyr help.

 

Motus

Link to comment
Share on other sites

Hi Motus,

 

I've highlighted where your mistakes are. It looks like you've copied and pasted from the one above, but not changed all the variable names.

 

 

       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
            try
            {
                FSUIPCConnection.Process();

 

            // get local Time

                short year = BitConverter.ToInt16(fsLocalDateTime.Value, :cool:;
                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));
                this.textBox1.Text = fsTime.ToString("dddd, MMMM dd yyyy hh:mm:ss");

 

 

             // get Zulu Time
                year = BitConverter.ToInt16(fsZuluDateTime.Value, :cool:;

                DateTime fsZuluTime = new DateTime(year, 1, 1, fsZuluDateTime.Value[0], fsZuluDateTime.Value[1], fsZuluDateTime.Value[2]);
                short zuludayNo = BitConverter.ToInt16(fsZuluDateTime.Value, 6);
                fsZuluTime = fsTime.Add(new TimeSpan(dayNo - 1, 0, 0, 0)); // Should be fsZuluTime and zuludayNo
                this.textBox2.Text = fsTime.ToString("dddd, MMMM dd yyyy hh:mm:ss"); // Should be fsZuluTime

           

           // or like this

                year = BitConverter.ToInt16(fsZuluDateTime.Value, :cool:;
                DateTime fsZuluTimeBis = new DateTime(year, 1, 1, zhour.Value, zmin.Value, second.Value);

                this.textBox3.Text = fsZuluTimeBis.ToString("dddd, MMMM dd yyyy hh:mm:ss");

            }

       }

 

 

 

Paul

Link to comment
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
×
×
  • 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.