-
Notifications
You must be signed in to change notification settings - Fork 0
Time
Francisco Dias edited this page Jan 30, 2023
·
1 revision
Never miss the beat with a simple query to the server for precise time information.
The following function is provided for working with time:
Extra details on structs that are returned as time fetching results:
This function queries the time of the Game Jolt server.
This is an asynchronous function that will trigger either the callback_success
method (if task is successful) or the callback_failed
method (if task fails).
Syntax:
GameJolt_Time([callback_success], [callback_failed])
Argument | Type | Description |
---|---|---|
callback_success | function | The callback function executed if the request succeeds (a TimeData struct is passed as argument) ✴️ OPTIONAL |
callback_failed | function | The callback function executed if the request fails (error message is passed as argument) ✴️ OPTIONAL |
Returns:
N/A
Example:
GameJolt_Time(function(timeData)
{
var _timestamp = timeData.timestamp;
var _timezone = timeData.timezone;
var _year = timeData.year;
var _month = timeData.month;
var _day = timeData.day;
var _hour = timeData.hour;
var _minute = timeData.minute;
var _second = timeData.second;
if (timeData.hour > 0 && timeDate.hour < 3)
{
show_debug_message("It's too late, time to go to sleep!");
}
});
The code sample above queries the time for the Game Jolt server and if it is too late show a sleeping message.
This struct is returned as an async result of the call to the following API function calls:
-
and it contains details that describe the current time.
Property | Type | Description |
---|---|---|
timestamp | real | The UNIX time stamp (in seconds) representing the server's time. |
timezone | string | The timezone of the server (example: "America/New_York" ) |
year | real | The current year. |
month | real | The current month. |
day | real | The day of the month. |
hour | real | The hour of the day. |
minute | real | The minute of the hour. |
second | real | The seconds of the minute. |
YoYoGames 2023