블로그는 나의 힘!
[ Programing ]/Lua Scirpt2022. 11. 10. 09:54

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)

 

[Lua] 매주 이벤트(퀘스트) 주차 초기화 계산.

 TIME_MINUTE = 60      TIME_HOUR = TIME_MINUTE * 60      TIME_DAY = TIME_HOUR * 24      TIME_WEEK = TIME_DAY * 7      -- 현재 시간      g_CurrentTime = os.t..

goguri.tistory.com



 

Posted by Mister_Q