import i from "dayjs";
import { r as m, C as a } from "./base-PQGakkrl.js";
import "dayjs/locale/zh-cn";
import "dayjs/locale/en";
import o from "dayjs/plugin/localeData";
import c from "dayjs/plugin/objectSupport";
import f from "dayjs/plugin/isSameOrAfter";
import D from "dayjs/plugin/isSameOrBefore";
import j from "dayjs/plugin/isoWeek";
import l from "dayjs-lunar";
import u from "dayjs/plugin/utc";
import b from "dayjs/plugin/timezone";
i.locale("zh-cn");
i.extend(o);
i.extend(c);
i.extend(f);
i.extend(D);
i.extend(j);
i.extend(u);
i.extend(b);
i.extend(l);
class n {
  static objDay = i;
  static timezone = "PRC";
  // desc: 时区配置，默认中国时区，可设置为 "UTC"、 "America/New_York" 等
  static initDay(t) {
    return (a.isUndefined(t) ? i() : t).tz(this.timezone);
  }
  static getDayjsObject(t) {
    if (a.isEmpty(t))
      return this.initDay(i());
    if (i.isDayjs(t))
      return this.initDay(t.clone());
    let e;
    return a.isString(t) ? e = t.replace(/[/]/g, "-").replace(/：/g, ":") : a.isInt(t) ? e = new Date(parseInt(t, 10)) : a.isObject(t) && (e = t), this.initDay(i(e, "YYYY-MM-DD HH:mm:ss"));
  }
  /**
   * 获取时间格式
   * @param options  string|int| new Date() | dayjs() | {value,format}
   * @returns
   */
  static initFormat(t) {
    let e = { value: "", format: "YYYY-MM-DD" }, r;
    return a.isObject(t) ? i.isDayjs(t) ? r = t : (t.format && (e = a.getJsonMerge(e, t)), t.value || t.format ? r = this.getDayjsObject(t.value || "") : r = this.getDayjsObject(t)) : r = this.getDayjsObject(t), r.format(e.format);
  }
  static addTime(t, e, r = "days") {
    return this.getDayjsObject(t).add(e, r);
  }
  static subtractTime(t, e, r = "days") {
    return this.getDayjsObject(t).subtract(e, r);
  }
  /**
   * 比较时间差值
   * @param time1 开始时间
   * @param timeDiff2  比较时间
   * @param type  day week month year hour minute second millisecond
   * @returns
   */
  static diffTime(t, e, r = "millisecond") {
    return this.getDayjsObject(t).diff(this.getDayjsObject(e), r);
  }
  /* static isValid(time: any, checkFormat = "YYYY-MM-DD"): any {
      return Dayjs(time, checFormat, true).isValid();
  } */
  static lunar(t) {
    return this.getDayjsObject(t).lunar();
  }
}
m("date", (s, t) => n.initFormat({ value: s, format: t }));
m("dateTime", (s, t) => n.initFormat({ value: s, format: t }));
m("time", (s, t) => n.initFormat({ value: s, format: t }));
export {
  n as C
};
//# sourceMappingURL=day-Bz9LfelO.js.map
