Skip to content

Commit 257559d

Browse files
author
Nathan Reyes
committed
Add is24hr prop
1 parent 046dd50 commit 257559d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/DatePicker.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ export default {
6161
const parts = this.isRange ? this.dateParts : [this.dateParts[0]];
6262
return parts.map((dp, idx) =>
6363
h(TimePicker, {
64-
props: { value: dp, locale: this.$locale, theme: this.$theme },
64+
props: {
65+
value: dp,
66+
locale: this.$locale,
67+
theme: this.$theme,
68+
is24hr: this.is24hr,
69+
},
6570
on: { input: p => this.onTimeInput(p, idx) },
6671
}),
6772
);
@@ -146,6 +151,7 @@ export default {
146151
mode: { type: String, default: MODE_DATE },
147152
value: { type: null, required: true },
148153
modelConfig: { type: Object, default: () => ({ ..._dateConfig }) },
154+
is24hr: Boolean,
149155
isRequired: Boolean,
150156
isRange: Boolean,
151157
updateOnInput: Boolean,

src/components/TimePicker.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<time-select v-model.number="hours" :options="hourOptions" />
3333
<span style="margin: 0 4px;">:</span>
3434
<time-select v-model.number="minutes" :options="minuteOptions" />
35-
<div class="vc-am-pm">
35+
<div v-if="!is24hr" class="vc-am-pm">
3636
<button :class="{ active: isAM }" @click="isAM = true">
3737
AM
3838
</button>
@@ -56,6 +56,7 @@ export default {
5656
value: { type: Object, required: true },
5757
locale: { type: Object, required: true },
5858
theme: { type: Object, required: true },
59+
is24hr: { type: Boolean, default: true },
5960
},
6061
data() {
6162
return {
@@ -157,8 +158,6 @@ export default {
157158
},
158159
setup() {
159160
this.protected(() => {
160-
this.is24hr =
161-
this.locale.is24hr !== undefined ? this.locale.is24hr : false;
162161
let { hours } = this.value;
163162
if (hours === 24) hours = 0;
164163
let isAM = true;
@@ -181,6 +180,7 @@ export default {
181180
...this.value,
182181
hours,
183182
minutes: this.minutes,
183+
seconds: 0,
184184
});
185185
});
186186
},

0 commit comments

Comments
 (0)