local g_CurrTime = os.time() -- 현재 시간
local DAY_SEC = 86400
local EVERY_WEEK = 1 -- 0 : 일 ~ 6 : 토
local EVERY_HOUR = 0 -- 0 ~ 23 시
local tmStartDate = 1649548800 -- 2022.04.10. Hour(9)
local tmEndDate = 1649548800 + ( 86400 * 15 ) -- 2022.04.25. Hour(9)
-- %w : 요일 (0 : 일 ~ 6 : 토)
local currentWeekDay = tonumber( os.date( "%w", g_CurrTime ) )
local startWeekDay = tonumber( os.date( "%w", tmStartDate ) )
local everyWeek = EVERY_WEEK
-- %H : 시간 (0 ~ 23)
local currentHour = tonumber( os.date("%H", g_CurrTime ) )
local startHour = tonumber( os.date( "%H", tmStartDate ) )
local everyHour = EVERY_HOUR
print( "TEST!!!!! customDate(%d) tmStartDate(%d) GetCurrentWeek(%d) startWeekDay(%d) currentWeekDay(%d) everyWeek(%d) startHour(%d) currentHour(%d) everyHour(%d)",
DAY_SEC, tmStartDate, GetCurrentWeek(), startWeekDay, currentWeekDay, everyWeek, startHour, currentHour, everyHour )
-- Time 가산 테스트
local startDate = tmStartDate + DAY_SEC
local baseDate = os.date( "*t", startDate )
print( "TEST_1!!!!! NowDate+ Year(%d) Month(%d) Day(%d) Hour(%d) week(%d)",
baseDate.year, baseDate.month, baseDate.day, baseDate.hour, baseDate.wday )
-- Time 차감 테스트
local startDate2 = tmStartDate - DAY_SEC
local baseDate2 = os.date( "*t", startDate2 )
print( "TEST_2!!!!! NowDate- Year(%d) Month(%d) Day(%d) Hour(%d) week(%d)",
baseDate2.year, baseDate2.month, baseDate2.day, baseDate.hour, baseDate2.wday )
-- 기본 Time 출력
local baseStartDate = os.date( "*t", tmStartDate )
print( "TEST_3!!!!! tmStartDate Year(%d) Month(%d) Day(%d) Hour(%d) week(%d)",
baseStartDate.year, baseStartDate.month, baseStartDate.day, baseStartDate.hour, baseStartDate.wday )
------------------------------------------
-- [ Print ]
-- TEST!!!!! customDate(86400) tmStartDate(1649548800) startWeekDay(0) GetCurrentWeek(3) currentWeekDay(3)
everyWeek(1) startHour(9) currentHour(21) everyHour(0)
-- TEST_1!!!!! NowDate+ Year(2022) Month(4) Day(11) Hour(9) week(2)
-- TEST_2!!!!! NowDate- Year(2022) Month(4) Day(9) Hour(9) week(7)
-- TEST_3!!!!! tmStartDate Year(2022) Month(4) Day(10) Hour(9) week(1)
------------------------------------------
참고 : Mi_Q Kingdom :: [Lua] 매주 이벤트(퀘스트) 주차 초기화 계산. (tistory.com)
'[ Programing ] > Lua Scirpt' 카테고리의 다른 글
[Lua] Sleep (0) | 2023.02.28 |
---|---|
[Lua] 형변환 (1) | 2022.11.10 |
[Lua] 매주 이벤트(퀘스트) 주차 초기화 계산. (0) | 2022.04.21 |
[Lua] 날짜와 시간 함수. (0) | 2022.04.11 |
Lua - 루아 스크립트 함수를 C++에서 호출하여 활용 (0) | 2022.03.06 |