将选择的基本时间转换为适用于 Corona 本地通知的日期表。

我希望在自己的 Corona 应用程序中以用户设置的特定时间设置本地通知。我已经使用以下指南使基本通知工作: http://developer.coronalabs.com/reference/index/systemschedulenotification

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

但我想采用用户选择的时间,并构建一个协调通用时间格式的日期表,以取代上述代码中的 os.time() + 60 部分。有谁知道如何做到这一点吗?

我的时间选择器返回基本的小时和分钟值,以及AM或PM。

谢谢!

点赞
用户608478
用户608478

好的,明白了,这很简单。

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)
2012-07-21 18:32:49