모듈:DayCount: 두 판 사이의 차이
편집 요약 없음 |
편집 요약 없음 |
||
| (같은 사용자의 중간 판 하나는 보이지 않습니다) | |||
| 2번째 줄: | 2번째 줄: | ||
function p.daycount(frame) | function p.daycount(frame) | ||
local startDate = frame.args[1] | local startDate = frame.args[1] | ||
-- 현재 UTC 시간 | -- 현재 UTC 시간 | ||
local currentUtcTime = os.time(os.date("!*t")) | local currentUtcTime = os.time(os.date("!*t")) | ||
-- 한국 시간으로 변환 | -- 한국 시간으로 변환 | ||
local offsetSeconds = 9 * 60 * 60 | local offsetSeconds = 9 * 60 * 60 | ||
local koreanTime = currentUtcTime + offsetSeconds | local koreanTime = currentUtcTime + offsetSeconds | ||
-- 시작 날짜 | -- 시작 날짜 파싱 | ||
local year, month, day = startDate:match("(%d+)-(%d+)-(%d+)") | local year, month, day = startDate:match("(%d+)-(%d+)-(%d+)") | ||
if not year or not month or not day then | if not year or not month or not day then | ||
| 18번째 줄: | 17번째 줄: | ||
end | end | ||
-- 시작일을 현지 시간 기준으로 계산 (UTC 보정 제거) | |||
local startTime = os.time({ | local startTime = os.time({ | ||
year = tonumber(year), | year = tonumber(year), | ||
| 25번째 줄: | 25번째 줄: | ||
min = 0, | min = 0, | ||
sec = 0 | sec = 0 | ||
}) | }) | ||
-- 경과 일수 계산 | -- 경과 일수 계산 | ||
local diffSeconds = koreanTime - startTime | local diffSeconds = koreanTime - startTime | ||
local dayCount = math.floor(diffSeconds / (24 * 60 * 60)) | local dayCount = math.floor(diffSeconds / (24 * 60 * 60)) + 1 | ||
return tostring(dayCount) | return tostring(dayCount) | ||
2025년 5월 11일 (일) 22:53 기준 최신판
이 모듈에 대한 설명문서는 모듈: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