@shencom/utils-date
Version:
73 lines (70 loc) • 4.55 kB
JavaScript
import dayjs from 'dayjs';
import { FormatDateTime } from './format';
const now = dayjs();
const RangeToday = [FormatDateTime(now.startOf("day")), FormatDateTime(now.endOf("day"))];
const yesterdayStart = FormatDateTime(now.subtract(1, "day").startOf("day"));
const yesterdayEnd = FormatDateTime(dayjs(yesterdayStart).endOf("day"));
const RangeYesterday = [yesterdayStart, yesterdayEnd];
const beforeYesterdayStart = FormatDateTime(now.subtract(2, "day").startOf("day"));
const beforeYesterdayEnd = FormatDateTime(dayjs(beforeYesterdayStart).endOf("day"));
const RangeBeforeYesterday = [beforeYesterdayStart, beforeYesterdayEnd];
const weekStart = FormatDateTime(now.startOf("week"));
const weekEnd = FormatDateTime(dayjs(weekStart).endOf("week"));
const RangeWeek = [weekStart, weekEnd];
const beforeWeekStart = FormatDateTime(now.subtract(1, "week").startOf("week"));
const beforeWeekEnd = FormatDateTime(dayjs(beforeWeekStart).endOf("week"));
const RangeBeforeWeek = [beforeWeekStart, beforeWeekEnd];
const nextWeekStart = FormatDateTime(now.add(1, "week").startOf("week"));
const nextWeekEnd = FormatDateTime(dayjs(nextWeekStart).endOf("week"));
const RangeNextWeek = [nextWeekStart, nextWeekEnd];
const weekStartToNow = FormatDateTime(now.startOf("week"));
const weekEndToNow = FormatDateTime(now.endOf("day"));
const RangeWeekToNow = [weekStartToNow, weekEndToNow];
const lastWeekStart = FormatDateTime(now.subtract(1, "week").startOf("week"));
const lastWeekEnd = FormatDateTime(dayjs(lastWeekStart).endOf("week"));
const RangeLastWeek = [lastWeekStart, lastWeekEnd];
const lastFourWeekStartToNow = FormatDateTime(now.subtract(4, "week").startOf("week"));
const lastFourWeekEndToNow = FormatDateTime(now.endOf("day"));
const RangeLastFourWeek = [lastFourWeekStartToNow, lastFourWeekEndToNow];
const monthStart = FormatDateTime(now.startOf("month"));
const monthEnd = FormatDateTime(now.endOf("month"));
const RangeMonth = [monthStart, monthEnd];
const beforeMonthStart = FormatDateTime(now.subtract(1, "month").startOf("month"));
const beforeMonthEnd = FormatDateTime(dayjs(beforeMonthStart).endOf("month"));
const RangeBeforeMonth = [beforeMonthStart, beforeMonthEnd];
const nextMonthStart = FormatDateTime(now.add(1, "month").startOf("month"));
const nextMonthEnd = FormatDateTime(dayjs(nextMonthStart).endOf("month"));
const RangeNextMonth = [nextMonthStart, nextMonthEnd];
const monthStartToNow = FormatDateTime(now.startOf("month"));
const monthEndToNow = FormatDateTime(now.endOf("day"));
const RangeMonthToNow = [monthStartToNow, monthEndToNow];
const lastMonthEnd = FormatDateTime(now.endOf("day"));
const lastMonthStart = FormatDateTime(dayjs(lastMonthEnd).subtract(1, "month").startOf("day"));
const RangeLastMonth = [lastMonthStart, lastMonthEnd];
const lastThreeMonthEnd = FormatDateTime(now.endOf("day"));
const lastThreeMonthStart = FormatDateTime(
dayjs(lastThreeMonthEnd).subtract(3, "month").startOf("day")
);
const RangeLastThreeMonth = [lastThreeMonthStart, lastThreeMonthEnd];
const lastSixMonthEnd = FormatDateTime(now.endOf("day"));
const lastSixMonthStart = FormatDateTime(
dayjs(lastSixMonthEnd).subtract(6, "month").startOf("day")
);
const RangeLastSixMonth = [lastSixMonthStart, lastSixMonthEnd];
const yearStart = FormatDateTime(now.startOf("year"));
const yearEnd = FormatDateTime(now.endOf("year"));
const RangeYear = [yearStart, yearEnd];
const beforeYearStart = FormatDateTime(now.subtract(1, "year").startOf("year"));
const beforeYearEnd = FormatDateTime(dayjs(beforeYearStart).endOf("year"));
const RangeBeforeYear = [beforeYearStart, beforeYearEnd];
const nextYearStart = FormatDateTime(now.add(1, "year").startOf("year"));
const nextYearEnd = FormatDateTime(dayjs(nextYearStart).endOf("year"));
const RangeNextYear = [nextYearStart, nextYearEnd];
const yearStartToNow = FormatDateTime(now.startOf("year"));
const yearEndToNow = FormatDateTime(now.endOf("day"));
const RangeYearToNow = [yearStartToNow, yearEndToNow];
const lastYearEnd = FormatDateTime(now.endOf("day"));
const lastYearStart = FormatDateTime(dayjs(lastYearEnd).subtract(1, "year").startOf("day"));
const RangeLastYear = [lastYearStart, lastYearEnd];
export { RangeBeforeMonth, RangeBeforeWeek, RangeBeforeYear, RangeBeforeYesterday, RangeLastFourWeek, RangeLastMonth, RangeLastSixMonth, RangeLastThreeMonth, RangeLastWeek, RangeLastYear, RangeMonth, RangeMonthToNow, RangeNextMonth, RangeNextWeek, RangeNextYear, RangeToday, RangeWeek, RangeWeekToNow, RangeYear, RangeYearToNow, RangeYesterday };
//# sourceMappingURL=range-constant.js.map