βοΈBasic Usage
In this section, you will see some example on how the function will be use.
GetCurrentDateUnit:
The code below will print out the date today, the day of this week, the month of the date, the day of the month, and the year of the date.
local TimeUtilityModule = require('MODULE PATH GOES HERE')
local AllDateUnit = TimeUtilityModule.GetCurrentDateUnit('All')
local DayOfWeek, Month, DayOfMonth, Year = TimeUtilityModule.GetCurrentDateUnit('DayOfWeek'), TimeUtilityModule.GetCurrentDateUnit('Month'), TimeUtilityModule.GetCurrentDateUnit('DayOfMonth'), TimeUtilityModule.GetCurrentDateUnit('Year')
print(AllDateUnit) --- Monday February 12 2024
print(DayOfWeek) --- Monday
print(Month) --- February
print(DayOfMonth) --- 12
print(Year) --- 2024FormatSecondToTime:
The function below will format 60 seconds, 120 seconds, 30 seconds, and 210 seconds into the correct time unit.
local TimeUtilityModule = require('MODULE PATH GOES HERE')
local one_minute = 60
local two_minute = one_minute * 2
local thirty_seconds = 30
print(TimeUtilityModule.FormatSecondToTime(one_minute, 'Colons') -- 1:00
print(TimeUtilityModule.FormatSecondToTime(two_minute, 'Colons') -- 2:00
print(TimeUtilityModule.FormatSecondToTime(thirty_seconds, 'Colons') -- 30
print(TimeUtilityModule.FormatSecondToTime(one_minute + two_minute + thirty_seconds, 'Colons') -- 3:30
print(TimeUtilityModule.FormatSecondToTime(one_minute, 'Time_Units') -- 1 minute
print(TimeUtilityModule.FormatSecondToTime(two_minute, 'Time_Units') -- 2 minutes
print(TimeUtilityModule.FormatSecondToTime(thirty_seconds, 'Time_Units') -- 30 seconds
print(TimeUtilityModule.FormatSecondToTime(one_minute + two_minute + thirty_seconds, 'Time_Units') -- 3 minutes 30 secondsConvertTimeUnitToSecond:
The code below will convert 10 seconds, 1 minute, 1 hour, 1 day, 1 week, 1 month, 1 year, 1 decade, and 1 millennium to the second unit.
MarkTimestamp:
This function is a custom wait()function. Basically what it does is use a repeat loop to yield the code until the os.time() is equal to the sum of the marked timestamp and the given second(s).
ViewMarkedTimeStamps:
The code below will let you see all the marked timestamps after MarkTimestamp "A" and then wait for 3 seconds then MarkTimestamp "B" and ViewMarkedTimestamps.
GetElapsedSecondSinceTimestamp
The code below will count elapsed second(s) since the timestamp got marked.
GetMarkedTimestamp
The code below will get the marked timestamp by marking a timestamp name "Test1' and calling the GetMarkedTimestamp function from the module.
UpdateMarkedTimestamp
The code below will mark a timestamp name "TestStamp" and then update the time stamp and print it after 5 seconds have passed.
instead
Last updated