Skip to content

Commit

Permalink
fix: disabledtime for ampm (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Dec 2, 2021
1 parent ad7aaba commit 21f5718
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion __test__/__snapshots__/time-range.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
data-type="ampm"
>
<li
class="mx-time-item disabled"
class="mx-time-item"
data-index="0"
>
Expand Down
13 changes: 13 additions & 0 deletions src/time/time-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,26 @@ export default {
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) {
if (type === 'hour') {
return this.isDisabledHour(date);
}
if (type === 'minute') {
return this.isDisabledMinute(date);
}
if (type === 'ampm') {
return this.isDisabledAMPM(date);
}
return this.isDisabledTime(date);
},
handleSelect(value, type) {
Expand Down

0 comments on commit 21f5718

Please sign in to comment.