UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

54 lines (53 loc) 2.99 kB
import { utc } from "../chunk-O3UNRTSC.mjs"; import { DateTime } from "../chunk-HFRGTGH6.mjs"; import "../chunk-IKUC55KC.mjs"; import "../chunk-ADJAEGCT.mjs"; import { choose } from "../chunk-AVHYDITZ.mjs"; import "../chunk-EBIF6AMC.mjs"; import "../chunk-KCY4RPFR.mjs"; import "../chunk-SSROJBD5.mjs"; import "../chunk-S3NSPQ7M.mjs"; import "../chunk-NNA77YYC.mjs"; import "../chunk-SJGQU3OG.mjs"; import "../chunk-D5IYAIMK.mjs"; import "../chunk-PF7HDF6B.mjs"; import "../chunk-IXK47WKF.mjs"; import "../chunk-PIRWVOO2.mjs"; import "../chunk-AAND4MKF.mjs"; import "../chunk-4N72FQFX.mjs"; // src/utils/Period.ts var toStartEnd = ({ period, start, end, zone = utc }) => { const today = DateTime.now.withZone(zone).startOf("day"); return choose(period).equals("today", { start: today, end: today.endOf("day") }).equals("yesterday", { start: today.subtract(1, "day"), end: today }).equals("tomorrow", { start: today.add(1, "day"), end: today.add(1, "day").endOf("day") }).equals("this-week", { start: today.startOf("week"), end: today.endOf("week") }).equals("last-seven-days", { start: today.subtract(6, "day"), end: today.endOf("day") }).equals("last-week", { start: today.subtract(1, "week").startOf("week"), end: today.subtract(1, "week").endOf("week") }).equals("last-two-weeks", { start: today.subtract(13, "day"), end: today.endOf("day") }).equals("last-month", { start: today.subtract(1, "month").startOf("month"), end: today.subtract(1, "month").endOf("month") }).equals("next-week", { start: today.add(1, "week").startOf("week"), end: today.add(1, "week").endOf("week") }).equals("this-month", { start: today.startOf("month"), end: today.endOf("month") }).equals("three-months-ago", { start: today.subtract(3, "month").startOf("month"), end: today.subtract(3, "month").endOf("month") }).equals("two-months-ago", { start: today.subtract(2, "month").startOf("month"), end: today.subtract(2, "month").endOf("month") }).equals("last-three-months", { start: today.subtract(3, "month"), end: today.endOf("day") }).equals("next-month", { start: today.add(1, "month").startOf("month"), end: today.add(1, "month").endOf("month") }).equals("this-year", { start: today.startOf("year"), end: today.endOf("year") }).equals("last-year", { start: today.subtract(1, "year").startOf("year"), end: today.subtract(1, "year").endOf("year") }).equals("two-years-ago", { start: today.subtract(2, "year").startOf("year"), end: today.subtract(2, "year").endOf("year") }).equals("three-years-ago", { start: today.subtract(3, "year").startOf("year"), end: today.subtract(3, "year").endOf("year") }).equals("next-year", { start: today.add(1, "year").startOf("year"), end: today.add(1, "year").endOf("year") }).equals("all-time", { start: new DateTime(0).withZone(zone), end: today.endOf("day") }).else({ start: start ?? today, end: end ?? today.endOf("day") }); }; export { toStartEnd }; //# sourceMappingURL=Period.mjs.map