모듈:DayCount
이 모듈에 대한 설명문서는 모듈:DayCount/설명문서에서 만들 수 있습니다
local p = {}
function p.daycount(frame)
local startDate = frame.args[1]
-- 현재 UTC 시간
local currentUtcTime = os.time(os.date("!*t"))
-- 한국 시간으로 변환
local offsetSeconds = 9 * 60 * 60
local koreanTime = currentUtcTime + offsetSeconds
-- 시작 날짜 파싱
local year, month, day = startDate:match("(%d+)-(%d+)-(%d+)")
if not year or not month or not day then
return "Invalid date format. Please use YYYY-MM-DD."
end
-- 시작일을 현지 시간 기준으로 계산 (UTC 보정 제거)
local startTime = os.time({
year = tonumber(year),
month = tonumber(month),
day = tonumber(day),
hour = 0,
min = 0,
sec = 0
})
-- 경과 일수 계산
local diffSeconds = koreanTime - startTime
local dayCount = math.floor(diffSeconds / (24 * 60 * 60)) + 1
return tostring(dayCount)
end
return p