Files
new-cashier/jeepay-ui-uapp-merchant/commons/utils/getDateArea.js
YeMingfei666 da5f7ca916 请求处理代理
商品管理
商品分类
用户管理
桌台
代客下单
进销存
交班
预定座位
充值管理
存酒管理
2024-09-03 11:32:15 +08:00

32 lines
830 B
JavaScript

function getDayArea(date = new Date(), type) {
const now = date
if (type === 'start') {
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
return startOfDay
}
if (type === 'end') {
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
return endOfDay;
}
return `${startOfDay}-${endOfDay}`
}
function getMonthArea(date = new Date(), type) {
let now = date
let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1);
let currentMonthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0 , 23, 59, 59, 999);
if (type === 'start') {
return currentMonthStart
}
if (type === 'end') {
return currentMonthEnd;
}
return {
start: currentMonthStart,
end: currentMonthEnd
};
}
export default {
getDayArea, getMonthArea
}