@aplus-frontend/ui
Version:
2 lines (1 loc) • 2.59 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@aplus-frontend/utils"),u=require("dayjs"),s=(t,a=u().valueOf())=>u(l.getTimeFormatToZone(a,t??l.userTimezone)),b=(t,a)=>{const e=s(t,a);return[e.startOf("day"),e.endOf("day")]},v=(t,a)=>{const e=s(t,a);return[e.startOf("day").subtract(1,"day").startOf("day"),e.endOf("day").subtract(1,"day").endOf("day")]},y=(t,a)=>{const e=s(t,a);return[e.startOf("week").startOf("day"),e.endOf("week").endOf("day")]},c=(t,a)=>{const e=s(t,a);return[e.subtract(1,"week").startOf("week").startOf("day"),e.subtract(1,"week").endOf("week").endOf("day")]},O=(t,a)=>{const e=s(t,a);return[e.startOf("month").startOf("day"),e.endOf("month").endOf("day")]},m=(t,a)=>{const e=s(t,a);return[e.subtract(1,"month").startOf("month").startOf("day"),e.subtract(1,"month").endOf("month").endOf("day")]},p=(t,a)=>{const e=s(t,a),r=e.month(),f=Math.floor(r/3),n=e.month(f*3).date(1).startOf("day"),o=n.add(2,"month").endOf("month").endOf("day");return[n,o]},h=(t,a)=>{const r=s(t,a).subtract(3,"month"),f=r.month(),n=Math.floor(f/3),o=r.clone().month(n*3).date(1).startOf("day"),G=o.clone().add(2,"month").endOf("month").endOf("day");return[o,G]},i=(t,a)=>{const e=s(t,a);return[e.startOf("year").startOf("day"),e.endOf("year").endOf("day")]},T=(t,a)=>{const e=s(t,a);return[e.subtract(1,"year").startOf("year").startOf("day"),e.subtract(1,"year").endOf("year").endOf("day")]},d=(t,a,e)=>{const r=s(a,e);return[r.subtract(t-1,"day").startOf("day"),r.endOf("day")]},k=(t,a,e)=>[{label:e?e("ap.field.thisWeek"):"本周",value:y(t,a)},{label:e?e("ap.field.lastWeek"):"上周",value:c(t,a)},{label:e?e("ap.field.lastXDays",{day:7}):"近7天",value:d(7,t,a)},{label:e?e("ap.field.lastXDays",{day:30}):"近30天",value:d(30,t,a)},{label:e?e("ap.field.lastXDays",{day:90}):"近90天",value:d(90,t,a)},{label:e?e("ap.field.thisMonth"):"本月",value:O(t,a)},{label:e?e("ap.field.lastMonth"):"上月",value:m(t,a)},{label:e?e("ap.field.thisQuarter"):"本季度",value:p(t,a)},{label:e?e("ap.field.lastQuarter"):"上季度",value:h(t,a)},{label:e?e("ap.field.thisYear"):"本年",value:i(t,a)},{label:e?e("ap.field.lastYear"):"去年",value:T(t,a)}];exports.presetsDefault=k;exports.presetsGetLastMonth=m;exports.presetsGetLastQuarter=h;exports.presetsGetLastWeek=c;exports.presetsGetLastXDays=d;exports.presetsGetLastYear=T;exports.presetsGetThisMonth=O;exports.presetsGetThisQuarter=p;exports.presetsGetThisWeek=y;exports.presetsGetThisYear=i;exports.presetsGetTimezoneFormat=s;exports.presetsGetToday=b;exports.presetsGetYesterday=v;