Home

Module time

Bindings for interacting with the time. Usage is generally something as follows:
 time_limit = time.get() + time.create( 0, 5, 0 )
 player.msg( string.format("You only have %s left!", time.str(time.get() - time_limit)) )
 
 -- Do stuff here
 
 if time.get() > time_limit then
 -- Limit is up
 end
 

Functions

time.__eq (t1, t2) Checks to see if two time are equal.
time.__le (t1, t2) Checks to see if a time is larger or equal to another.
time.__lt (t1, t2) Checks to see if a time is strictly larger than another.
time.add (t1, t2) Adds two time metatables.
time.create (scu, stp, stu) Creates a time.
time.fromnumber (num) Creates a time from a number representing it.
time.get () Gets the current time in internal representation time.
time.inc (t) Increases or decreases the time.
time.str (t, d) Converts the time to a pretty human readable format.
time.sub (t1, t2) Subtracts two time metatables.
time.tonumber (t) Gets a number representing this time.


Functions

time.__eq (t1, t2)
Checks to see if two time are equal. It is recommended to check with < and <= instead of ==.

Parameters

  • t1: Time to compare for equality.
  • t2: Time to compare for equality.

Usage:

if time.create( 630, 5, 78) == time.get() then -- do something if they match

Return value:

true if they're equal.
time.__le (t1, t2)
Checks to see if a time is larger or equal to another.

Parameters

  • t1: Time to see if is is smaller or equal to than t2.
  • t2: Time see if is larger or equal to than t1.

Usage:

if time.create( 630, 5, 78) <= time.get() then -- do something if time is past UST 630:0005.78

Return value:

true if t1 <= t2
time.__lt (t1, t2)
Checks to see if a time is strictly larger than another.

Parameters

  • t1: Time to see if is is smaller than t2.
  • t2: Time see if is larger than t1.

Usage:

if time.create( 630, 5, 78) < time.get() then -- do something if time is past UST 630:0005.78

Return value:

true if t1 < t2
time.add (t1, t2)
Adds two time metatables. Overrides the addition operator.

Parameters

  • t1: Time metatable to add to.
  • t2: Time metatable added.

Usage:

new_time = time.get() + time.create( 0, 5, 0 ) -- Adds 5 STP to the current date
time.create (scu, stp, stu)
Creates a time. This can be absolute or relative.

Parameters

  • scu: SCU for the new time.
  • stp: STP for the new time.
  • stu: STU for the new time.

Usage:

t = time.create( 591, 3271, 12801 ) -- Gets a time near when the incident happened.

Return value:

A newly created time metatable.
time.fromnumber (num)
Creates a time from a number representing it. The best usage for this currently is mission variables.

Parameters

  • num: Number to get time from.

Usage:

t = time.fromnumber( t:tonumber() ) -- Should get the time t again

Return value:

Time representing number.
time.get ()
Gets the current time in internal representation time.

Usage:

t = time.get()

Return value:

Time in internal representation time.
time.inc (t)
Increases or decreases the time.

Parameters

  • t: Amount to increment or decrement the time by.

Usage:

time.inc( time.create(0,0,100) ) -- Increments the time by 100 STU.
time.str (t, d)
Converts the time to a pretty human readable format.

Parameters

  • t: Time to convert to pretty format. If omitted, current time is used.
  • d: Decimals to use for displaying STU (should be between 0 and 5).

Usage

  • strt = time.str() -- Gets current time
  • strt = time.str( time.get() + time.create(0,5,0) ) -- Gets time in 5 STP
  • strt = t:str() -- Gets the string of t

Return value:

The time in human readable format.
time.sub (t1, t2)
Subtracts two time metatables. Overrides the subtraction operator.

Parameters

  • t1: Time metatable to subtract from.
  • t2: Time metatable subtracted.

Usage:

new_time = time.get() - time.create( 0, 3, 0 ) -- Subtracts 3 STP to the current date
time.tonumber (t)
Gets a number representing this time. The best usage for this currently is mission variables.

Parameters

  • t: Time to get number of.

Usage:

num = t:tonumber() -- Getting the number from a time t

Return value:

Number representing time.

Valid XHTML 1.0!