Skip to content

Commit c3f57f1

Browse files
author
mod
committed
update Calendar
1 parent aefec4e commit c3f57f1

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/components/calendar/calendar.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
</DatePicker>
1717
<Icon type="ios-arrow-forward" :class="[classes + '-action-arrow']" @click.native="next" />
1818
</div>
19-
<!--datePicker-->
20-
<!--DatePicker end-->
2119
<table :class="classes">
2220
<thead>
2321
<tr :class="[classes + '-header']">

src/components/calendar/date-format.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
// 判断平闰年
2-
export function isRunYear(fullYear) {
3-
return fullYear % 4 == 0 && (fullYear % 100 != 0 || fullYear % 400 == 0);
4-
}
5-
// 获取一个月有多少天
1+
// get month has days
62
function getCountDays(date) {
73
var curDate = date ? new Date(date) : new Date();
84
var curMonth = curDate.getMonth();
95
curDate.setMonth(curMonth + 1);
106
curDate.setDate(0);
117
return curDate.getDate();
128
}
9+
// get prev months show days
1310
function getPrevDaysList (month,year){
1411
let startIndex = weekStartIndex(month, year);
1512
const startToArray = new Array(startIndex).fill("").map((item, index) => {
@@ -23,6 +20,7 @@ function getPrevDaysList (month,year){
2320
});
2421
return startToArray;
2522
}
23+
// get next month show some days
2624
function getNextDaysList(prev, now){
2725
const total = prev + now;
2826
const floorTotal = Math.ceil( total/7 ) * 7 - total;
@@ -37,36 +35,38 @@ function getNextDaysList(prev, now){
3735
});
3836
return nextToArray;
3937
}
40-
// 获取列表显示日历时间
38+
// get now month days
39+
function getNowDaysList(days){
40+
const nowDays = new Array(days).fill("").map((item, index) => {
41+
item = index + 1;
42+
return {
43+
day: item,
44+
type: 'now',
45+
selected: false,
46+
disabled: false
47+
};
48+
});
49+
return nowDays;
50+
}
51+
// get now days show days list
4152
export function getCalendarList(month, year) {
4253
if( !month || !year ){
4354
return [];
4455
}
4556
const days = getCountDays(year + "-" + month);
46-
4757
const prevToArray = getPrevDaysList(month, year);
4858
let prevStartIndex = weekStartIndex(month, year);
4959
prevStartIndex = prevStartIndex === 0 ? 7 : prevStartIndex;
5060
const nextToArray = getNextDaysList(prevStartIndex, days);
51-
const nowToArray = new Array(days).fill("").map((item, index) => {
52-
item = index + 1;
53-
return {
54-
day: item,
55-
type: 'now',
56-
selected: false,
57-
disabled: false
58-
};
59-
});
61+
const nowToArray = getNowDaysList(days);
6062
return prevToArray.concat(nowToArray, nextToArray);
6163
}
62-
6364
export function weekStartIndex(month, year) {
6465
const day = "01";
6566
month = month < 10 ? "0" + month : month;
6667
const time = year + "-" + month + "-" + day;
6768
return new Date(time).getDay();
6869
}
69-
7070
export function getNowTime(){
7171
const date = new Date();
7272
return {

0 commit comments

Comments
 (0)