[TIMOB-14953] iOS: Ti.Calendar getEventsBetweenDates is not working
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-02-22T19:48:39.000+0000 |
| Affected Version/s | Release 3.2.0 |
| Fix Version/s | Release 5.4.0 |
| Components | iOS |
| Labels | defect, ios, qe-5.4.0 |
| Reporter | Dan Tamas |
| Assignee | Angel Petkov |
| Created | 2013-08-19T14:22:20.000+0000 |
| Updated | 2016-08-08T19:25:52.000+0000 |
Description
on iOS getEventsBetweenDates method is not working:
- it is misspelled: **getEventsBeteenDates** (missing "w")
- if I call the method this way, no matter what I'm trying to put as arguments (dates or strings) is not working
if I put a strings (like "2014-02-19T16:17:46+01:00") I get
"*** -[EKEventStore predicateForEventsWithStartDate:endDate:calendars:]: startDate is nil";
if I put dates I get
message = "Invalid type passed to function";
nativeLocation = "-[TiCalendarCalendar getEventsBeteenDates:] (TiCalendarCalendar.m:157)";
nativeReason = "expected: String, was: __NSDate";
Here is the fix for now... After fixing the misspelling in TiCalendarCalendar.m, the getEventsBetweenDates is expecting two date strings in full UTC format like so: yyyy-MM-ddTHH:mm:ss.SSS+0000 My javascript example:
Works perfectly.var date1 = new Date(); var date2 = new Date(); date2.setHours(date1.getHours() + 24); var date1ISO = date1.toISOString(); var date2ISO = date2.toISOString(); date1ISO = date1ISO.replace("Z", "+0000"); date2ISO = date2ISO.replace("Z", "+0000"); var events = Ti.Calendar.defaultCalendar.getEventsBetweenDates(date1ISO, date2ISO);Hi Sean, thnx for the workaround. I use a module for now but this needs to be fixed.
This is still an issue. Could we get a fix in place for this?
Has there been any updates in regards to the spelling issue here? This bug is of low priority, but it forces developers to make the fix themselves when they update Titanium/add new developers to their project. Thanks!
+1 We encountered this last year, and it still is a very serious pain that we need to modify the file in the titanium library folder every time we want to use a new build of the platform. What is the time frame for this fix? It seems to be a simple mispelling as @Melissa said above.
Changes spelling and did a change so you can pass in Date objects and strings , instead of just strings.
PR pending: https://github.com/appcelerator/titanium_mobile/pull/7756var date1 = new Date(new Date().getTime() + 3000), date2 = new Date(new Date().getTime() + 900000); date3 = new Date(new Date().getTime() + 1000000); Ti.API.info(date1); defCalendar = null; if (Ti.Calendar.hasCalendarPermissions()) { getEventsBetweenDates(); performCalendarReadFunctions(); } else { Ti.Calendar.requestCalendarPermissions(function(e) { if (e.success) { getEventsBetweenDates(); performCalendarReadFunctions(); } else { Ti.API.error(e.error); alert('Access to calendar is not allowed'); } }); } function getEventsBetweenDates() { defCalendar = Ti.Calendar.defaultCalendar; var event1 = defCalendar.createEvent({ title: 'Sample Event', notes: 'This is a test event which has some values assigned to it.', location: 'Appcelerator Inc', begin: date1, end: date2, availability: Ti.Calendar.AVAILABILITY_FREE, allDay: false, }); var event2 = defCalendar.createEvent({ title: 'Sample Event', notes: 'This is a test event which has some values assigned to it.', location: 'Appcelerator Inc', begin: date2, end: date3, availability: Ti.Calendar.AVAILABILITY_FREE, allDay: false, }); event1.save(Ti.Calendar.SPAN_THISEVENT); event2.save(Ti.Calendar.SPAN_THISEVENT); } function performCalendarReadFunctions() { // date2.setHours(date1.getHours() + 24); var date1ISO = date1.toISOString(); var date2ISO = date2.toISOString(); date1ISO = date1ISO.replace("Z", "+0000"); date2ISO = date2ISO.replace("Z", "+0000"); var events = defCalendar.getEventsBetweenDates(date1, date2); Ti.API.info(events); Ti.API.info(events.length); }[~ndustri] [~rborn] Can you validate that the PR is working for your use cases as well? I need to setup some demo dates first to finish CR and FT on this ticket. Thanks guys!
(y)(y)
Verified as fixed. Tested On: iPhone 6S (9.3.3) Device Mac OSX El Capitan 10.11.6 Ti SDK: 5.4.0.v20160804185318 Appc Studio: 4.7.0.201607250649 Appc NPM: 4.2.7 App CLI: 5.4.0-40 Xcode 7.3.1 Node v4.4.7 *Closing ticket.*