vitaliiblagodir / cordova-plugin-datepicker Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
With fix from 20 may, i cant edit time/date with keyboard. When i edit and click on "ok", the result is nothing.
Please back to previus revision, or change plugin version to new :)
The datepicker do not look like this:
https://www.google.com/design/spec/components/pickers.html
Hi Vitalii!
Great plugin, you saved me :)
One question, when using 'time' is it normal that entire date is returned? not just actual time selected? I receive entire date object and not just '14:30' for example.
I fixed this by changing the format of returned time, so its working fine, just wanted to be sure that this is actual how it works.
datePicker.show(options, function(time){
$scope.$apply(function(){
$scope.field.field_value = $filter('date')(time, 'HH:mm');
});
});
Thanks!
dp
I'm using this code:
var options = {
date: new Date(),
mode: 'time'
};
datePicker.show(options, function(date){
alert(date);
});
I'm getting Invalid Date, but datepicker works fine
I first came across this plugin via ngCordova. The documented example:
module.controller('MyCtrl', function($scope, $cordovaDatePicker) {
var options = {
date: new Date(),
mode: 'date', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: false,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
document.addEventListener("deviceready", function () {
$cordovaDatePicker.show(options).then(function(date){
alert(date);
});
}, false);
});
doesn't work on iOS because minDate wasn't being interpreted as a Date object. This is what finally worked (Ionic example):
minDate = ionic.Platform.isIOS() ? new Date() : (new Date()).valueOf();
datePickerOptions = {
date: new Date(),
minDate: minDate,
mode: 'date'
};
I think this should be better reflected in the documentation. Thank you for your consideration.
Ignore.
My html has an ng-click="datePopup()"
The function is
var options = {
date: new Date(),
mode: 'date', // or 'time'
minDate: new Date() - 10000,
allowOldDates: true,
allowFutureDates: false,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$scope.popupDate = function(){
console.log("in the popup");
$cordovaDatePicker.show(options).then(function(date){
console.log("date is", date);
});
This works fine at first.
The first time I press it I get the datepicker. Fine. The second time nothing and this error in console:
TypeError: undefined is not a function
at DatePicker.show (http://192.168.1.35:8100/plugins/com.plugin.datepicker/www/android/DatePicker.js:19:32)
at Object.show (http://192.168.1.35:8100/lib/ngCordova/dist/ng-cordova.js:1272:28)
at Scope.$scope.popupDate (http://192.168.1.35:8100/js/settings.js:89:26)
at $parseFunctionCall (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:20124:18)
at http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:50863:9
at Scope.$eval (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:22178:28)
at Scope.$apply (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:22276:23)
at HTMLButtonElement.<anonymous> (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:50862:13)
at HTMLButtonElement.eventHandler (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:10823:21)
at triggerMouseEvent (http://192.168.1.35:8100/lib/ionic/js/ionic.bundle.js:2811:7)
I get the following error after compiling the code using
cordova build ios
Interface Builder could not open the document DatePicker.xib" because it does not exist
I am on cordova 4.2.0
I was wondering if it would be possible to have this plugin published in build.phonegap.
Although there are already datepicker plugins available their but they have compatibility issues. There is one plugin available their forked version of this datepicker by nicholasareed
However it has a major drawback with options type time when your phone's language setting is not English, right away it returns "Invalid Date" lets say
if you're in French Language Setting, but if you change it to English you get your desired date Object. The problem starts at the callback itself of the plugin.
Today I tested this plugin and it works properly, it returns the date in English despite of your phone's language setting.
It would be really nice to get this published in build.phonegap.
Thank you and much appreciated.
Is it possible to change date format in iOS to something like yyyy/mm/dd? (eg: 2015/01/22)
When showing the datepicker in time mode on iPad, there is no buttons to approve/cancel the selected time. The problem is present on every iPad I tested running 7.1, 8.1, 8.2
Here's a screenshot. I blurred the app in background which is not relevant to the problem.
This time picker is generated by this code:
$cordovaDatePicker.show({
date: moment().hour(8).minute(0).toDate(),
mode: 'time'
})
Where `$cordovaDatePicker.show is a simple wrapper from ngCordova:
function (options) {
var q = $q.defer();
options = options || {date: new Date(), mode: 'date'};
$window.datePicker.show(options, function (date) {
q.resolve(date);
});
return q.promise;
}
I have noticed that the date picker crash on iPad 8.1.x throwing the following error meanwhile on iPhone things works smoothly.
On ipad the date picker appear but once it gets selected or lose focus the app crash.
Also on iPad the cancel and ok button does not appear.
*** Assertion failure in -[UIPickerTableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:], /SourceCache/UIKit/UIKit-3318.16.14/UITableView.m:9269
2014-11-20 23:19:03.980 size-me[302:17931] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource is not set'
*** First throw call stack:
(0x27a37d67 0x35572c77 0x27a37c3d 0x2870aaa9 0x2b1a221b 0x2b1a232f 0x2b197a51 0x2afafc1b 0x2b424da9 0x2aed9c1f 0x2a904f65 0x2a900951 0x2a9007d9 0x2a9001c7 0x2a8fffd1 0x2a8f9edd 0x279fe625 0x279fbd09 0x279fc10b 0x27949981 0x27949793 0x2ecf9051 0x2af3b981 0x452eb 0x35b0eaaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
When using the plugin on Lollipop I'm getting a a dark with some sort of cyan blue color, like in this post:
http://stackoverflow.com/questions/29170874/how-to-change-datepickers-calendarviews-background-color-in-lollipop
Is there a way to customize it? My app is white with red, dark and blue just doesn't fit. I'm totally dumb about android, so I don't know if this should be a customization parameter on the plugin or a customization on my app.
Thanks!
when I select the time in the picker, always returns error "invalid Date". I think the problem is in the method toLocateString () used to return the result in function onTimeSet.
my location is Spain.
first of all thx for the plugin - its in action in the ng-cordova wrapper for the ionic framework:
it would be niece with a more modern android picker:
this is lined out in http://developer.android.com/guide/topics/ui/controls/pickers.html
The date picker plugin shows error message on iOS 7.1.1. Whenever date picker plugin is triggered following error appears in the log. Although the date picker is working fine
: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
: CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
There is no way of knowing if they pressed cancel.
If you initialize the plugin and pass a date object into the {date: dateobject} it seems to use the default of new Date. As in the picker pre-selects the current time always!
i tried the following code, but not working
var options = {
date: new Date(),
minDate :new Date(2012,12,12),
maxDate :new Date(2016,12,12),
mode: 'date'
};
datePicker.show(options, function(date){
alert("date result " + date);
});
The iOS datetime picker is great, but unfortunately the android version of this plugin doesn't support that. It would be great if it did.
Did few rounds of checking, after set the hour in time picker, still getting 12 hours format.
Check with DatePickerPlugin.java,
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
should change from "hh" to "HH"
Fixed both these issues here: https://github.com/adaptivedev/cordova-plugin-datepicker
Hi,
we have updated locally the plugin for Android so it shows a third button (to have Set, Clear and Cancel), basically some small changes in src/android/DatePickerPlugin.java and www/android/DatePicker.js.
Please let us know if you are interested on taking a look and adding them to the plugin.
Thanks
Shows an error
WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInternalInconsistencyException> Invalid parameter not satisfying: date
My code
Assuming that the button text value is 12:00 AM
var myX = button.element.getX();
var myY = button.element.getY();
var myWidth = button.element.getWidth();
theDate = new Date();
if(button.getText() !== "Event Date") {
theDate = Ext.Date.parse(button.getText(), 'h:i A'); //Converts 12:00 AM to date object
console.log(theDate); //Outputs Mon Dec 15 2014 00:00:00 GMT+0400 (Arabian Standard Time)
}
var options = {
date: theDate,
mode: 'time',
x: myX + (myWidth / 2),
y: myY + 20
};
datePicker.show(options, function(date){
date = Ext.Date.format(date, "h:i A"); //Formats date object to 12:00 AM format
button.setText(date);
});
Hi, there is a major problem with the plugin that causes crashes when I'm using it in my IPad.
I've managed to find the exact scenario that causes the crash: executing datePicker.show with year greater or lower by 2 years from the last picked/initiated year.
On android everithing works just fine (haven't checked on iphone).
Examples:
just tried out the minuteInterval property, but it doesn't seem to change anything on the datepicker, it still goes in intervals of 1 minute regardless.
The plugin has properties to define "Cancel" and "Done" labels on iOS but we don't have the same for Android. The "apply" button is translated, but not the "cancel" one. So when you use the plugin on Android you have a "frenglish" app. It would be nice to make these properties work on Android too.
'datetime' option doesn't work on Samsung S3 i9300 .
Only 'date' or 'time' are working
as below. :-)
It looks as if the version of this plugin on phone gap is 0.4.0 and the current release is 0.5.0. Would it be possible to update the version?
https://build.phonegap.com/plugins/1200
Cheers in advance.
Hi,
I'm having problems with the plugin.
It works fine on Android, on iOS the dialog is not opening.
I'm calling it simply with;
datePicker.show({date: new Date(), mode: 'date'})
The datepicker is not opening. I doesn't throw any errors, just returns undefined.
I'm using the PhoneGap Build version from @nicholasareed, https://github.com/nicholasareed/cordova-plugin-datepicker. I'd post an issues there, but issues are not enabled on that repository.
Do you have any suggestions?
Hi,
thanks for this great plugin. I'm afraid to tell you, that customers have reported the whole app crashes on 4S with 8.1.3 as soon as the button (which will invoke the datepicker to show up) was clicked.
They don't even see it. Sometimes it crashes, sometimes not. I can't reproduce this bug as I have no real 4S device by hand and I can't reproduce this bug on Simlulator with 8.1 SDK (maybe 8.1 != 8.1.3)
Other users reported on Android, that they can pick and choose whatever they want but the callback won't be invoked. I don't know how to manage this bugs right now - maybe some of you could Imagine whats going wrong there.. I know it is hard to test without log but maybe someone has an real 8.1.3 with 4S and can reproduce this issue. Thank you very much.
Hello,
I get this warning message when updated Cordova to version 3.6.3
/Plugins/com.plugin.datepicker/DatePicker.m:143:10: 'writeJavascript:' is deprecated: Deprecated in Cordova 3.6. Use the CDVCommandDelegate equivalent of evalJs:. This will be removed in 4.0.0
Cheers
Using Android
logs says:
...
DatePickerPlugin D DatePicker called with options: [{"date":"9\/9\/2014\/11\/46","maxDate":0,"minDate":0,"mode":"time"}]
PluginManager W THREAD WARNING: exec() call to DatePickerPlugin.time blocked the main thread for 27ms. Plugin should use CordovaInterface.getThreadPool().
...
could be a possible optimisation...
So im using the datepicker with ngCordova. The first time i call the datepicker everything works fine but when i call it i second time i receive the error:
Error: undefined is not a function (evaluating 'date.getFullYear()')
Here is the snippet:
<label type="text" ng-model="user.birthday" ng-click="showDatePicker1()">mm/dd/yyyy</label>
var options = {
date: new Date(),
mode: 'date', // or 'time'
allowOldDates: true,
allowFutureDates: false,
doneButtonLabel: 'DONE',
doneButtonColor: '#F2F3F4',
cancelButtonLabel: 'CANCEL',
cancelButtonColor: '#000000'
};
$scope.showDatePicker1 = function() {
$cordovaDatePicker.show(options, function(date){
alert("date result " + date);
});
}
Its not working for ios 8,
Plz help
Is it possible to post a full example on how to use the plugin? ( HTML input type="text" or "date"..., and how to handle the click event ).
Hello,
I got an error in show method when testing it in browser
TypeError: Cannot read property 'show' of undefined
Can you please let me know how I can test it in browser so that I cam implement it properly, as in simulator its difficult to debug.
Thanks
Gaurav
It seems that maxdate and minDate options are not working with Android. It works with iOS. Please help me...
Hi,
I have noticed a problem when calling datePicker multiple times within the same page. As the 'datetime' mode is not available for android, I am splitting the date/time selection into 2 steps so that it works cross-platform. Essentially I don't want users to be able to choose a date in the past but they should be able to choose any time (past or future).
When you click on the first 'date' button I call:
var options = {
date: new Date(),
mode: 'date',
allowOldDates: false
};
datePicker.show(options, function(date){});
Then when you click on the 2nd 'time' button I call:
var options = {
date: new Date(),
mode: 'time',
allowOldDates: true
};
datePicker.show(options, function(date){});
It seems that the 'allowOldDates' parameter in the 2nd call is not being respected because it wont let me choose a time in the past. However, If I happen to have clicked the 2nd button before the first one then it works properly, so it seems like a problem with multiple calls to the datepicker.
Hello,
I've seen an strange behavior of the plugin (just happens sometimes), the case is when the datepicker is shown the js callback is executed without waiting the user interaction (pressing the button in this case).
I've been tracing the error and the execution goes directly to the cancel statement and that's the value the js callback gets: "cancel".
Do you know why can be happening this?
I created a project, installed the plugin, and added the demo code, but the plugin does not bring up the date picker.
I already tried to change the last parameter on new TimePickerDialog (line 102 and 103) in the android source of DatePickerPlugin.java
final TimePickerDialog timeDialog = new TimePickerDialog(currentCtx, timeSetListener, mHour, mMinutes, true);
But it didn't change in my app.
How can i center the datepicker with a given input?
The API doesn't allow us to know the width of the picker for properly centering or does it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.