|
|
|
@ -22,30 +22,39 @@ export class DateUtils { |
|
|
|
|
*/ |
|
|
|
|
public static getDate(currentDate: Date, type: number): any { |
|
|
|
|
const returnObj = { |
|
|
|
|
timeS: 0, |
|
|
|
|
timeE: 0, |
|
|
|
|
timeS: new Date(), |
|
|
|
|
timeE: new Date(), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (type === 1) { |
|
|
|
|
currentDate.setHours(0); |
|
|
|
|
currentDate.setMinutes(0); |
|
|
|
|
currentDate.setSeconds(0); |
|
|
|
|
returnObj.timeS = currentDate.getTime(); |
|
|
|
|
currentDate.setHours(23); |
|
|
|
|
currentDate.setMinutes(59); |
|
|
|
|
currentDate.setSeconds(59); |
|
|
|
|
returnObj.timeE = currentDate.getTime(); |
|
|
|
|
const start = new Date(currentDate); |
|
|
|
|
|
|
|
|
|
start.setHours(0); |
|
|
|
|
start.setMinutes(0); |
|
|
|
|
start.setSeconds(0); |
|
|
|
|
returnObj.timeS = start; |
|
|
|
|
|
|
|
|
|
const end = new Date(currentDate); |
|
|
|
|
end.setHours(23); |
|
|
|
|
end.setMinutes(59); |
|
|
|
|
end.setSeconds(59); |
|
|
|
|
returnObj.timeE = currentDate; |
|
|
|
|
|
|
|
|
|
} else if (type === 2) { |
|
|
|
|
currentDate.setDate(currentDate.getDate() - 1) |
|
|
|
|
currentDate.setHours(0); |
|
|
|
|
currentDate.setMinutes(0); |
|
|
|
|
currentDate.setSeconds(0); |
|
|
|
|
returnObj.timeS = currentDate.getTime(); |
|
|
|
|
currentDate.setHours(23); |
|
|
|
|
currentDate.setMinutes(59); |
|
|
|
|
currentDate.setSeconds(59); |
|
|
|
|
returnObj.timeE = currentDate.getTime(); |
|
|
|
|
|
|
|
|
|
const start = new Date(currentDate); |
|
|
|
|
start.setDate(currentDate.getDate() - 1) |
|
|
|
|
start.setHours(0); |
|
|
|
|
start.setMinutes(0); |
|
|
|
|
start.setSeconds(0); |
|
|
|
|
returnObj.timeS = start; |
|
|
|
|
|
|
|
|
|
const end = new Date(currentDate); |
|
|
|
|
end.setDate(currentDate.getDate() - 1) |
|
|
|
|
end.setHours(23); |
|
|
|
|
end.setMinutes(59); |
|
|
|
|
end.setSeconds(59); |
|
|
|
|
returnObj.timeE = end; |
|
|
|
|
|
|
|
|
|
} else if (type === 3) { |
|
|
|
|
const dayOfWeek = currentDate.getDay(); |
|
|
|
@ -56,14 +65,14 @@ export class DateUtils { |
|
|
|
|
start.setHours(0); |
|
|
|
|
start.setMinutes(0); |
|
|
|
|
start.setSeconds(0); |
|
|
|
|
returnObj.timeS = start.getTime(); |
|
|
|
|
returnObj.timeS = start; |
|
|
|
|
|
|
|
|
|
const end = new Date(currentDate); |
|
|
|
|
end.setDate(end.getDate() + 6) |
|
|
|
|
end.setHours(23); |
|
|
|
|
end.setMinutes(59); |
|
|
|
|
end.setSeconds(59); |
|
|
|
|
returnObj.timeE = end.getTime(); |
|
|
|
|
returnObj.timeE = end; |
|
|
|
|
|
|
|
|
|
} else if (type === 4) { |
|
|
|
|
const startOfThisWeek = new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate() - currentDate.getDay() + 1); |
|
|
|
@ -73,12 +82,12 @@ export class DateUtils { |
|
|
|
|
startOfLastWeek .setHours(0); |
|
|
|
|
startOfLastWeek .setMinutes(0); |
|
|
|
|
startOfLastWeek .setSeconds(0); |
|
|
|
|
returnObj.timeS = startOfLastWeek .getTime(); |
|
|
|
|
returnObj.timeS = startOfLastWeek; |
|
|
|
|
|
|
|
|
|
endOfLastWeek.setHours(23); |
|
|
|
|
endOfLastWeek.setMinutes(59); |
|
|
|
|
endOfLastWeek.setSeconds(59); |
|
|
|
|
returnObj.timeE = endOfLastWeek.getTime(); |
|
|
|
|
returnObj.timeE = endOfLastWeek; |
|
|
|
|
|
|
|
|
|
} else if (type === 5) { |
|
|
|
|
var daysInMonth = new Date(currentDate.getFullYear(), currentDate.getMonth()+1, 0).getDate(); |
|
|
|
@ -88,14 +97,14 @@ export class DateUtils { |
|
|
|
|
start.setHours(0); |
|
|
|
|
start.setMinutes(0); |
|
|
|
|
start.setSeconds(0); |
|
|
|
|
returnObj.timeS = start.getTime(); |
|
|
|
|
returnObj.timeS = start; |
|
|
|
|
|
|
|
|
|
const end = new Date(currentDate); |
|
|
|
|
end.setDate(daysInMonth) |
|
|
|
|
end.setHours(23); |
|
|
|
|
end.setMinutes(59); |
|
|
|
|
end.setSeconds(59); |
|
|
|
|
returnObj.timeE = end.getTime(); |
|
|
|
|
returnObj.timeE = end; |
|
|
|
|
|
|
|
|
|
} else if (type === 6) { |
|
|
|
|
var daysInMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0).getDate(); |
|
|
|
@ -106,7 +115,7 @@ export class DateUtils { |
|
|
|
|
start.setHours(0); |
|
|
|
|
start.setMinutes(0); |
|
|
|
|
start.setSeconds(0); |
|
|
|
|
returnObj.timeS = start.getTime(); |
|
|
|
|
returnObj.timeS = start; |
|
|
|
|
|
|
|
|
|
const end = new Date(currentDate); |
|
|
|
|
end.setMonth(currentDate.getMonth() - 1); |
|
|
|
@ -114,7 +123,7 @@ export class DateUtils { |
|
|
|
|
end.setHours(23); |
|
|
|
|
end.setMinutes(59); |
|
|
|
|
end.setSeconds(59); |
|
|
|
|
returnObj.timeE = end.getTime(); |
|
|
|
|
returnObj.timeE = end; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return returnObj; |
|
|
|
|