Giter Site home page Giter Site logo

cordova-plugin-datepicker's People

Contributors

abcnever avatar alan-rahlf-by avatar alexkvak avatar almost avatar andrei-vakulski avatar andrelsmoraes avatar chun-yang avatar davidaam avatar diego-silva avatar ecthurlow avatar jakecraige avatar jgillard avatar khaledalyawad avatar manishval avatar pabloleone avatar sebastianzillessen avatar siewmai avatar tenfef avatar thuey avatar vieko avatar vitaliiblagodir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-datepicker's Issues

Time picker not working on iOS8

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);
});

minDate and MaxDate not working

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);  
        });

mode time error in android

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.

Android cordova > PluginManager: "THREAD WARNING"

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...

Documentation should make it clear that minDate is a Date object for iOS

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.

No Ok/Cancel buttons on iPad for in mode time

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.

Screenshot

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;
}

Error using plugin in browser

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

Full Example!

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 ).

cancel

There is no way of knowing if they pressed cancel.

Pre-select date doesn't work on iOS

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!

iOS 7.0.2 not opening

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?

Time Picker is not returning 24hours format

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"

I cant edit date/time with keyboard

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 :)

Datepicker Second Show Error

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);  
    });
  }

Error on ios 7.1.1

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.

Problem with multiple calls to datePicker

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.

24hours timepicker

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.

Labels for buttons on Android

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.

Published this datetime picker on build.phonegap

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

https://github.com/nicholasareed/cordova-plugin-datepicker/tree/007feae6393d7022af51d9a60055f7de4dd89e54

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.

'WriteJavascript' warning after updating cordova project to v 3.6.3

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

Transparent background iOS 7 iPhone 4

We are using the plugin for an iOS 7 project, which works fine. But when iOS 7 users with iPhone 4 uses the app, the background is transparent.

Do we need to set the background color manually? If so, how do we do it?

See example below:

foto-2

Changes to the Android version

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

First time I use it it works fine, the second time I get an error

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) 

Crash on iPhone 4S with 8.1.3 / problems with Galaxy S4 on 4.4.2

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.

Timepicker problem

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

Time return in Android

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

Datepicker callback executed before click on button dialog

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?

Crash on iPad iOS 8.1.x 'UITableView dataSource is not set'

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)

Customizing appearance

Hi,
How can we remove the space between the picker and the done/cancel button.
PFA screen shot.
Please help!

ios simulator screen shot 30-sep-2014 3 28 41 am

Crash - App Crashes on IPad when show

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:

  1. datePicker.show(/2014/) -> pick = 2015 -> datePicker.show(/2014/) -> works.
  2. datePicker.show(/2014/) -> pick>=2016 -> datePicker.show(/2014/) -> Crashes.
  3. datePicker.show(/2014/) -> non picked -> datePicker.show(/>=2016/) -> Crashes.
  4. datePicker.show(/2014/) -> non picked -> datePicker.show(/<=2012/) -> Crashes.
    This bug making the use of this plugin in an app that uses multiple date pickers impossible.
    It will be great if you could also upload the update to phonegap build, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.