Fixed #115 - Calendar datetime picker with stepMinute 15

pull/1196/head^2
mertsincan 2021-05-16 22:06:34 +03:00
parent 5136a928b9
commit dabc67877b
1 changed files with 11 additions and 10 deletions

View File

@ -360,6 +360,9 @@ export default {
watch: { watch: {
modelValue() { modelValue() {
this.updateCurrentMetaData(); this.updateCurrentMetaData();
},
showTime() {
this.updateCurrentMetaData();
} }
}, },
methods: { methods: {
@ -622,22 +625,20 @@ export default {
return !this.$attrs.disabled && !this.$attrs.readonly; return !this.$attrs.disabled && !this.$attrs.readonly;
}, },
updateCurrentTimeMeta(date) { updateCurrentTimeMeta(date) {
const hours = date.getHours(); let currentHour = date.getHours();
if (this.hourFormat === '12') { if (this.hourFormat === '12') {
this.pm = hours > 11; this.pm = currentHour > 11;
if (hours >= 12) if (currentHour >= 12)
this.currentHour = (hours == 12) ? 12 : hours - 12; currentHour = (currentHour == 12) ? 12 : currentHour - 12;
else else
this.currentHour = (hours == 0) ? 12 : hours; currentHour = (currentHour == 0) ? 12 : currentHour;
}
else {
this.currentHour = date.getHours();
} }
this.currentMinute = date.getMinutes(); this.currentHour = Math.floor(currentHour / this.stepHour) * this.stepHour;
this.currentSecond = date.getSeconds(); this.currentMinute = Math.floor(date.getMinutes() / this.stepMinute) * this.stepMinute;
this.currentSecond = Math.floor(date.getSeconds() / this.stepSecond) * this.stepSecond;
}, },
bindOutsideClickListener() { bindOutsideClickListener() {
if (!this.outsideClickListener) { if (!this.outsideClickListener) {