2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-25 04:40:36 +03:00

fix: disabledtime for ampm (#664)

This commit is contained in:
mengxiong10
2021-12-02 16:11:33 +08:00
parent ad7aaba823
commit 21f57180e0
2 changed files with 14 additions and 1 deletions
@@ -307,7 +307,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
data-type="ampm" data-type="ampm"
> >
<li <li
class="mx-time-item disabled" class="mx-time-item"
data-index="0" data-index="0"
> >
+13
View File
@@ -180,6 +180,16 @@ export default {
this.isDisabledTime(value.setSeconds(59, 999)) this.isDisabledTime(value.setSeconds(59, 999))
); );
}, },
isDisabledAMPM(date) {
const value = new Date(date);
const minHour = value.getHours() < 12 ? 0 : 12;
const maxHour = minHour + 11;
return (
this.isDisabledTime(value) &&
this.isDisabledTime(value.setHours(minHour, 0, 0, 0)) &&
this.isDisabledTime(value.setHours(maxHour, 59, 59, 999))
);
},
isDisabled(date, type) { isDisabled(date, type) {
if (type === 'hour') { if (type === 'hour') {
return this.isDisabledHour(date); return this.isDisabledHour(date);
@@ -187,6 +197,9 @@ export default {
if (type === 'minute') { if (type === 'minute') {
return this.isDisabledMinute(date); return this.isDisabledMinute(date);
} }
if (type === 'ampm') {
return this.isDisabledAMPM(date);
}
return this.isDisabledTime(date); return this.isDisabledTime(date);
}, },
handleSelect(value, type) { handleSelect(value, type) {