Module TIME

TIME

This class allows to work with TIME objects.

All TIME objects are float number. Since all TIME objects are 32 bit signed, there are two limitations for values allowed:

-The MAXIMUM TIME value allowed is the number 2147483647 (t_max = TIME.new(2147483647))

-The MINIMUM TIME value allowed is the number -2147483647 (t_min = TIME.new(-2147483647))

Class TIME

time:new ([octet]) Create a new time.
time:detect_time_value (t) It checks if the given input (either a number or a string) falls within a specific range of time values.
time:__add (t2) Allow to do the sum between two time object.
time:__sub (t2) Allow to subtract two time object.
time:__unm () Calculate the opposite of a time object.
time:__eq (t2) Given two time objects, it checks if they are equal.
time:__lt () Given two time object it checks if the first one is less (<) then the second one
time:__lte () Given two time object it checks if the first one is less (<=) then the second one
time:__tostring () This method converts a time object to a string


Class TIME

Global TIME Functions
time:new ([octet])
Create a new time. If an argument is present, import it as OCTET and initialise it with its value.

Parameters:

  • octet value (32 bit) (optional)

Returns:

    a new float number
time:detect_time_value (t)
It checks if the given input (either a number or a string) falls within a specific range of time values.

Parameters:

  • t a time value

Returns:

    a boolean value: true if the time value is too much big or too much low. false, otherwise
time:__add (t2)
Allow to do the sum between two time object.

Parameters:

  • t2 the time to sum

Returns:

    return the sum if it allowed. It might be return the error message "Result of addition out of range" if the result of the sum is too much big

Usage:

    oct1 = OCTET.random(4)
    oct2 = OCTET.random(4)
    t1 = time.new(oct1)
    t2 = time.new(oct2)
    sum = t1:__add(t2)	
time:__sub (t2)
Allow to subtract two time object.

Parameters:

  • t2 the time to subtract

Returns:

    return the subtraction if it allowed. It might be return the error message "Result of subtraction out of range" if the result of the subtraction is too much big

Usage:

    The same of the method __add()
time:__unm ()
Calculate the opposite of a time object.

Returns:

    the opposite a time object

Usage:

    oct1 = OCTET.random(4)
    t1 = time.new(oct1)
    opp = t1:__unm() 	
time:__eq (t2)
Given two time objects, it checks if they are equal.

Parameters:

  • t2

Returns:

    a boolean value "true" if they are equal, "false" otherwise

Usage:

    oct1 = OCTET.random(4)
    t1 = time.new(oct1)
    bool = t1:__eq(t1)
    if bool then print("true")		--Output: true
    else print("false")
    end
time:__lt ()
Given two time object it checks if the first one is less (<) then the second one

Returns:

    a boolean value "true" if the first argument is less than the second one, "false" otherwise

Usage:

    The same of :__eq()
time:__lte ()
Given two time object it checks if the first one is less (<=) then the second one

Returns:

    a boolean value "true" if the first argument is less or equal than the second one, "false" otherwise

Usage:

    The same of :__eq()
time:__tostring ()
This method converts a time object to a string

Returns:

    the string representation of a time object

Usage:

    oct1 = OCTET.random(4)
    t1 = time.new(oct1)
    t1:__tostring()	
generated by LDoc 1.5.0 Last updated 2025-03-25 10:43:18