Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date picker - Invalid parameter not satisfying: date #134

Open
RohiniBasavarajNataraj opened this issue Oct 27, 2015 · 8 comments
Open

date picker - Invalid parameter not satisfying: date #134

RohiniBasavarajNataraj opened this issue Oct 27, 2015 · 8 comments

Comments

@RohiniBasavarajNataraj
Copy link

Hi,
pickerDate function is called on onclick event.
Code shows the date picker for twice and then shows Invalid parameter not satisfying: date exception in Xcode. Please help

Please see the below code
var options = {
date: new Date(),
locale: "en_us"
mode : 'date',
allowOldDates: false,
allowFutureDates: true,
doneButtonLabel: 'DONE',
cancelButtonLabel: 'CANCEL'
};

function onSuccess(date) {
alert(date);
}

function onError(error) { // Android only
alert('Error: ' + error);
}

$scope.pickerDate = function() {
alert("date");
datePicker.show(options, onSuccess, onError);
};

Thanks in advance.

@FWiner
Copy link

FWiner commented Oct 28, 2015

+1

@FWiner
Copy link

FWiner commented Nov 2, 2015

5 days later.....

@VitaliiBlagodir
Copy link
Owner

Hi! Sorry, I haven't time for it.
If someone has the solution, don't hesitate and create pull request!

@RohiniBasavarajNataraj
Copy link
Author

Hi,

Below is a option to address the issue, but does not address the route cause.

When the date picker function is called for first onclick event it works fine. But when I debugged the code for the second click somehow self.datePicker.date was getting updated with garbage value @"NaN-NaN-NaNTNaN:NaN:00Z" value ( DatePicker.m file).
I just catch that exception and initialize the valid today date.
@Try{
self.datePicker.date = [formatter dateFromString:dateString];
}
@catch (NSException *exception) {
NSLog(@"Write failed with error: %@", exception);
NSString *dateS;
dateS = [formatter stringFromDate:[NSDate date]];
self.datePicker.date = [formatter dateFromString:dateS];
}

Appreciate any feedback and improvements.
Thanks in advance

@FWiner
Copy link

FWiner commented Nov 9, 2015

@RohiniBasavarajNataraj good advise!

i think the dateString is the selected date after open again

but im not good at oc 0_0
thank u for your advise

@spacepotato
Copy link

@RohiniBasavarajNataraj
You champion! That solved it for me as well.
Just to add a bit of additional information, the line you are replacing is around line 244 of DatePicker.m which for Ionic is located at plugins/cordova-plugin-datepicker/src/ios

@mvidailhet
Copy link

It's working for me too ! I made a pull-request with @RohiniBasavarajNataraj fix: #177

@aleximmauell
Copy link

but i got error on second firing after modifying Date.m . NSInternalInconsistencyException : Invalid parameter not satisfying:date

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

No branches or pull requests

6 participants