Anonymous

Module:TimeSpan/doc: Difference between revisions

From Melvor Idle
(Created page with "== TimeSpan Module Documentation == The 'TimeSpan' module provides functionality for working with time spans in Lua. === Constructor === ====TimeSpan.new(days, hours, minutes, seconds, milliseconds)==== Creates a new 'TimeSpan' object representing the specified time components. * '''Parameters:''' * `'days'`: Number of days (default: `0`). * `'hours'`: Number of hours (default: `0`). * `'minutes'`: Number of minutes (default: `0`). * `'seconds'`: Number of s...")
 
Line 118: Line 118:


-- Get specific components of the TimeSpan
-- Get specific components of the TimeSpan
local days = ts:getDays()
print("Days:", ts:getDays())  -- Output: 1
local hours = ts:getHours()
print("Hours:", ts:getHours())  -- Output: 2
local minutes = ts:getMinutes()
print("Minutes:", ts:getMinutes())  -- Output: 30
local seconds = ts:getSeconds()
print("Seconds:", ts:getSeconds())  -- Output: 15
local milliseconds = ts:getMilliseconds()
print("Milliseconds:", ts:getMilliseconds())  -- Output: 500
 
-- Output the TimeSpan components
print("Days:", days)  -- Output: 1
print("Hours:", hours)  -- Output: 2
print("Minutes:", minutes)  -- Output: 30
print("Seconds:", seconds)  -- Output: 15
print("Milliseconds:", milliseconds)  -- Output: 500


-- Get the total number of hours represented by the TimeSpan
-- Get the total number of hours represented by the TimeSpan
1,048

edits