Skip to content

Commit 1420443

Browse files
author
Nathan Reyes
committed
Add time picker examples
1 parent dfd1f00 commit 1420443

File tree

5 files changed

+141
-1
lines changed

5 files changed

+141
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div class="example">
3+
<v-date-picker v-model="date" mode="dateTime" is24hr>
4+
<template v-slot="{ inputValue, inputEvents }">
5+
<input
6+
class="px-2 py-1 border rounded focus:outline-none focus:border-blue-300"
7+
:value="inputValue"
8+
v-on="inputEvents"
9+
/>
10+
</template>
11+
</v-date-picker>
12+
</div>
13+
</template>
14+
15+
<script>
16+
export default {
17+
data() {
18+
return {
19+
date: new Date(),
20+
};
21+
},
22+
};
23+
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div class="example">
3+
<v-date-picker v-model="date" mode="dateTime" :minute-increment="5" />
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
data() {
10+
return {
11+
date: new Date(),
12+
};
13+
},
14+
};
15+
</script>

docs/api/v2.0/datepicker.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ sidebarDepth: 2
3434

3535
**Default Value:** `false`
3636

37+
### `is24hr`
38+
39+
**Type:** Boolean
40+
41+
**Description:** Use 24-hr time picker and input format.
42+
43+
**Default Value:** `false`
44+
45+
### `minute-increment`
46+
47+
**Type:** Number
48+
49+
**Description:** Increment amount for the minute `select` options.
50+
51+
**Default Value:** 1
52+
3753
### `is-required`
3854

3955
**Type:** Boolean

docs/changelog/v2.0.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,11 @@ export default {
335335
};
336336
```
337337

338-
[Read more abount providing custom `input` elements.](/datepicker.html#input)
338+
[Read more abount providing custom `input` elements.](/datepicker.html#input)
339+
340+
## v2.1.1
341+
342+
### Enhancements
343+
344+
Time picker styling improvements.
345+
Display non-matched `minute` options when using `minute-interval`

docs/datepicker.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,91 @@ data() {
101101
}
102102
```
103103

104+
#### 24-hr Mode
105+
106+
Use the `is24hr` prop to adjust the hour `select` element and default input format for 24-hr mode.
107+
108+
<guide-datepicker-24hr />
109+
110+
```html
111+
<v-date-picker v-model="date" mode="dateTime" is24hr>
112+
<template v-slot="{ inputValue, inputEvents }">
113+
<input
114+
class="px-2 py-1 border rounded focus:outline-none focus:border-blue-300"
115+
:value="inputValue"
116+
v-on="inputEvents"
117+
/>
118+
</template>
119+
</v-date-picker>
120+
```
121+
122+
```js
123+
export default {
124+
data() {
125+
return {
126+
date: new Date(),
127+
};
128+
},
129+
};
130+
```
131+
132+
#### Minute Increments
133+
134+
Use the `minute-increment` prop to set custom intervals for the minute `select` options.
135+
136+
<guide-datepicker-minute-increment />
137+
138+
```html
139+
<v-date-picker v-model="date" mode="dateTime" :minute-increment="5" />
140+
```
141+
142+
```js
143+
export default {
144+
data() {
145+
let date = new Date();
146+
date.setMinutes(0, 0, 0);
147+
return {
148+
date,
149+
};
150+
},
151+
};
152+
```
153+
154+
:::warning
155+
If the bound date does not match of the the minute options derived by the `minute-increment` amount, the accurate `minute` amount will be displayed, but this option will be disabled.
156+
:::
157+
104158
### Time
105159

106160
To limit user selction to only time components (hours, minutes, seconds), use `mode: 'time'`.
107161

108162
<guide-datepicker-with-value mode="time" />
109163

164+
```html
165+
<div>
166+
<div class="flex mb-2" v-if="mode !== 'date'">
167+
<label class="text-gray-600 font-medium"><input class="mr-1" type="radio" value="" v-model="timezone">Local</label>
168+
<label class="text-gray-600 font-medium ml-3"><input class="mr-1" type="radio" value="utc" v-model="timezone">UTC</label>
169+
</div>
170+
<v-date-picker mode="time" v-model="date" :timezone="timezone" />
171+
<div class="flex items-baseline mt-2">
172+
<span class="text-gray-600 font-semibold tracking-wide">Date (ISO):</span>
173+
<span class="text-gray-800 ml-2">{{ date.toISOString() }}</span>
174+
</div>
175+
</div>
176+
```
177+
178+
```js
179+
export default {
180+
data() {
181+
return {
182+
date: new Date(),
183+
timezone: '',
184+
};
185+
},
186+
}
187+
```
188+
110189
## Model Config :tada:
111190

112191
*Introduced in **`v2.0.0`***

0 commit comments

Comments
 (0)