Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Today date is not selected if I set todays date as default date #20

Open
fparkar opened this issue Nov 10, 2016 · 1 comment
Open

Today date is not selected if I set todays date as default date #20

fparkar opened this issue Nov 10, 2016 · 1 comment

Comments

@fparkar
Copy link

fparkar commented Nov 10, 2016

If we have below line then we can't highlight todays date...

[self.datepicker selectDate:[NSDate date]];

It always appear White text color and white background..

please fix it...

@johndpope
Copy link

johndpope commented Jan 16, 2017

problem is related to how the dates are stored internally - self.dates ( has an array of dates with corresponding times) - if you remove the time element - it may fix it.

When you populate the control - strip out the time.
Then pass in corresponding date without time.

+(NSDate *)dateWithOutTime:(NSDate *)datDate{
    if( datDate == nil ) {
        datDate = [NSDate date];
    }
    NSDateComponents* comps = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate:datDate];
    [comps setHour:00];
    [comps setMinute:00];
    [comps setSecond:00];
    [comps setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
    
    return [[NSCalendar currentCalendar] dateFromComponents:comps];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants