"use strict";const t=require("../vendor.js");t.dayjs.locale("zh-cn"),t.dayjs.extend(t.relativeTime),exports.checkWorkStatus=function(){const e=t.dayjs().hour();return e>=8&&e<18?{status:"在线",value:"Online"}:{status:"已休息",value:"Offline"}},exports.generateTimeSlots=function(e=null){const r=e?t.dayjs(e):t.dayjs(),s=(e?t.dayjs(e):t.dayjs()).valueOf(),o=[];let n=8;for(;n<18;){const t=Math.min(n+2,18),e=r.hour(n).minute(0).second(0),a=r.hour(t).minute(0).second(0),u=e.format("HH:mm"),i=a.format("HH:mm"),f=s>=e.valueOf()&&s<a.valueOf();a.valueOf()>s&&o.push({label:f?"两个小时内":`${u}-${i}`,str:u,end:i,isCurrent:f,date:r.format("YYYY-MM-DD"),startTimestamp:e.valueOf(),endTimestamp:a.valueOf()}),n=t}return console.log("slots",o),o},exports.getCurrentHour=function(){const t=new Date,e=t.getHours(),r=t.getMinutes();return console.log(e,r,"dayjs().hour()"),{currentHour:e,currentMinute:r}},exports.getDate=function(e){return e?t.dayjs(e).format("YYYY-MM-DD"):""},exports.getFromNow=function(e){return e?t.dayjs(e).fromNow():""},exports.getIsInRangeInclusive=function(e,r){const s=t.dayjs(),o=t.dayjs(e),n=t.dayjs(r);return s.isAfter(o)&&s.isBefore(n)},exports.getTheFutureDay=function(e=1){return t.dayjs().add(e,"day").format("YYYY-MM-DD")},exports.getTimeRangeDisplay=function(e,r,s=null){try{const o=t.dayjs(e),n=t.dayjs(r),a=s?t.dayjs(s):t.dayjs();if(!o.isValid()||!n.isValid())return"时间格式错误";if(o.isAfter(n))return"时间顺序错误";if(a.isAfter(o)&&a.isBefore(n))return"两个小时内";return o.isSame(n,"day")?`${o.format("YYYY-MM-DD")} ${o.format("HH:mm")}-${n.format("HH:mm")}`:`${o.format("YYYY-MM-DD HH:mm")} - ${n.format("YYYY-MM-DD HH:mm")}`}catch(o){return"时间格式错误"}},exports.showCurrentTime=function(){const e=t.dayjs().format("HH:mm");return console.log(e),e},exports.showDay=function(e){return t.dayjs(e).format("YYYY-MM-DD")},exports.specificTime=function(e){const r=t.dayjs(),s=t.dayjs(e);let o=Math.abs(s.diff(r,"hour",!0))<=2||s.isBefore(r);return console.log(o,"hoursDiff"),o};
