bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

[datepicker] format

Open lgaudez opened this issue 11 years ago • 9 comments

I just upgraded from ui-bootstrap 0.13.0 to 0.13.3 and I got a problem with my datepicker directive.

As you can see in this plunkr : here

I have a directive that convert a date to a localdate and format ngModel in iso format (yyyy-MM-dd).

Everything works fine when I don't set

datepickerPopupConfig.datepickerPopup = 'dd/MM/yyyy';

But when i uncomment this line (at the bottom of example.js file), if I choose a date nothing is set in ngModel.$modelValue and ngModel is markup as 'ng-invalid-date'.

If I set the input to type="date", this is working but I don't want to do that.

Is this an issue of ui-bootstrap? Am I doing something wrong?

Thanks a lot

lgaudez avatar Aug 19 '15 08:08 lgaudez

The dates provided now must be a date instance - this is due to cross-browser date string parsing issues causing various UI bugs. The commit that likely has caused this is https://github.com/angular-ui/bootstrap/commit/ab4580fd .

wesleycho avatar Aug 20 '15 05:08 wesleycho

Thanks for highlighting the commit that caused this incompatibly. Any idea to resolve it except forking repo?

lgaudez avatar Aug 20 '15 07:08 lgaudez

This was an intentional breaking change - unfortunately, your best recourse is to convert your string to a date object before attaching it to the model.

wesleycho avatar Aug 20 '15 13:08 wesleycho

I am closing this as per comments - I should note that I am currently working on a major refactor of the dateParser, datepicker, and timepicker to support custom parsers in order to allow moment.js support, so there are more breaking changes in the horizon.

wesleycho avatar Aug 21 '15 14:08 wesleycho

@wesleycho May I see your work about plugging custom parsers? I would like to help. Do you have a public branch that I can fork?

lgaudez avatar Aug 28 '15 10:08 lgaudez

@wesleycho Nothing new?

lgaudez avatar Oct 16 '15 12:10 lgaudez

Any update on allowing the date and time pickers to work with momentjs? Working with moments is much easier to do than the native Date object!

AndrewDavidReid avatar Feb 12 '16 16:02 AndrewDavidReid

@areid31891, it's still on the todo list.

icfantv avatar Feb 12 '16 17:02 icfantv

+1 for working with momentjs. The latest update, which now uses native methods getFullYear and so on, means the model passed in can no longer be a Moment.

horyd avatar Feb 24 '16 08:02 horyd