Can't insert all day event

158 views
Skip to first unread message

mdecaro

unread,
Jul 29, 2012, 6:04:28 PM7/29/12
to gdata-objec...@googlegroups.com
Using the sources.  Am unable to insert an all day vent.  Not using 'GD' methods as I have seen in some older posts, but 'GTL'.

I can insert a timed event without problems.

Any help would be appreciated.

Greg Robbins

unread,
Jul 29, 2012, 8:48:26 PM7/29/12
to gdata-objec...@googlegroups.com
For all-day events, be sure the start and end times specify no time:

startDateTime.hasTime = NO;
endDateTime.hasTime = NO;

All-day events are mentioned at


Incidentally, the discussion group for the JSON-based library is at http://groups.google.com/group/google-api-objectivec-client

mdecaro

unread,
Jul 30, 2012, 12:40:33 PM7/30/12
to gdata-objec...@googlegroups.com
I tried that and it did not work.  Otherwise followed the lead shown in the SampleCode

Greg Robbins

unread,
Jul 30, 2012, 3:24:36 PM7/30/12
to gdata-objec...@googlegroups.com
The calendar start and end objects, GTLCalendarEventDateTime, have separate fields for date-time objects with and without times. So to specify an event being all day, the fields with times should be nil:

  GTLDateTime *startDateTime = [GTLDateTime dateTimeWithDate:... timeZone:...];
  startDateTime.hasTime = NO;
  GTLDateTime *endDateTime = [GTLDateTime dateTimeWithDate:... timeZone:...];
  endDateTime.hasTime = NO;

  newEvent.start.dateTime = nil;
  newEvent.start.date = startDateTime;
  newEvent.end.dateTime = nil;
  newEvent.end.date = endDateTime;

mdecaro

unread,
Jul 30, 2012, 8:51:35 PM7/30/12
to gdata-objec...@googlegroups.com
It simply doesn't work.  Here is the code:

    GTLCalendarEvent *calEvent = [GTLCalendarEvent object];

    calEvent.summary = @"This is a test";

    calEvent.start = [GTLCalendarEventDateTime object];

    calEvent.end = [GTLCalendarEventDateTime object];

    calEvent.start.date = [GTLDateTime dateTimeWithDate:dt1 timeZone:[NSTimeZone systemTimeZone]];

    calEvent.start.date.hasTime = NO;

    calEvent.end.date = [GTLDateTime dateTimeWithDate:dt2 timeZone:[NSTimeZone systemTimeZone]];

    calEvent.end.date.hasTime = NO;

    calEvent.start.dateTime = nil;

    calEvent.end.dateTime = nil;

    calEvent.reminders = [GTLCalendarEventReminders object];

    calEvent.reminders.useDefault = [NSNumber numberWithBool:YES];

mdecaro

unread,
Jul 30, 2012, 8:59:07 PM7/30/12
to gdata-objec...@googlegroups.com
Forgot this:

    NSDate *dt1,*dt2;

    dt1 = [NSDate date];

    dt2 = [dt1 dateByAddingTimeInterval:24.0 * 60 * 60];

Thomas Van Lenten

unread,
Jul 30, 2012, 9:37:32 PM7/30/12
to gdata-objec...@googlegroups.com
On Mon, Jul 30, 2012 at 8:51 PM, mdecaro <matthew...@gmail.com> wrote:
It simply doesn't work.  Here is the code:

    GTLCalendarEvent *calEvent = [GTLCalendarEvent object];

    calEvent.summary = @"This is a test";

    calEvent.start = [GTLCalendarEventDateTime object];

    calEvent.end = [GTLCalendarEventDateTime object];

    calEvent.start.date = [GTLDateTime dateTimeWithDate:dt1 timeZone:[NSTimeZone systemTimeZone]];

    calEvent.start.date.hasTime = NO;

    calEvent.end.date = [GTLDateTime dateTimeWithDate:dt2 timeZone:[NSTimeZone systemTimeZone]];

    calEvent.end.date.hasTime = NO;


Put the GTLDateTimes into a local and set hasTime before you set them on the event.  The way it works right now, the updates to the GTLDateTime after it has been set aren't captured.

TVL

    calEvent.start.dateTime = nil;

    calEvent.end.dateTime = nil;

    calEvent.reminders = [GTLCalendarEventReminders object];

    calEvent.reminders.useDefault = [NSNumber numberWithBool:YES];




On Monday, July 30, 2012 3:24:36 PM UTC-4, Greg Robbins wrote:
The calendar start and end objects, GTLCalendarEventDateTime, have separate fields for date-time objects with and without times. So to specify an event being all day, the fields with times should be nil:

  GTLDateTime *startDateTime = [GTLDateTime dateTimeWithDate:... timeZone:...];
  startDateTime.hasTime = NO;
  GTLDateTime *endDateTime = [GTLDateTime dateTimeWithDate:... timeZone:...];
  endDateTime.hasTime = NO;

  newEvent.start.dateTime = nil;
  newEvent.start.date = startDateTime;
  newEvent.end.dateTime = nil;
  newEvent.end.date = endDateTime;

--
You received this message because you are subscribed to the Google Groups "Google Data APIs Objective-C Client Library Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/gdata-objectivec-client/-/T6qySrz85VgJ.

To post to this group, send email to gdata-objec...@googlegroups.com.
To unsubscribe from this group, send email to gdata-objectivec-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gdata-objectivec-client?hl=en.

Matthew DeCaro

unread,
Jul 30, 2012, 9:47:14 PM7/30/12
to gdata-objec...@googlegroups.com
That did it!!

Thanks.


______________________
Matthew DeCaro



mdecaro

unread,
Jul 31, 2012, 12:58:56 PM7/31/12
to gdata-objec...@googlegroups.com
Thanks.  Setting the GTLDateTime in a separate statement then setting start.date to that worked.

That doesn't make sense to me based on what I thought I knew of obj-c!  Any idea why?  I experimented and did start.date = [[GTLDateTime dateTimeWithDate:dt timeZone...]  retain] to no effect.

To post to this group, send email to gdata-objectivec-client@googlegroups.com.
To unsubscribe from this group, send email to gdata-objectivec-client+unsub...@googlegroups.com.

Thomas Van Lenten

unread,
Jul 31, 2012, 1:42:13 PM7/31/12
to gdata-objec...@googlegroups.com
On Tue, Jul 31, 2012 at 12:58 PM, mdecaro <matthew...@gmail.com> wrote:
Thanks.  Setting the GTLDateTime in a separate statement then setting start.date to that worked.

That doesn't make sense to me based on what I thought I knew of obj-c!  Any idea why?  I experimented and did start.date = [[GTLDateTime dateTimeWithDate:dt timeZone...]  retain] to no effect.

The value is copied out of the GTLDataTime when you set it on the event, so updating it after the fact is being ignored.

TVL
 
To view this discussion on the web visit https://groups.google.com/d/msg/gdata-objectivec-client/-/KLGZjsn5zNwJ.

To post to this group, send email to gdata-objec...@googlegroups.com.
To unsubscribe from this group, send email to gdata-objectivec-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages