diff --git a/tailbone/static/js/tailbone.buefy.datepicker.js b/tailbone/static/js/tailbone.buefy.datepicker.js index c516b97f..0b861fd6 100644 --- a/tailbone/static/js/tailbone.buefy.datepicker.js +++ b/tailbone/static/js/tailbone.buefy.datepicker.js @@ -27,20 +27,14 @@ const TailboneDatepicker = { }, data() { - let buefyValue = this.value - if (buefyValue && !buefyValue.getDate) { - buefyValue = this.parseDate(this.value) - } return { - buefyValue, + buefyValue: this.parseDate(this.value), } }, watch: { value(to, from) { - if (this.buefyValue != to) { - this.buefyValue = to - } + this.buefyValue = this.parseDate(to) }, }, @@ -61,13 +55,16 @@ const TailboneDatepicker = { }, parseDate(date) { - // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format - var parts = date.split('-') - return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) + if (typeof(date) == 'string') { + // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format + var parts = date.split('-') + return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) + } + return date }, dateChanged(date) { - this.$emit('input', date) + this.$emit('input', this.formatDate(date)) }, focus() {