Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:17:23+00:00 2026-06-04T07:17:23+00:00

If I create a new event on ICal and set it to be a

  • 0

If I create a new event on ICal and set it to be a all day event – my app shows that it lasts 2 days.

I used nslog to output startdate and enddate and for event on 8.5.2012 my application says event ends on 9.5.2012 at 21.00(9pm).

What causes this and what is the best way to convert start/enddate in my application to same values that are shown on iCal. Promblem exists only with all day events.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:17:24+00:00Added an answer on June 4, 2026 at 7:17 am

    Okay.. Here I have made some functions so other people strugling with the same problem could easily get some aid.

    - (NSDate *)changeDayBy:(NSDate *)current:(NSUInteger) change
    {
        NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
        [components setDay: change];
        return [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:current options:0];
    }
    
    - (BOOL) endDateNeedsAFix:(CalEvent *)event
        {
            if ( !event.isAllDay )
                return NO;
    
            NSDateComponents *comps1 = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:event.startDate] ;
            NSDateComponents *comps2 = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:event.endDate];
    
            return [[[NSCalendar currentCalendar] dateFromComponents: comps2] timeIntervalSinceDate: [[NSCalendar currentCalendar] dateFromComponents: comps1]] / ( 60*60*24) > 0 ? YES : NO;
    
        }
    
        - (NSDate*) endDateFixed:(CalEvent *)event
        {
            if ( !event.isAllDay )
                return event.endDate;
    
            NSDateComponents *comps1 = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:event.startDate];
            NSDateComponents *comps2 = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:event.endDate];
    
            if ( [[[NSCalendar currentCalendar] dateFromComponents: comps2] timeIntervalSinceDate: [[NSCalendar currentCalendar] dateFromComponents: comps1]] / ( 60*60*24) > 0 )
                return [self changeDayBy:event.endDate :-1];
    
            return event.endDate;
        }
    

    Function endDateNeedsAFix reports if fix is needed for selected calEvent* event. It’s helpful if application has some kind of event editor where end date is shown fixed, before saving changes, check if fix is needed and then use changeDayBy to add +1 to date.

    endDateFixed returns NSDate from event’s endDate – if not necessary, as unchanged – but if needed – it will be fixed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Versioning If your events changes you would create a new version of that event,
In my Silverlight app I have an event handler that dynamically creates a new
How do I create a new event in a base page class that fires
I am trying to create new Event objects to be persisted in the database
I want to create a new event for TFileListBox. I want to know when
To create a new event handler on a control you can do this c.Click
I would like to create a new event-dispatch thread in Swing, and I'm having
I am trying to use the Zend_Gdata_Calendar library to create a new event on
How can I combine two events and create a new event ? e.g :
i need some help understanding how i can create a new custom event. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.