Varjo system time
Varjo uses nanoseconds as a time unit. Varjo timestamps are monotonic, independent of the time-of-day clock, and relative to the epoch that is constant during the execution of the program (Varjo system epoch). The current Varjo time can be queried using the method
GetVarjoTimestamp in the VarjoTime class, which returns the number of nanoseconds that elapsed since the Varjo system epoch.
// Gets current Varjo system timestamp long GetVarjoTimestamp();
Varjo system time conversion
Note that the Varjo system time epoch is not equal to e.g. the Unix Epoch or any other global time epoch. However, Varjo timestamps can be converted to be compatible with timestamps from other time sources. To do so, Varjo system time and the other time source needs to be synchronized. The clock synchronization procedure measures the offset between the two time sources and the offset would then be used for the timestamp conversion.
Conversion to C# DateTime object
ConvertVarjoTimestampToDateTime in the VarjoTime class can be used to convert from the Varjo nanoseconds time to the real time-of-day clock timestamp expressed as the C# DateTime object.
// Converts Varjo system timestamp to DateTime object DateTime? ConvertVarjoTimestampToDateTime(long varjoTimestamp);
The result of this conversion depends on the time-of-day clock adjustment of the operating system (e.g. Windows time synchronization with NTP server). This conversion is supported for Varjo timestamps that are up to one hour in the past, but not earlier than the time when the Varjo system was started (e.g. the conversion can’t be used with timestamps that were recorded before the last computer reboot or restart of the Varjo services). The conversion can also be applied to Varjo timestamps that are in the future relative to the result of
GetVarjoTimestamp, however, the future time conversion must be used with consideration of a possible upcoming time-of-day clock adjustment that can’t be accounted for at the moment of the conversion. The conversion can fail (null is returned) if queried for an unsupported Varjo timestamp value, however, the failure is not guaranteed in all possible misuse scenarios.