Alarm clock

Im trying to build an alarm clock, using notifications as the trigger on when the alarm should go off. Im having a hard time to figure out how i should do to compare the time from when the alarm is set, and compare that to the time when the alarm should go off. As i understand the notification should be feed with seconds from now, when the notification should go off.

How should i do to compare the time now with the time the alarm is set to go off, i want to use a 24 h time?

For example

Alarm set         Alarm rings         Diff

21:59:23          07:00                  ?

Is notifications the best way to build an alarm clock or is there another solution that would do a better job?

Have you read this blog post:

http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Thanks, that helped. But is there a nicer way to do the comparisons than this? 

local Hour = 7 local Minutes = 0 local date = os.date( "\*t" ) local DAYSEC = 24\*3600 local TimeNow = (date.hour \* 3600) + (date.min \* 60) + date.sec local AlarmTime = (Hour \* 3600) + (Minutes \* 60) local SecondsToAdd = 0 if TimeNow \< AlarmTime then SecondsToAdd = AlarmTime - TimeNow else SecondsToAdd = DAYSEC - TimeNow SecondsToAdd = SecondsToAdd + AlarmTime end local notificationId = system.scheduleNotification( SecondsToAdd, options )

Is notifications the best use for an alarm clock or would a timer be a better choice, or is there another option?

Have you read this blog post:

http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/

Thanks, that helped. But is there a nicer way to do the comparisons than this? 

local Hour = 7 local Minutes = 0 local date = os.date( "\*t" ) local DAYSEC = 24\*3600 local TimeNow = (date.hour \* 3600) + (date.min \* 60) + date.sec local AlarmTime = (Hour \* 3600) + (Minutes \* 60) local SecondsToAdd = 0 if TimeNow \< AlarmTime then SecondsToAdd = AlarmTime - TimeNow else SecondsToAdd = DAYSEC - TimeNow SecondsToAdd = SecondsToAdd + AlarmTime end local notificationId = system.scheduleNotification( SecondsToAdd, options )

Is notifications the best use for an alarm clock or would a timer be a better choice, or is there another option?