Time handling

zeuz uses a non-standard timestamp format. Most computers and systems calculate time from a starting point of 1 January 1970. zeuz calculates time from a starting point of 1 January 1900.

Info: Do I need to convert time values to zeuz format?

If you can use one of the wrappers provided in the SDK download or the SDK in Go, you don’t need to convert time values to the zeuz format, because the wrapper or SDK does it for you. See the API introduction to check whether you can use one of these options, instead of accessing the zeuz base API directly.

You must access the zeuz base API directly if:

  • You develop your game in a language other than Unity, Unreal, or Go, or
  • You want to use the zeuz API to build tools around your game, for example to integrate your game into your CI/CD pipeline.

With the zeuz SDK

The zeuz SDK handles time conversion to the zeuz format for you. If you’re using the wrappers for Unity or Unreal, or the SDK in Go, we recommend that you use the Timestamp data type in the SDK to store time values. Timestamp is an int64 data type that can accommodate the zeuz timestamp format.

With the zeuz base API

If you’re using the zeuz base API directly, you must include a function in your scripts to convert time values into the zeuz format. Store time values as a 64-bit integer data type, which can accommodate the zeuz timestamp format.

Correct time handling is very important when using the zeuz base API to send API requests, because you authenticate requests using a session key that expires in 24 hours.

Example conversion

The following example function takes the current system time and converts it into the zeuz format.

Example snippet in C++:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
long zeuz_now() 
{
   // Get the current system time from the computer clock
   auto now = std::chrono::system_clock::now();
   
   // Convert the current time into milliseconds
   auto now_ms = std::chrono::time_point_cast<std::chrono::seconds>(now);
   
   // Get the time in milliseconds since 1 January 1970
   // Note: The Unix epoch is the time 00:00:00 UTC on 1 January 1970
   auto epoch = now_ms.time_since_epoch();
   
   // Take the current time from 1970 in milliseconds
   // Convert it into milliseconds from 1900
   // Convert the result from milliseconds into microseconds
   return (epoch.count() + 2208988800) * 1000 * 1000;
}

See the API login page for an example login script that incorporates the above time conversion.

For more information on zeuz base API authentication, see the following:



2021-may-27 Page updated with editorial review.


Last edited on: October 13, 2021 (149a70bd)