Virtual date and time in the game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

I want to organize a virtual date and time in the game. For example: the game starts on the 1st of January 1905, and next time the game goes forward. Additionally, I want to determine the length of the virtual hour (say 6 minutes).

I can do it myself, means GDScript. But first I want to ask, in Godot there are standard tools to solve this problem?

:bust_in_silhouette: Reply From: Zylann

Usually, almost every high level language has a Date or DateTime object in its standard library, but after searching the doc, it turns out Godot hasn’t one in GDScript (or it’s not obvious :p) There is OS.get_date() but it returns today’s time in a dictionary. So yeah, you have to implement that yourself.
Or you can post a request on Github if you feel it would be a useful addition.

:bust_in_silhouette: Reply From: pheryx

I solved this by using OS.get_unix_time() as the “zero point” for the start of my game time. When advancing the game time I add incrementally as much time (in seconds) as I want the game universe to move forward. Using the start time for comparison, I calculate how many seconds, minutes, hours, or days have passed.

Unfortunately there is no reverse function to determine the datetime from a UNIX timestamp, but at least it gives you an easier way to do the math.

Thank you all for the answers. I will invent how to do it.

DimitriyPS | 2016-06-10 10:05

:bust_in_silhouette: Reply From: DriNeo

I hope this link to another answers could help.