[TIMOB-14360] iOS: relativeOffSet in Calendar event does not return correct value greater than 2073600000 (24 days in mili seconds)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-07-23T21:30:28.000+0000 |
Affected Version/s | Release 3.1.0, Release 3.1.1 |
Fix Version/s | 2013 Sprint 15 API, 2013 Sprint 15, Release 3.2.0 |
Components | iOS |
Labels | calendar, ios, mobilesdk, ti.api |
Reporter | Ashish Nigam |
Assignee | Vishal Duggal |
Created | 2013-06-25T12:22:08.000+0000 |
Updated | 2014-06-19T12:43:01.000+0000 |
Description
Calendar-Event-Alert, relativeOffset value set greater than 24 days, does not work correctly when try to get the value.
Steps to reproduce:
1: Use the below code and copy paste that in app.js of a sample project.
2: launch the app (simulator/device) and press the calendar button.
3: check the console for Ti.API.info.
Correct Result will be printed if value is till 24 days (example value for 24 days).
[INFO] : alert1 before: 604800000 // i set 7 days
[INFO] : alert1 after : -604800000 // i get 7 days
[INFO] : alert2 before: 2073600000 // i set 24 days
[INFO] : alert2 after : 2073600000 // i get 24 days
if value is greater than 24 days then (example values for 26 days)
[INFO] : alert1 before: 604800000 // i set 7 days
[INFO] : alert1 after : -604800000 // i get 7 days
[INFO] : alert2 before: 2246400000 // i set 26 days
[INFO] : alert2 after : -2147483648 // i get -2147483648 as fixed value.
var win = Ti.UI.createWindow({
backgroundColor:"gray"
});
var btn = Ti.UI.createButton({
title:"calendar",
top:10,
height:100,
width:250,
left:10
});
btn.addEventListener("click",function(){
if (Ti.Calendar.eventsAuthorization == Ti.Calendar.AUTHORIZATION_AUTHORIZED) {
test_alerts();
} else {
Ti.Calendar.requestEventsAuthorization(function(e){
if (e.success) {
test_alerts();
} else {
alert('Access to calendar is not allowed');
}
});
}
function test_alerts()
{
var ical = Ti.Calendar.defaultCalendar;
var start_date = new Date();
var event = ical.createEvent({
title: 'Test event1',
begin: start_date,
end: new Date(start_date.getTime() + 15*60*1000),
availability: Ti.Calendar.AVAILABILITY_FREE,
allDay: false
});
var millis = 7*24*60*60*1000;
Ti.API.info('alert1 before: ' + millis);
var alert1 = event.createAlert({
relativeOffset:-millis //5 days before
});
Ti.API.info('alert1 after : ' + alert1.relativeOffset);
var millis2 = 26*24*60*60*1000;
Ti.API.info('alert2 before: ' + millis2);
var alert2 = event.createAlert({
relativeOffset:-millis2 //26 days before,
});
Ti.API.info('alert2 after : ' + alert2.getRelativeOffset()); // value should be similar to alert2 before value
event.alerts = [alert1, alert2];
event.save(Ti.Calendar.SPAN_FUTUREEVENTS);
}
});
win.add(btn);
win.open();
Pull pending https://github.com/appcelerator/titanium_mobile/pull/4471
@Betty Already fixed and should be available as part of CI on master(3.2)
Verified and Closed with environment: Appcelerator Studio: 3.2.0.201311122338 SDK:3.2.0.v20131113183932 alloy: 1.3.0 acs: 1.0.7 npm: 1.3.2 titanium: 3.2.0 titanium-code-processor: 1.1.0 Xcode:5.0.2 Device: Iphone 5s(v7.0.2) OS: Mac OSX 10.9 Working as expected in iOS.