2012-07-18 8 views
0

내 코로나 앱에서 사용자가 설정 한 특정 시간에 로컬 알림을 설정합니다. 나는 기본 통지는 다음과 같은 가이드를 사용하여, 작업이 : http://developer.coronalabs.com/reference/index/systemschedulenotification기본 시간을 Corona 로컬 알림의 날짜 테이블로 변환합니다.

local utcTime = os.date("!*t", os.time() + 60) 
local notification = system.scheduleNotification(utcTime, options) 

하지만 OS의 자리를 차지할, 사용자가 선택한 시간이 걸릴 및 coordinatedUniversalTime 형식의 날짜 테이블을 구성합니다. time() + 위 코드의 60 부분. 누구든지 그 일을 어떻게 알아?

시간 선택기가 기본 시간과 분 값을 반환하고 AM인지 PM인지를 나타냅니다.

감사합니다.

+0

오늘 밤 시험해 볼 날짜 모듈을 찾았습니다. http://math2.org/luasearch-2/luadist-extract/luadate-2.dist/luadate-2.src/date.doc.htm –

답변

0

바로 알기 쉽습니다.

local options = { 
      alert = "Alert Text", 
      sound = "audio/sound.caf" 
     } 

     local currentDate = os.date("*t") 
     local notificationHr 
     if reminderPicker1.getAMPM() == "am" then 
      notificationHr = reminderPicker1.getHour() 
     else 
      notificationHr = reminderPicker1.getHour() + 12 
     end 
     local utcTime = os.date("!*t", os.time{year=currentDate.year, month=currentDate.month, day=currentDate.day, hour=notificationHr, min=reminderPicker1.getMin(), sec=0 }) 
     local notification = system.scheduleNotification(utcTime, options) 
+0

문제가 해결되었으므로 스스로 대답을 받아 들여야합니다. 이것은 SO 지식 기반을 향상시킬 것입니다. –

+0

이것은 나를 도왔습니다. 하지만 여기에 더 많은 도움이 있습니다. https://forums.coronalabs.com/topic/59921-get-local-notification-daily-and-weekly-between-2-dates/ 그리고이 코드는주의해야합니다. 12는 특별한 예외. 12시에서 12 시까 지를 더하면 24시에 자정입니다. 12시에 12시 추가하지 않고 12시를 떠나면 실제로 정오 인 12시에 머물러있게됩니다. – RanLearns

관련 문제