mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-17 05:10:34 +03:00
feat: add getWeek in custom format (#382)
This commit is contained in:
@@ -36,6 +36,11 @@ import { createDate } from '../util/date';
|
||||
export default {
|
||||
name: 'TableDate',
|
||||
mixins: [localeMixin, formatMixin],
|
||||
inject: {
|
||||
getWeek: {
|
||||
default: getWeek,
|
||||
},
|
||||
},
|
||||
props: {
|
||||
calendarYear: {
|
||||
type: Number,
|
||||
@@ -132,7 +137,7 @@ export default {
|
||||
const year = this.calendarYear;
|
||||
const month = this.calendarMonth;
|
||||
const date = createDate(year, month, day);
|
||||
return getWeek(date, this.t('formatLocale'));
|
||||
return this.getWeek(date, this.t('formatLocale'));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
+8
-1
@@ -86,7 +86,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { parse, format } from 'date-format-parse';
|
||||
import { parse, format, getWeek } from 'date-format-parse';
|
||||
import { isValidDate, isValidRangeDate, getValidDate } from './util/date';
|
||||
import { pick, isObject, mergeDeep } from './util/base';
|
||||
import { getLocale } from './locale';
|
||||
@@ -121,6 +121,7 @@ export default {
|
||||
provide() {
|
||||
return {
|
||||
locale: this.locale,
|
||||
getWeek: this.getWeek,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@@ -295,6 +296,12 @@ export default {
|
||||
this.closePopup();
|
||||
}
|
||||
},
|
||||
getWeek(date, options) {
|
||||
if (isObject(this.format) && typeof this.format.getWeek === 'function') {
|
||||
return this.format.getWeek(date, options);
|
||||
}
|
||||
return getWeek(date, options);
|
||||
},
|
||||
parseDate(value, fmt) {
|
||||
if (isObject(this.format) && typeof this.format.parse === 'function') {
|
||||
return this.format.parse(value, fmt);
|
||||
|
||||
Reference in New Issue
Block a user