语言

Menu
Sites
Language
Strange tizen.alarm.getAll() behaviour

Hi,

 
It looks like tizen.alarm.getAll() is reporting wrong alarm time.
Here is a sample code
tizen.alarm.add(newAlarm, "vrpbxib8us.fdsp", newAlarmArguments);
console.log("adding alarm "+JSON.stringify(newAlarm));
console.log(JSON.stringify(tizen.alarm.getAll()));

here is the console output :

wgt/js/main.js (209) :adding alarm {"daysOfTheWeek":[],"date":"2013-07-05T10:48:59.000Z","id":"263832","period":604800} 
wgt/js/main.js (212) :[{"daysOfTheWeek":[],"date":"2013-07-05T11:48:59.000Z","id":"263832","period":604800}]
 
Looks like 1 hour was magically added during the process. By the way, the alarm fires at the right time (ie 10:48:59 UTC).
But the problem is that if want to use the  date value of stored alarms for some processing in my app, I need to substract 1 hour, and i'm a bit worried about my code being broken in future tizen versions.
 
Regards,
 
P.S : I'm using 2.1 sdk and with a developper device.
 

 

 

 

编辑者为: Brock Boland 17 3月, 2014 原因: Paragraph tags added automatically from tizen_format_fix module.

响应

3 回复
konduri sai swathi
Hi , I have tried it and understood that according to your time zone it gets changed , for example my time zone is kolkata which is GMT+5:30 , so when i add alarm for 11:30 it displays as 6:00 . I guess the only way is to subtract that extra time .
Jean-Philippe Vignolo
In fact, my timezone is UTC+2 Both date in the output are UTC (it's what the Z means at the end of the date). I don't know if it's a bug or a feature but I see no valid reasons to have this +1 hour added by the getAll() call. If fact tizan.alarm.get(id) also add this hour. When I did my testing it was, 12:48 (GMT+2) so the first output is correct (10:48 UTC). here is a more detailed code showing what's happening :
var oneMinuteLater = new Date();
oneMinuteLater.setMinutes(oneMinuteLater.getMinutes() + 1);
var newAlarm = new tizen.AlarmAbsolute(oneMinuteLater,tizen.alarm.PERIOD_WEEK);
console.log("oneMinuteLater "+oneMinuteLater);
tizen.alarm.add(newAlarm, "vrpbxib8us.fdsp", newAlarmArguments);
console.log("adding alarm "+JSON.stringify(newAlarm));
console.log(JSON.stringify(tizen.alarm.getAll()));
and the output
wgt/js/main.js (203) :oneMinuteLater Fri Jul 05 2013 14:31:32 GMT+0200 (CEST)
wgt/js/main.js (210) :adding alarm {"daysOfTheWeek":[],"date":"2013-07-05T12:31:32.000Z","id":"278944","period":604800}
wgt/js/main.js (213) :[{"daysOfTheWeek":[],"date":"2013-07-05T13:31:32.000Z","id":"278944","period":604800}]
So as you can see, the new Date() is 14:31 GMT+2 , it's correctly converted in 12:31 UTC by new tizen.AlarmAbsolute(). But then it suddenly becomes 13:31 utc after the tizen.alarm.getAll(); Again, the system correctly fires the alarm at 12:31 utc.
konduri sai swathi
Hi , Even i'm not sure why this issue is coming , if you think it's a bug then kindly log an issue and raise bug in JIRA and follow that for updates .