Skip to content

Commit 462171b

Browse files
committed
fix: export dayjs
1 parent 1b652ad commit 462171b

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

demo/pages/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<script>
1919
import { VuecRangeInput, VuecSingleInput } from '../../src';
20-
import date from '../../src/date';
20+
import dayjs from '../../src/date';
2121
2222
export default {
2323
components: {
@@ -26,8 +26,8 @@ export default {
2626
},
2727
data() {
2828
return {
29-
now: date(),
30-
maxDate: date().add(26, 'day'),
29+
now: dayjs(),
30+
maxDate: dayjs().add(26, 'day'),
3131
};
3232
},
3333
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@alibaba-aero/vuec",
2+
"name": "@alibaba-aero/vue-calendar",
33
"version": "0.0.1",
44
"description": "Vue Calendar",
55
"main": "dist/vuec.cjs.min.js",

src/components/core/calendar.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</template>
4444

4545
<script>
46-
import idate from '../../date';
46+
import dayjs from '../../date';
4747
4848
import VuecMonth from './month.vue';
4949
import DefaultDayView from './default-day.vue';
@@ -75,7 +75,7 @@ export default {
7575
},
7676
date: {
7777
type: Object,
78-
default: () => idate(),
78+
default: () => dayjs(),
7979
},
8080
visibleMonths: {
8181
type: Number,
@@ -116,7 +116,7 @@ export default {
116116
const map = {};
117117
118118
this.selections.forEach((item) => {
119-
const month = idate(item, 'YYYY/MM/DD').format('YYYY/MM');
119+
const month = dayjs(item, 'YYYY/MM/DD').format('YYYY/MM');
120120
map[month] = map[month] || [];
121121
map[month].push(item);
122122
return map;
@@ -127,20 +127,20 @@ export default {
127127
months() {
128128
const months = [];
129129
130-
let date = idate(this.Xdate);
130+
let date = dayjs(this.Xdate);
131131
132132
if (this.showPreviousWeeks) {
133133
date.startOf('Month');
134134
}
135135
136-
const end = idate(this.Xdate).add(this.visibleMonths - 1, 'Month').endOf('Month');
136+
const end = dayjs(this.Xdate).add(this.visibleMonths - 1, 'Month').endOf('Month');
137137
138138
while (date.isBefore(end)) {
139139
const monthKey = date.format('YYYY/MM');
140140
141141
months.push({
142142
title: date.format('MMMM'),
143-
date: idate(date),
143+
date: dayjs(date),
144144
selections: this.monthSelections[monthKey],
145145
});
146146

src/components/core/default-day.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
</template>
88

99
<script>
10-
// import { formatDate } from '../../utils';
11-
1210
export default {
1311
props: {
1412
date: {
@@ -22,7 +20,7 @@ export default {
2220
},
2321
computed: {
2422
formattedDate() {
25-
return this.date.format('D'); // formatDate(this.date, 'D', true);
23+
return this.date.format('D');
2624
},
2725
},
2826
};

src/components/core/month.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</template>
4343

4444
<script>
45-
import idate from '../../date';
45+
import dayjs from '../../date';
4646
4747
import DayView from './day.vue';
4848
import DefaultDayView from './default-day.vue';
@@ -100,8 +100,8 @@ export default {
100100
const activeMonth = this.date.month();
101101
const monthKey = this.date.format('YYYY/MM');
102102
// move to start of week if it's not
103-
let date = idate(this.date).startOf('Month').startOf('week');
104-
const end = idate(this.date).endOf('Month');
103+
let date = dayjs(this.date).startOf('Month').startOf('week');
104+
const end = dayjs(this.date).endOf('Month');
105105
106106
const days = [];
107107
@@ -113,7 +113,7 @@ export default {
113113
days.push({
114114
disabled: true,
115115
hide: date.month() !== activeMonth,
116-
date: idate(date),
116+
date: dayjs(date),
117117
data: this.adapter({
118118
date,
119119
dayKey,
@@ -128,7 +128,7 @@ export default {
128128
dayKey,
129129
monthKey,
130130
}) || {},
131-
date: idate(date),
131+
date: dayjs(date),
132132
selected: this.selection.indexOf(dayKey) !== -1,
133133
});
134134
}

src/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as idate } from '../date';
1+
export { default as dayjs } from '../date';
22

33
// Core components
44
export { default as VuecCalendar } from './core/calendar.vue';

src/components/range-input.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<script>
4343
import VuecSelectRange from './select-range.vue';
4444
import IconClose from './icons/close.vue';
45-
import idate from '../date';
45+
import dayjs from '../date';
4646
4747
export default {
4848
components: {
@@ -96,15 +96,15 @@ export default {
9696
},
9797
},
9898
data() {
99-
const [fromDate = idate(), toDate = idate()] = this.value;
99+
const [fromDate = dayjs(), toDate = dayjs()] = this.value;
100100
return {
101101
visible: this.open,
102102
temporaryDisableClickListen: false,
103103
fromDate,
104104
toDate,
105105
dates: [
106-
idate(fromDate),
107-
idate(toDate),
106+
dayjs(fromDate),
107+
dayjs(toDate),
108108
],
109109
};
110110
},
@@ -141,8 +141,8 @@ export default {
141141
$event.stopPropagation();
142142
},
143143
onSelectionChange(selections) {
144-
this.fromDate = idate(selections[0]);
145-
this.toDate = idate(selections[selections.length - 1]);
144+
this.fromDate = dayjs(selections[0]);
145+
this.toDate = dayjs(selections[selections.length - 1]);
146146
this.$emit('input', [
147147
this.fromDate,
148148
this.toDate,

src/components/single-input.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<script>
2626
import VuecSingleSelect from './select-single.vue';
27-
import idate from '../date';
27+
import dayjs from '../date';
2828
2929
export default {
3030
components: {
@@ -68,8 +68,8 @@ export default {
6868
return {
6969
visible: this.open,
7070
temporaryDisableClickListen: false,
71-
fromDate: idate(),
72-
toDate: idate(),
71+
fromDate: dayjs(),
72+
toDate: dayjs(),
7373
dates: [],
7474
};
7575
},
@@ -106,8 +106,8 @@ export default {
106106
$event.stopPropagation();
107107
},
108108
onSelectionChange(selections) {
109-
this.fromDate = idate(selections[0], 'YYYY/MM/DD');
110-
this.toDate = idate(selections[selections.length - 1], 'YYYY/MM/DD');
109+
this.fromDate = dayjs(selections[0], 'YYYY/MM/DD');
110+
this.toDate = dayjs(selections[selections.length - 1], 'YYYY/MM/DD');
111111
this.$emit('input', [
112112
this.fromDate,
113113
this.toDate,

0 commit comments

Comments
 (0)