根据系统时间段判断,当前在哪个时间段
一号20点-八号20点
八号20点-十五号20点
十五号20点-二十二20点
二十二号20点-次月一号20点
export function formatDateUtil() {
// 获取当前日期
var date = new Date();
var myweekday = date.getDate()
console.log("时间",date.toLocaleDateString())
const months =date.getFullYear()+"-"+(date.getMonth()+1)
let week: any = '';
var Hours = date.getHours(); //获取当前月份(0-11,0代表1月)
var Ye= date.getFullYear()+1
var Year= date.getFullYear()
var Month = date.getMonth() + 2;
var Monthss = date.getMonth() + 1;
//用=号判断
if(Monthss==12&&myweekday >= 22){
if(Hours>20){
week = Year+"-"+Monthss + '/22——' + Ye+"-"+1 + '/1'
return week
}else{
week = Year+"-"+12 + '/15——' + Year+"-"+12 + '/22'
return week
};
}else if(Monthss==1&&myweekday == 1){
if (Hours < 20) {
week = Year-1+"-"+12 + '/22——' + Ye+"-" + '/1'
return week ;
} else {
week = Year+"-"+Monthss + '/1——' + Year+"-"+Monthss + '/8'
return week;
}
} else{
if(myweekday==1){
if (Hours < 20) {
week = months + '/22——' + Year+"-"+Month + '/1'
return week ;
} else {
week = months + '/1——' + months + '/8'
return week;
}
}
if (myweekday == 22) {
if (Hours > 20) {
week = months + '/22——' + Year+"-"+Month+ '/1'
return week;
} else {
week = months + '/15——' + months + '/22'
return week;
}
}
if (myweekday == 15) {
if (Hours > 20) {
week = months + '/15——' + (months) + '/22'
return week;
} else {
week = months + '/8——' + months + '/15'
return week;
}
}
if (myweekday == 8) {
if (Hours > 20) {
week = months + '/8——' + months + '/15'
return week;
} else {
week = months + '/1——' + months + '/8'
return week;
}
}
if (myweekday > 15 && myweekday < 22) {
week = months + '/15——' + (months) + '/22'
return week;
}
if (myweekday > 8 && myweekday < 15) {
week = months + '/8——' + (months) + '/15'
return week;
}
if (myweekday > 1 && myweekday < 8) {
week = months + '/1——' + (months) + '/8'
return week;
}
if (myweekday > 22) {
week = months + '/22——' + Year+"-"+Month + '/1'
return week;
}
}
}