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