ix.date
Persistent date and time handling.
All of Lua's time functions are dependent on the Unix epoch, which means we can't have dates that go further than 1970. This library remedies this problem. Time/date is represented by a date object that is queried, instead of relying on the seconds since the epoch.
Futher documentation
This library makes use of a third-party date library found at https://github.com/Tieske/date - you can find all documentation regarding the date object and its methods there.
Functions
ix.date.Construct(currentDate)
View source »Returns a date object from a table or serialized date.
Parameters
-
currentDate
Date to construct
Returns
-
date
Constructed date object
ix.date.Get()
View source »Returns the currently set date.
Returns
-
date
Current in-game date
ix.date.GetFormatted(format, currentDate)
View source »Returns a string formatted version of a date.
Parameters
-
format
string
Format string
-
currentDate
date
default: nil
Date to format. If nil, it will use the currently set date
Returns
-
string
Formatted date
ix.date.GetSerialized(currentDate)
View source »Returns a serialized version of a date. This is useful when you need to network a date to clients, or save a date to disk.
Parameters
-
currentDate
date
default: nil
Date to serialize. If nil, it will use the currently set date
Returns
-
table
Serialized date
ix.date.Initialize()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Loads the date from disk.
ix.date.ResolveOffset()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Updates the internal in-game date/time representation and resets the offset.
ix.date.Save()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Saves the current in-game date to disk.
ix.date.Send(client)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Sends the current date to a player. This is done automatically when the player joins the server.
Parameters
-
client
Player
default: nil
Player to send the date to, or
nil
to send to everyone
ix.date.UpdateTimescale(secondsPerMinute)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Updates the time scale of the in-game date/time. The time scale is given in seconds per minute (i.e how many real life seconds it takes for an in-game minute to pass). You should avoid using this function and use the in-game config menu to change the time scale instead.
Parameters
-
secondsPerMinute
number
New time scale