季度扩展插件
yarn add QuarterOfYear
初始化,(入口文件)
import dayjs from 'dayjs';
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
dayjs.extend(quarterOfYear);
import { RangeValue } from 'rc-picker/lib/interface';
import dayjs from 'dayjs';
const Ranges: Record<
string,
Exclude<RangeValue<any>, null> | (() => Exclude<RangeValue<any>, null>)
> = {
今天: [
//兼容时分秒
dayjs().subtract(0, 'day').startOf('day'),
dayjs().subtract(0, 'day').endOf('day'),
],
本周: [dayjs().startOf('week'), dayjs().endOf('week')],
本月: [dayjs().startOf('month'), dayjs().endOf('month')],
本年: [dayjs().startOf('year'), dayjs().endOf('year')],
昨天: [
dayjs().subtract(1, 'day').startOf('day'),
dayjs().subtract(1, 'day').endOf('day'),
],
上周: [
dayjs().subtract(1, 'week').startOf('week'),
dayjs().subtract(1, 'week').endOf('week'),
],
上月: [
dayjs().subtract(1, 'month').startOf('month'),
dayjs().subtract(1, 'month').endOf('month'),
],
本季度: [dayjs().startOf('quarter'), dayjs().endOf('quarter')],
上季度: [
dayjs().subtract(1, 'quarter').startOf('quarter'),
dayjs().subtract(1, 'quarter').endOf('quarter'),
],
};
错误记录 clone.weekday is not a function
初始化dayjs
import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import localeData from 'dayjs/plugin/localeData';
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
import relativeTime from 'dayjs/plugin/relativeTime';
import weekday from 'dayjs/plugin/weekday';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import weekYear from 'dayjs/plugin/weekYear';
dayjs.extend(quarterOfYear);
dayjs.extend(relativeTime);
dayjs.extend(customParseFormat);
dayjs.extend(advancedFormat);
dayjs.extend(weekday);
dayjs.extend(localeData);
dayjs.extend(weekOfYear);
dayjs.extend(weekYear);