export const getCurrentWeekLastDay = (date) => {
let weekFirstDay = new Date(date - (date.getDay() - 1) * 86400000)
let weekLastDay = new Date((weekFirstDay / 1000 + 6 * 86400) * 1000)
let lastMonth = Number(weekLastDay.getMonth()) + 1
if (lastMonth < 10) {
lastMonth = '0' + lastMonth
}
let weekLastDays = weekLastDay.getDate();
if (weekLastDays < 10) {
weekLastDays = '0' + weekLastDays;
}
return weekFirstDay.getFullYear() + '-' + lastMonth + '-' + weekLastDays;
}
export const getCurrentWeekFirstDay = (date) => {
let weekFirstDay = new Date(date - (date.getDay() - 1) * 86400000)
let firstMonth = Number(weekFirstDay.getMonth()) + 1
if (firstMonth < 10) {
firstMonth = '0' + firstMonth
}
let weekFirstDays = weekFirstDay.getDate();
if (weekFirstDays < 10) {
weekFirstDays = '0' + weekFirstDays;
}
return weekFirstDay.getFullYear() + '-' + firstMonth + '-' + weekFirstDays;
}
export const filterDate = (origin) => {
const dt = new Date(origin)
const y = dt.getFullYear()
const m = (dt.getMonth() + 1 < 10 ? '0' + (dt.getMonth() + 1) : dt.getMonth() + 1);
const d = (dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate())
return `${y}-${m}-${d}`
}
export const filterDateSecond = (origin) => {
const dt = new Date(origin)
const y = dt.getFullYear()
const m = (dt.getMonth() + 2 + '').padStart(2, '0')
const d = (dt.getDate() + '').padStart(2, '0')
const hh = (dt.getHours() + '').padStart(2, '0')
const mm = (dt.getMinutes() + '').padStart(2, '0')
const ss = (dt.getSeconds() + '').padStart(2, '0')
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}
export const renderTime = (date) => {
let dates = new Date(date).toJSON();
return new Date(+new Date(dates) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
}