• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Get sim-time

Messages
46
Country
israel
I saw some questions but none of the answers worked for me.
How do I get the time in the simulator through simconnect? I tried ZULU TIME and Local time as INT and Float 32 and 64 into Int64, log int, uint.
The timestamp I get doesn't make sense.
 
Which ZULU/LOCAL time are you talking about? The Environment variables? In that case it's like it says in the docs... seconds since start of day. It returns a floating point value... presumably milliseconds? But the whole number part corresponds to seconds since midnight, either Zulu or local time.

The top result is read as an integer, the lower one is read as a double.

1683840950272.png


-Max
 
What is this? Look completely alien. How do i used that on simconnect?!
Anyway, I just came back to write that the solution was to get year,month,day to build the day, then add zulutime.
C#:
            _simconnect.AddToDataDefinition(DataDefinitions.FlightData, "Zulu year", "number", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            _simconnect.AddToDataDefinition(DataDefinitions.FlightData, "zulu month of year", "number", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            _simconnect.AddToDataDefinition(DataDefinitions.FlightData, "zulu day of month", "number", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            _simconnect.AddToDataDefinition(DataDefinitions.FlightData, "zulu time", "seconds", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);



// then where I consume that:
            var day = new DateTime(data.zuluYear, data.zuluMonth, data.zuluDay, 0, 0, 0, 0, System.DateTimeKind.Utc);
            var time = day.AddSeconds(data.zuluTime);
            ActiveFlight.StartTime = time;

Quite ugly.
I couldn't make absolute time work, tried adding it to year 0, year 1900, year 2000 and year 1970. Always produces a bad timestamp.

* edit -
Crap, it's year 1. That makes sense, that's the common way to calculate time.
 
Wait, what...? Those are valid variable names for SimConnect? They're not valid Sim Vars ("A" type)... at least a gauge API lookup doesn't return a valid ID for them. How did you find those in the first place? Weird!

The screenshot is from my WASimCommander project's UI, which I've mentioned previously I think. It uses the WASM part of that project on the back-end which essentially gives access to some useful gauge API functions.

-Max
 
I just fiddled with it - found this forum post:
And then I was looking for the var names and got to this page:

But you see, here it says Jan 1 0000. I got numbers and had trouble getting the right data time, as you can see it only says "number" which makes sense for js or html gauges...
Anyway, I found out that using SIMCONNECT_DATATYPE.INT32 with UInt32 in C# gets me a number that kinda makes sense. But I couldn't make it work.
I saw the ZULU TIME var was too small to be a timestamp.
I was trying the approach above just as you linked the newer documentation which makes a whole lot more sense!
 
Yea the P3D docs leave out some details.... LOL! But even there is says they're "E" type variables. Makes me wonder yet again exactly how much of SimConnect is undocumented. Cool find though!

-Max
 
Back
Top