bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Datepicker to allow 2 date format

Open jlien-calwater opened this issue 11 years ago • 18 comments

Is it possible to allow two date format specifically just the zeros for month and day?

E.g.:

01/01/2015 1/01/2015 01/1/2015 1/1/2015

jlien-calwater avatar Sep 30 '15 15:09 jlien-calwater

Please do not use the issues forum for support related requests. Rather, please follow the instructions here.

icfantv avatar Sep 30 '15 16:09 icfantv

See this SO article for your answer.

icfantv avatar Sep 30 '15 17:09 icfantv

I'm reopening this as it needs further investigation. <input type="date"/> is not supported in all browsers so we support type="text" to mitigate.

What would help is if you could create a bare bones plunker using the latest code to demonstrate this issue. That should help get us started. Thanks.

icfantv avatar Oct 01 '15 18:10 icfantv

@icfantv here you go: http://plnkr.co/edit/NPqifjimoAnuJgvFPyDm?p=preview

I put both MM/dd/yyyy and M/d/yyyy text boxes.

jlien-calwater avatar Oct 01 '15 23:10 jlien-calwater

Linking in the SO article here: http://stackoverflow.com/questions/32832161/angular-bootstrap-how-to-allow-2-different-date-format

icfantv avatar Oct 02 '15 02:10 icfantv

Quick question, where would be the appropriate place to add a clarification/feature request that's related to this issue?

jdscolam avatar Oct 07 '15 19:10 jdscolam

@icfantv not sure what you have in mind for a fix. One solution came to mind is to enforce formatting on blur. Not sure if that is acceptable solution/method.

jlien-calwater avatar Oct 07 '15 23:10 jlien-calwater

I need to talk to the other devs about the right fix here assuming that it is a bug (I freely admit I have not yet investigated it). Currently we're focused on getting 0.14.0 out the door and getting ng-bootstrap (the ng2/BS4 port) ready for Angular Connect, London in a few weeks.

We have weekly meetings on Tuesdays and I will bring it up then. Thanks.

icfantv avatar Oct 07 '15 23:10 icfantv

To implement this, this would involve modifying the uibDateParser service - we may be able to support this, but this is work that would be scheduled for backlog, and likely only implemented if someone submitted a high quality PR.

One needs to be careful about the letters chosen to support double date formats. We follow the native dateFilter in Angular, so any choice cannot conflict with this.

wesleycho avatar Oct 14 '15 04:10 wesleycho

@wesleycho So one thing that is desperately needed is the ability to databind to a date format that is different than what is displayed. For example, binding to a datetime in ISO, then displaying simple mm/dd/yyyy.

jdscolam avatar Oct 20 '15 19:10 jdscolam

That is separate from this issue and should be in a separate issue if that is requested - we removed string support though due to cross-browser issues, so that particular proposal is a no-go.

wesleycho avatar Oct 20 '15 19:10 wesleycho

In 0.13.1 (and earlier, probably), the text box accepted many date formats as typed in by the user. Starting in 0.13.2, it accepts only the date format specified in datepicker-popup. You can reproduce this in the docs - scroll down to the 0.13.1 datepicker demo here and enter 1/1/17 or 2017-01-01 or jan 1 17 and it works. Try that in the 0.13.2 or later datepicker demo, and it doesn't work, unless you use the format specified in datepicker-popup. Was it intentional to remove this functionality?

danbockapps avatar Oct 29 '15 19:10 danbockapps

This was intentional - this was due to unexpected cross-browser issues that were impossible to fix.

wesleycho avatar Oct 29 '15 19:10 wesleycho

This feature is now supported in master via b1cfc57

wesleycho avatar Nov 02 '15 23:11 wesleycho

Many thanks for the fix, we struggled with the same issue. Is there an approximate date we can expect this fix in a (npm) release?

brunnurs avatar Jan 06 '16 08:01 brunnurs

@brunnurs, the 1.x release will be soon. In the interim, you can pull master and do a SNAPSHOT build.

icfantv avatar Jan 06 '16 16:01 icfantv

@icfantv Thanks for the V1.0.3 release, which includes the new feature. Unfortunately, it doesn't seem to work with the uib-datepicker-popup.

I extended your plunkr with the format d!.M!.yyyy. I expected to be able to enter a date in format 13.01.2016 OR 13.1.2016. But it doesn't seem to work. Is it a bug or my rookie-mistake?

brunnurs avatar Jan 13 '16 17:01 brunnurs

@brunnurs, if you think you've found a bug, please follow these instructions.

In practice, it's never a good idea to ask for help on a closed thread. Doing so is a good way for it to get missed or ignored.

icfantv avatar Jan 13 '16 17:01 icfantv