-
Notifications
You must be signed in to change notification settings - Fork 6
TimeDelta
Nak edited this page Sep 18, 2022
·
13 revisions
TimeDelta is a simple object to hold the duration of time.
It supports +(addition), -(subtraction), * (multiplication), / (division), and ^(exponents); other Number's or TimeDelta's.
TimeDelta objects can also be compared with each other.
if( [TimeDelta] > [TimeDelta] ) then print("The first TimeDelta is larger") end
if( [TimeDelta] == [TimeDelta] ) then print("The two TimeDelta are the same") end
if( [TimeDelta] < [TimeDelta] ) then print("The first TimeDelta is smaller") end
TimeDelta will also format the time when using tostring( TimeDelta ).
print( "Time: " .. NikNaks.TimeDelta( 176520 ) ) -> "Time: 2 days, 1 hour and 2 minutes"
Returns | Functions | Description |
---|---|---|
TimeDelta | NikNaks.TimeDelta( Number seconds ) | Returns a timedelta object. |
-
NikNaks.TimeDelta.Milisecond
= 0.001 -
NikNaks.TimeDelta.Second
= 1 -
NikNaks.TimeDelta.Minute
= 60 -
NikNaks.TimeDelta.Hour
= 3600 -
NikNaks.TimeDelta.Day
= 86400 -
NikNaks.TimeDelta.Week
= 604800 -
NikNaks.TimeDelta.Year
= 31535965 -
NikNaks.TimeDelta.Decade
= 315359654 -
NikNaks.TimeDelta.Century
= 3153596543
Note: Year, Decade and Century variables are rounded and will not count leap-years. You would have to parse in the two dates using DateTime and compare to get the correct variables;
print("Time until 2033: " .. NikNaks.DateTime( ):TimeUntil( NikNaks.DateTime("2033") )) -> "Time until 2033: 10 years, 107 days, 9 hours and 53 seconds"
Returns | Functions | Description |
---|---|---|
Table | TimeDelta:Totable() | Formats the time into a table with key-values matching the highest value. |
Bool | TimeDelta:IsPositive() | Returns true if the duration of time is positive. |
Bool | TimeDelta:IsNegative() | Returns true if the duration of time is negative. |
self | TimeDelta:AddMiliseconds( Number miliseconds) | Adds the given miliseconds. |
self | TimeDelta:AddSeconds( Number seconds) | Adds the given seconds. |
self | TimeDelta:AddMinutes( Number minutes) | Adds the given minutes. |
self | TimeDelta:AddHours( Number hours) | Adds the given hours. |
self | TimeDelta:AddDays( Number days) | Adds the given days. |
self | TimeDelta:AddWeeks( Number weeks) | Adds the given weeks. |
self | TimeDelta:AddYears( Number years) | Adds the given years. |
self | TimeDelta:AddDecades( Number decades) | Adds the given decades. |
self | TimeDelta:AddCenturies( Number centuries) | Adds the given centuries. |
self | TimeDelta:RemoveMiliseconds( Number miliseconds) | Removes the given miliseconds. |
self | TimeDelta:RemoveSeconds( Number seconds) | Removes the given seconds. |
self | TimeDelta:RemoveMinutes( Number minutes) | Removes the given minutes. |
self | TimeDelta:RemoveHours( Number hours) | Removes the given hours. |
self | TimeDelta:RemoveDays( Number days) | Removes the given days. |
self | TimeDelta:RemoveWeeks( Number weeks) | Removes the given weeks. |
self | TimeDelta:RemoveYears( Number years) | Removes the given years. |
self | TimeDelta:RemoveDecades( Number decades) | Removes the given decades. |
self | TimeDelta:RemoveCenturies( Number centuries) | Removes the given centuries. |
Number | TimeDelta:GetMiliseconds( Number miliseconds) | Returns the time as miliseconds. |
Number | TimeDelta:GetSeconds( Number seconds) | Returns the time as seconds. |
Number | TimeDelta:GetMinutes( Number minutes) | Returns the time as minutes. |
Number | TimeDelta:GetHours( Number hours) | Returns the time as hours. |
Number | TimeDelta:GetDays( Number days) | Returns the time as days. |
Number | TimeDelta:GetWeeks( Number weeks) | Returns the time as weeks. |
Number | TimeDelta:GetYears( Number years) | Returns the time as years. |
Number | TimeDelta:GetDecades( Number decades) | Returns the time as decades. |
Number | TimeDelta:GetCenturies( Number centuries) | Returns the time as centuries. |
- BitBuffer
- BSP Parser
- DateTime and Date-Functions
- TimeDelta
-
PathFinding (Coming soon)
- LPathFollower (Coming soon)
- NodeGraph (Coming soon)
- NikNav ( NikNaks Navigation ) on ToDo
- Extended functions (Coming soon)