|
|
|
@ -82,7 +82,7 @@ class Calendar { |
|
|
|
const y = date[1] === 1 ? date[0] - 1 : date[0]; |
|
|
|
const m = date[1] === 1 ? 12 : date[1] - 1; |
|
|
|
let w = DateClass.solarMonth(y, m); |
|
|
|
// console.log("获取当月前面需补齐的数组-->",y,m,w,last)
|
|
|
|
console.log("获取当月前面需补齐的数组-->",y,m,w,last) |
|
|
|
const arr: dateBase[] = []; |
|
|
|
for (let i = 0; i < last; i++) { |
|
|
|
const lun = DateClass.getLunars(y, m, w - i); |
|
|
|
@ -171,13 +171,17 @@ class Calendar { |
|
|
|
const result = this.validateDate(date); |
|
|
|
|
|
|
|
const currentDay = DateClass.solarWeeks(result[0], result[1]); |
|
|
|
// console.log("获取当月的完整数据",currentDay,result)
|
|
|
|
console.log("获取当月的完整数据",currentDay,result) |
|
|
|
// 获取当月的完整数据
|
|
|
|
const beforDays = this.beforDays(date, currentDay).reverse(); |
|
|
|
|
|
|
|
const m = this.getDay(date, beforDays); |
|
|
|
|
|
|
|
console.log("获取当月的完整数据--->",m,date) |
|
|
|
|
|
|
|
const afterDays = this.afterDays(m, date); |
|
|
|
|
|
|
|
|
|
|
|
// 转化成参数
|
|
|
|
const params = this.getDateParams(afterDays, date); |
|
|
|
|
|
|
|
@ -190,6 +194,58 @@ class Calendar { |
|
|
|
// console.log("日历数据",dateArray)
|
|
|
|
return dateArray; |
|
|
|
} |
|
|
|
//获得一周的所有日期
|
|
|
|
getWeekNumber(year: number, month: number, taday: number) { |
|
|
|
let dateStr = year + "-" + month + "-" + taday; // 要转换的日期字符串
|
|
|
|
let now = new Date(dateStr); |
|
|
|
let nowTime = now.getTime(); |
|
|
|
let second = nowTime % 86400000; |
|
|
|
let day = (now.getDay() + 6) % 7; |
|
|
|
let endTime = nowTime - second + new Date().getTimezoneOffset() * 60000 - day * 86400000; |
|
|
|
// var dataAry = new Array
|
|
|
|
// for(let i = 0; i <7; i++) {
|
|
|
|
let nextWeekFirstDatysss = new Date(endTime ); |
|
|
|
// let y: any = nextWeekFirstDaty.getFullYear();
|
|
|
|
// let m: any = nextWeekFirstDaty.getMonth() + 1;
|
|
|
|
// let d: any = nextWeekFirstDaty.getDate();
|
|
|
|
// dataAry.push([y,m,d])
|
|
|
|
// }
|
|
|
|
|
|
|
|
console.log("获得一周的所有日期---------------->",dateStr,now.getDay(),day,nextWeekFirstDatysss,endTime) |
|
|
|
|
|
|
|
|
|
|
|
let currentTime = DateClass.getCurrent() |
|
|
|
const dateArray: dateBase[] = []; |
|
|
|
for(let i = 0; i <7; i++) { |
|
|
|
let nextWeekFirstDaty = new Date(endTime + 86400000*(i+1) ); |
|
|
|
let y: any = nextWeekFirstDaty.getFullYear(); |
|
|
|
let m: any = nextWeekFirstDaty.getMonth() + 1; |
|
|
|
let d: any = nextWeekFirstDaty.getDate(); |
|
|
|
const lun = DateClass.getLunars(y, m, d); |
|
|
|
const l = lun.split('-'); |
|
|
|
console.log("获得一周的所有日期",i,d,endTime + 86400000*(i+1)) |
|
|
|
dateArray.push({ |
|
|
|
title: d, |
|
|
|
isCurrent: true, |
|
|
|
isHolidays: DateClass.getHolidays([y, m, d + i]), |
|
|
|
isWorks: DateClass.getWorks([y, m, d - i]), |
|
|
|
date: `${y}-${clockFactory(m)}-${clockFactory(d + i)}`, |
|
|
|
lunars: lun, |
|
|
|
lunarsChinese: |
|
|
|
DateClass.toChinaMonth(Number(l[1])) + DateClass.toChinaDay(Number(l[2])), |
|
|
|
lunarsChina: DateClass.toChinaDay(Number(l[2])), |
|
|
|
isNow: currentTime[2] === d ? true : false, |
|
|
|
solarDay: DateClass.getSolarDay(m, d + i), |
|
|
|
lunarDay: DateClass.getlunarDay(Number(l[0]), Number(l[1]), Number(l[2])), |
|
|
|
animal: DateClass.getAnimal(Number(l[0])), |
|
|
|
astro: DateClass.toAstro(y, m, d + i), |
|
|
|
term: getTerm(Number(l[0]), m, d + i), |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
return dateArray |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export default new Calendar(); |
|
|
|
|