Our World of Text:Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Dat Hack3r (talk | contribs) (:P) |
||
Line 1: | Line 1: | ||
= | local p = {} | ||
-- Function to calculate the week number based on a given date | |||
function p.getPreviousWeekNumber(frame) | |||
-- Define the start date of Week 1 | |||
local week1Start = os.time{year=2024, month=9, day=8} | |||
-- Convert the current date to time format | |||
local currentDateTime = os.time{year=currentDate.year, month=currentDate.month, day=currentDate.day} | |||
-- Calculate the difference in days from the start of Week 1 | |||
local daysDifference = os.difftime(currentDateTime, week1Start) / (24 * 60 * 60) | |||
-- Calculate the week number (rounding down to get integer weeks) | |||
local currentWeek = math.floor(daysDifference / 7) + 1 | |||
-- Calculate the previous week number | |||
local previousWeek = math.max(currentWeek - 1, 1) -- Ensure it doesn't go below 1 | |||
return 'Weekly Briefing Release'..previousWeek | |||
end | |||
return p |
Revision as of 10:14, 13 November 2024
local p = {}
-- Function to calculate the week number based on a given date function p.getPreviousWeekNumber(frame)
-- Define the start date of Week 1 local week1Start = os.time{year=2024, month=9, day=8} -- Convert the current date to time format local currentDateTime = os.time{year=currentDate.year, month=currentDate.month, day=currentDate.day} -- Calculate the difference in days from the start of Week 1 local daysDifference = os.difftime(currentDateTime, week1Start) / (24 * 60 * 60) -- Calculate the week number (rounding down to get integer weeks) local currentWeek = math.floor(daysDifference / 7) + 1 -- Calculate the previous week number local previousWeek = math.max(currentWeek - 1, 1) -- Ensure it doesn't go below 1 return 'Weekly Briefing Release'..previousWeek
end
return p