UGTK / Toolkit / Utility Systems / Time Online System Completed
Time Online System
Summary
The Time Online System is a utility system that provides current time provided from external sources.
Content
Modules Dependencies
The Time Online System does not have any dependencies.
Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.
| Module | Component, and the prefab carrying it |
|---|---|
UIModule/TextUpdaterSystem |
Mn_TextUpdater (in DateOnline) |
Setup
Don't require any setup. The Time Online System is ready to use.
How To Use
Get current time
OnlineDataTimeUtils.GetOnlineTime(this, (value, error) =>
{
if (error)
{
Debug.LogError("Error getting online time");
return;
}
onlineDateTime_1 = value;
});
Get difference between stored time and current time
OnlineDataTimeUtils.HasPassedTime(this, onlineDateTime_1.Value, (value, error) =>
{
if (error)
{
Debug.LogError("Error getting online time");
return;
}
Debug.Log("Time passed: " + value.GetSeconds());
});
Testing Scene
Test code example:
S_OnlineDateTime? onlineDateTime_1 = null;
Debug.Log("Ask online time 1");
OnlineDataTimeUtils.GetOnlineTime(this, (value, error) =>
{
if (error)
{
Debug.LogError("Error getting online time");
return;
}
onlineDateTime_1 = value;
});
yield return new WaitUntil(() => onlineDateTime_1.HasValue);
Debug.Log("Wait for 5 seconds");
yield return new WaitForSeconds(5);
Debug.Log("Ask online time 2");
OnlineDataTimeUtils.HasPassedTime(this, onlineDateTime_1.Value, (value, error) =>
{
if (error)
{
Debug.LogError("Error getting online time");
return;
}
Debug.Log("Time passed: " + value.GetSeconds());
});
Good to know:
- This exists because the device clock is a lie. A player can move the system date forward to skip a daily reward or an expiry: only a time read from a server is trustworthy for that. Use it for anything time-gated that matters.
- It is a network call, so it can fail. The callback's second parameter is the error flag: handle it. What you do on failure is a design decision — deny the reward (safe) or grant it (friendly) — but decide it explicitly instead of ignoring the flag.
- Everything is anchored to UTC and converted to local time on the way out (Unix epoch → UTC →
ToLocalTime()), so a player travelling across time zones does not shift the result. - It needs a
MonoBehaviourto run the coroutine on: the object you pass must stay alive until the callback fires, or the answer never arrives.
Technical Info
The following are the main scripts and Time Online System. Refer to the script section for detailed structure.
Scripts:
OnlineDataTimeUtils Functions
- GetOnlineTime: Makes an API call to get the current online time.
- HasPassedTime: Checks how much time has passed since the given time.
- GetOnlineTimeCoroutine: Coroutine that makes the API call to get the current time.
S_OnlineDateTime Functions
- Difference: Returns the
S_OnlineDateTimethat represent difference between twoS_OnlineDateTimeinstances. - GetSeconds: Returns the time in seconds.
- GetMinutes: Returns the time in minutes.
- GetHours: Returns the time in hours.
- GetDays: Returns the time in days.
- GetWeeks: Returns the time in weeks.
- GetMonths: Returns the time in months.
- GetYears: Returns the time in years.
- ToString: Returns the Unix time as a string.
© 2026 Marcello De Bonis. All rights reserved
Depends on 1
Used by 2
- AppInfoStats
- MessageSystem
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 2 modules in total.
UGTKengine within an engine


