mengxiong10 / vue2-datepicker

A datepicker / datetimepicker component for Vue2
https://mengxiong10.github.io/vue2-datepicker/index.html
MIT License
1.52k stars 405 forks source link

Some dates aren't in the selected date format #126

Closed dermansi closed 6 years ago

dermansi commented 6 years ago

Hey,

great work!

One thing that came to my mind while using it: the displayed date in the tooltip when hovering over a cell and the one displayed over the time picker (which let's you go back to date selection) aren't respecting the picked date format. They will always displayed as xx/xx/xxxx.

Every displayed date should respect the selected format.

Regards dermansi

mengxiong10 commented 6 years ago

Yes, I just use new Date(this.value).toLocaleDateString().

Because I only need to format the date, but the prop format format date time.

dermansi commented 6 years ago

Thank you for your fast answer. Can you introduce a new property which formats just the date for those two cases?

mengxiong10 commented 6 years ago

If you really want to change it, you can modify the source code.

import DatePicker from 'vue2-datepicker'

DatePicker.components.CalendarPanel.computed.timeHeader = function () {
  return DatePicker.methods.stringify(this.value, 'YYYY-MM-DD')
}
mengxiong10 commented 6 years ago

In v2.3.1. I added a prop named date-format to format header time and date's tooltip. If not set, the default is based on format prop.