|
4 | 4 | --> |
5 | 5 |
|
6 | 6 | <template> |
7 | | - <!-- |
8 | | - `format` is specified as a workaround for https://github.com/nextcloud/calendar/issues/8307 |
9 | | - until the issue is fixed in `@nextcloud/vue`. |
10 | | -
|
11 | | - This works because `@vuepic/vue-datepicker` can use it to parse text inputs from the user |
12 | | - when providing a format as pattern string (and not a one-way function). |
13 | | - --> |
14 | 7 | <DateTimePicker |
15 | 8 | :ariaLabel="ariaLabel" |
16 | 9 | :min="minimumDate" |
17 | 10 | :max="maximumDate" |
18 | 11 | :modelValue="date" |
19 | 12 | :type="type" |
20 | 13 | class="date-time-picker" |
21 | | - :format="formatStr" |
22 | 14 | @blur="onBlur" |
23 | 15 | @update:modelValue="onInput" /> |
24 | 16 | </template> |
25 | 17 |
|
26 | 18 | <script> |
27 | | -import { getCanonicalLocale } from '@nextcloud/l10n' |
28 | 19 | import { |
29 | 20 | NcDateTimePicker as DateTimePicker, |
30 | 21 | } from '@nextcloud/vue' |
31 | | -import { getDateLocalePattern, getDateTimeLocalePattern, getTimeLocalePattern } from 'datetime-locale-patterns' |
32 | 22 | import { mapStores } from 'pinia' |
33 | 23 | import useDavRestrictionsStore from '@/store/davRestrictions.js' |
34 | 24 |
|
35 | | -const canonicalLocale = getCanonicalLocale() |
36 | | -
|
37 | 25 | export default { |
38 | 26 | name: 'DatePicker', |
39 | 27 | components: { |
@@ -102,28 +90,6 @@ export default { |
102 | 90 |
|
103 | 91 | return this.max || new Date(this.davRestrictionsStore.maximumDate) |
104 | 92 | }, |
105 | | -
|
106 | | - /** |
107 | | - * Returns the date format pattern for the current picker type. |
108 | | - * |
109 | | - * See https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table |
110 | | - * |
111 | | - * @return {string | undefined} A format pattern or `undefined` to use the default `NcDateTimePicker` formatting. |
112 | | - */ |
113 | | - formatStr() { |
114 | | - // Match logic from https://github.com/nextcloud-libraries/nextcloud-vue/blob/v9.8.0/src/components/NcDateTimePicker/NcDateTimePicker.vue#L549 |
115 | | - if (this.type === 'date' || this.type === 'date-range') { |
116 | | - return getDateLocalePattern(canonicalLocale, { dateStyle: 'medium' }) |
117 | | - } else if (this.type === 'time' || this.type === 'time-range') { |
118 | | - return getTimeLocalePattern(canonicalLocale, { timeStyle: 'short' }) |
119 | | - } else if (this.type === 'datetime' || this.type === 'datetime-range') { |
120 | | - return getDateTimeLocalePattern(canonicalLocale, { dateStyle: 'medium', timeStyle: 'short' }) |
121 | | - } else { |
122 | | - // 'datetime-locale-patterns' does not support `month` and `year`. |
123 | | - // So fall back to default formatting. |
124 | | - return undefined |
125 | | - } |
126 | | - }, |
127 | 93 | }, |
128 | 94 |
|
129 | 95 | methods: { |
|
0 commit comments