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

"typeable" ignores "format" #583

Open
c7pt7in opened this issue Aug 23, 2018 · 25 comments
Open

"typeable" ignores "format" #583

c7pt7in opened this issue Aug 23, 2018 · 25 comments

Comments

@c7pt7in
Copy link

c7pt7in commented Aug 23, 2018

"typeable" ignores "format" attribute and only works if I type date in format "MM.dd.yyyy"

Component use:

<datepicker v-model="date" :format="'dd.MM.yyyy'" :typeable="true"></datepicker>

1.5.1 and 1.5.2

@renatoosaka
Copy link

Same here

@charliekassel
Copy link
Owner

This is as designed.
If a user types something then it is left as is, as long as it parses to a Date object.
It doesn't really matter what is displayed in the input as the value will be the same - i.e. the Date object.

@tehnolog
Copy link

This is wrong.
If user type date in 'dd.MM.yyyy', 'MM.dd.yyyy', 'yyyy.MM.dd' etc, Date object should be different.
So It's impossible to type date in non-standard format.
Also values such as '25.05.1990' are clearing on blur.

@kennardconsulting
Copy link

+1

My users need to be able to type in 1/6/1980 to mean 1st June 1980. But the pop-up locks to 6th Jan 1980.

@barbosaalr
Copy link

Hello all, I just created pullRequest 633 to handle non-standard formats! Waiting to see if @charliekassel will accept it!

@ricardoinaciojunior
Copy link

The problem still persists on 02-01-2018

@triosw
Copy link

triosw commented Apr 3, 2019

Problem still persists.
@charliekassel, if you cannot parse the date from format, can you please provide a prop for passing a parsing function?
e.g. props:{ ... dateStrParser: Function, ... } and if (this.dateStrParser){ this.currentDate = this.dateStrParser(inputStrVal, this.format); } (or take the current parsing function as default value for the prop).

If not possible:
@charliekassel can you ar least emit 'blur' event when the input loses focus, so we can catch it and apply our custom parsing function on the value of the input field?

(obviously prev tips were only my 2cents...)

@rpounder
Copy link

@charliekassel if it's by design, then it is bad design. Strictly from a UI perspective, if a user sees a date in a format, they won't try and type it a different way than what is displayed in most cases.

@atrujillofalcon
Copy link

No solution yet :(

@harlekoy
Copy link

harlekoy commented May 30, 2019

Good news i created a fixed on this issue 😄#718

Format: dd MMM yyyy

C4s9ZEYCnB

Format: dd/MM/yyyy

P2yZ5S2Df4

@renielsalvador
Copy link

I am having problems with this too. Seems like the parsing mechanism that happens inside the components doesnt consider the format you provide. I.E if you set the format as dd-MM-yyyy and selects day 13+, it will return an invalid date and clears the calendar.

datepicker

@MatheusMuriel
Copy link

I am having problems with this too. Seems like the parsing mechanism that happens inside the components doesnt consider the format you provide. I.E if you set the format as dd-MM-yyyy and selects day 13+, it will return an invalid date and clears the calendar.

datepicker

I have this problem too
I think it's because the component switch days and months (so it goes up to 12)

@ConorSheehan1
Copy link

pr #653 would solve this! It delegates the parsing of dates, so you can pass a parser function, the same way you can pass a formatter function

@arthurbarbero
Copy link

The #653 does not solve this, this bug is not a formating problem, the typeable directive doesn't take the language directive nor the formating directive, it just keep accepting only the mm/dd/yyy format and conflict with all the component, Shame on you datepicker...

@ConorSheehan1
Copy link

@arthurbarbero You're right, the issue isn't about formatting, it's about parsing.
Specifically this line

const typedDate = Date.parse(this.input.value)

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse for reasons on why ambiguous dates such as 01/02/2020 are interpreted as mm/dd/yyyy. e.g.

new Date('10 06 2014');
will be treated as a local date of 6 October, 2014 and not 10 June, 2014.

#653 solves this parsing issue by providing a parse prop, which accepts a callback function, allowing you to parse user input any way you want! e.g. moment(userInput, 'DD/MM/YYYY')

I forked the datepicker, merged #653, ran the build script and committed the dist dir so I could npm install it directly from git, added a parse callback in my app, and voila. Working datepicker with typeable dd/mm/yyyy format.

dd/mm/yyyy working

@arthurbarbero
Copy link

The pr #653 will only solve the problem when it merge to the master, until then, Shame on you Vuejs-Datepicker.

@ConorSheehan1
Copy link

@arthurbarbero I don't think shame-driven development works. If you want #653 merged, you should upvote it.

Also you could change your downvote on my comment stating that #653 could solve this issue, now that I've also explained to you exactly how it could solve this issue.
Screenshot_20200104-115959__01

@i-am-nikola
Copy link

Has this bug been fixed yet? This not true for me! I type in 1/6/2020 to mean 1st June 2020. But the pop-up locks to 6th Jan 2020.

@9xcoder
Copy link

9xcoder commented Apr 23, 2021

still error with format "dd/MM/yyyy" :(

@sarunmrzn
Copy link

How is this still not fixed

@jotapixma
Copy link

2021 and still the fix date format, sad.

@atrujillofalcon
Copy link

2021 and still the fix date format, sad.

No other solution that migrate to other datepicker. https://github.com/mengxiong10/vue2-datepicker is good option.

@zawyehtutko
Copy link

2022 End of May, still not fixed yet.

@zawyehtutko
Copy link

problem is after i add props: typeable = "true", UI shows right, shown value and display format is right but after click to somewhere, it disappear.

@snakemastr
Copy link

2023 end of october, still not fixed.
Wasted hours implementing and styling only to find out a key feature makes this plugin unusable for me.

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