Value input for date picker
See original GitHub issueRight now v-model is not a part of the docs for the date picker. So it is a little confusing what types of dates you can set the value too. I looked at the source code to see if that helped. It appears that the value can be falsy
a Date
object or a date string, but not epoch time (which usually seems like one of the best ways to store date information).
Related to this is if you use date-format
function to convert the value to a non-recognizable date format then that value gets passed back in through v-model which results in undefined input. If you use computed values on the value then you can circumvent this problem, but then it seems pointless to have a date formatting option and it means you have to jump through extra hoops so that, for example, your input isn’t tied directly to the date-picker. One suggestion would be I’ve seen some other date-pickers that offer a formatted output property separate from the original format. Perhaps someone else has a better suggestion on the best way to deal with this.
Also in looking at the source code I ran into what appears to be an error https://github.com/vuetifyjs/vuetify/blob/master/src/components/pickers/DatePicker.js on line 79
if (!isNaN(this.value) && this.value.indexOf(':') !== -1) return new Date(this.value)
The first boolean statement resolves to true if the value is actually a number, but then you are trying to use indexOf
which is a string method. I’m not sure if maybe this is supposed to accept numbers (e.g. epoch time) or if it is actually just wanting date strings.
Summary
- Add
v-model
to the API docs - Add epoch time to one of the accepted values
- Look into maybe a better way to handle formatted dates
- Correct the error on line 79
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Would it be possible to reflect this restriction in the documentation? A sentence like “The v-model accepts only strings in the YYYY-MM-DD format.” would clear things up a lot.
Thanks for the swift reply! 😃
This can help for format dd/mm/yyyy https://codepen.io/adeari/pen/ZxpXbQ?&editors=101