Socket
Socket
Sign inDemoInstall

dayjs

Package Overview
Dependencies
0
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

dist/esm/constant-033807b3.js

433

dist/index.d.ts

@@ -1,4 +0,429 @@

import { dayjs } from './dayjs';
export * from './types';
export * from './dayjs';
export default dayjs;
/// <reference path="./locale/index.d.ts" />
export = dayjs;
declare function dayjs (date?: dayjs.ConfigType): dayjs.Dayjs
declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, strict?: boolean): dayjs.Dayjs
declare function dayjs (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean): dayjs.Dayjs
declare namespace dayjs {
interface ConfigTypeMap {
default: string | number | Date | Dayjs | null | undefined
}
export type ConfigType = ConfigTypeMap[keyof ConfigTypeMap]
export interface FormatObject { locale?: string, format?: string, utc?: boolean }
export type OptionType = FormatObject | string | string[]
export type UnitTypeShort = 'd' | 'D' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
export type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date'
export type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates'
export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort;
export type OpUnitType = UnitType | "week" | "weeks" | 'w';
export type QUnitType = UnitType | "quarter" | "quarters" | 'Q';
export type ManipulateType = Exclude<OpUnitType, 'date' | 'dates'>;
class Dayjs {
constructor (config?: ConfigType)
/**
* All Day.js objects are immutable. Still, `dayjs#clone` can create a clone of the current object if you need one.
* ```
* dayjs().clone()// => Dayjs
* dayjs(dayjs('2019-01-25')) // passing a Dayjs object to a constructor will also clone it
* ```
* Docs: https://day.js.org/docs/en/parse/dayjs-clone
*/
clone(): Dayjs
/**
* This returns a `boolean` indicating whether the Day.js object contains a valid date or not.
* ```
* dayjs().isValid()// => boolean
* ```
* Docs: https://day.js.org/docs/en/parse/is-valid
*/
isValid(): boolean
/**
* Get the year.
* ```
* dayjs().year()// => 2020
* ```
* Docs: https://day.js.org/docs/en/get-set/year
*/
year(): number
/**
* Set the year.
* ```
* dayjs().year(2000)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/year
*/
year(value: number): Dayjs
/**
* Get the month.
*
* Months are zero indexed, so January is month 0.
* ```
* dayjs().month()// => 0-11
* ```
* Docs: https://day.js.org/docs/en/get-set/month
*/
month(): number
/**
* Set the month.
*
* Months are zero indexed, so January is month 0.
*
* Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the next year.
* ```
* dayjs().month(0)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/month
*/
month(value: number): Dayjs
/**
* Get the date of the month.
* ```
* dayjs().date()// => 1-31
* ```
* Docs: https://day.js.org/docs/en/get-set/date
*/
date(): number
/**
* Set the date of the month.
*
* Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the next months.
* ```
* dayjs().date(1)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/date
*/
date(value: number): Dayjs
/**
* Get the day of the week.
*
* Returns numbers from 0 (Sunday) to 6 (Saturday).
* ```
* dayjs().day()// 0-6
* ```
* Docs: https://day.js.org/docs/en/get-set/day
*/
day(): number
/**
* Set the day of the week.
*
* Accepts numbers from 0 (Sunday) to 6 (Saturday). If the range is exceeded, it will bubble up to next weeks.
* ```
* dayjs().day(0)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/day
*/
day(value: number): Dayjs
/**
* Get the hour.
* ```
* dayjs().hour()// => 0-23
* ```
* Docs: https://day.js.org/docs/en/get-set/hour
*/
hour(): number
/**
* Set the hour.
*
* Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the next day.
* ```
* dayjs().hour(12)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/hour
*/
hour(value: number): Dayjs
/**
* Get the minutes.
* ```
* dayjs().minute()// => 0-59
* ```
* Docs: https://day.js.org/docs/en/get-set/minute
*/
minute(): number
/**
* Set the minutes.
*
* Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next hour.
* ```
* dayjs().minute(59)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/minute
*/
minute(value: number): Dayjs
/**
* Get the seconds.
* ```
* dayjs().second()// => 0-59
* ```
* Docs: https://day.js.org/docs/en/get-set/second
*/
second(): number
/**
* Set the seconds.
*
* Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next minutes.
* ```
* dayjs().second(1)// Dayjs
* ```
*/
second(value: number): Dayjs
/**
* Get the milliseconds.
* ```
* dayjs().millisecond()// => 0-999
* ```
* Docs: https://day.js.org/docs/en/get-set/millisecond
*/
millisecond(): number
/**
* Set the milliseconds.
*
* Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the next seconds.
* ```
* dayjs().millisecond(1)// => Dayjs
* ```
* Docs: https://day.js.org/docs/en/get-set/millisecond
*/
millisecond(value: number): Dayjs
/**
* Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes.
*
* In general:
* ```
* dayjs().set(unit, value) === dayjs()[unit](value)
* ```
* Units are case insensitive, and support plural and short forms.
* ```
* dayjs().set('date', 1)
* dayjs().set('month', 3) // April
* dayjs().set('second', 30)
* ```
* Docs: https://day.js.org/docs/en/get-set/set
*/
set(unit: UnitType, value: number): Dayjs
/**
* String getter, returns the corresponding information getting from Day.js object.
*
* In general:
* ```
* dayjs().get(unit) === dayjs()[unit]()
* ```
* Units are case insensitive, and support plural and short forms.
* ```
* dayjs().get('year')
* dayjs().get('month') // start 0
* dayjs().get('date')
* ```
* Docs: https://day.js.org/docs/en/get-set/get
*/
get(unit: UnitType): number
/**
* Returns a cloned Day.js object with a specified amount of time added.
* ```
* dayjs().add(7, 'day')// => Dayjs
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/manipulate/add
*/
add(value: number, unit?: ManipulateType): Dayjs
/**
* Returns a cloned Day.js object with a specified amount of time subtracted.
* ```
* dayjs().subtract(7, 'year')// => Dayjs
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/manipulate/subtract
*/
subtract(value: number, unit?: ManipulateType): Dayjs
/**
* Returns a cloned Day.js object and set it to the start of a unit of time.
* ```
* dayjs().startOf('year')// => Dayjs
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/manipulate/start-of
*/
startOf(unit: OpUnitType): Dayjs
/**
* Returns a cloned Day.js object and set it to the end of a unit of time.
* ```
* dayjs().endOf('month')// => Dayjs
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/manipulate/end-of
*/
endOf(unit: OpUnitType): Dayjs
/**
* Get the formatted date according to the string of tokens passed in.
*
* To escape characters, wrap them in square brackets (e.g. [MM]).
* ```
* dayjs().format()// => current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00'
* dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')// 'YYYYescape 2019-01-25T00:00:00-02:00Z'
* dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019'
* ```
* Docs: https://day.js.org/docs/en/display/format
*/
format(template?: string): string
/**
* This indicates the difference between two date-time in the specified unit.
*
* To get the difference in milliseconds, use `dayjs#diff`
* ```
* const date1 = dayjs('2019-01-25')
* const date2 = dayjs('2018-06-05')
* date1.diff(date2) // 20214000000 default milliseconds
* date1.diff() // milliseconds to current time
* ```
*
* To get the difference in another unit of measurement, pass that measurement as the second argument.
* ```
* const date1 = dayjs('2019-01-25')
* date1.diff('2018-06-05', 'month') // 7
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/display/difference
*/
diff(date?: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number
/**
* This returns the number of **milliseconds** since the Unix Epoch of the Day.js object.
* ```
* dayjs('2019-01-25').valueOf() // 1548381600000
* +dayjs(1548381600000) // 1548381600000
* ```
* To get a Unix timestamp (the number of seconds since the epoch) from a Day.js object, you should use Unix Timestamp `dayjs#unix()`.
*
* Docs: https://day.js.org/docs/en/display/unix-timestamp-milliseconds
*/
valueOf(): number
/**
* This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
* ```
* dayjs('2019-01-25').unix() // 1548381600
* ```
* This value is floored to the nearest second, and does not include a milliseconds component.
*
* Docs: https://day.js.org/docs/en/display/unix-timestamp
*/
unix(): number
/**
* Get the number of days in the current month.
* ```
* dayjs('2019-01-25').daysInMonth() // 31
* ```
* Docs: https://day.js.org/docs/en/display/days-in-month
*/
daysInMonth(): number
/**
* To get a copy of the native `Date` object parsed from the Day.js object use `dayjs#toDate`.
* ```
* dayjs('2019-01-25').toDate()// => Date
* ```
*/
toDate(): Date
/**
* To serialize as an ISO 8601 string.
* ```
* dayjs('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z'
* ```
* Docs: https://day.js.org/docs/en/display/as-json
*/
toJSON(): string
/**
* To format as an ISO 8601 string.
* ```
* dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z'
* ```
* Docs: https://day.js.org/docs/en/display/as-iso-string
*/
toISOString(): string
/**
* Returns a string representation of the date.
* ```
* dayjs('2019-01-25').toString() // 'Fri, 25 Jan 2019 02:00:00 GMT'
* ```
* Docs: https://day.js.org/docs/en/display/as-string
*/
toString(): string
/**
* Get the UTC offset in minutes.
* ```
* dayjs().utcOffset()
* ```
* Docs: https://day.js.org/docs/en/manipulate/utc-offset
*/
utcOffset(): number
/**
* This indicates whether the Day.js object is before the other supplied date-time.
* ```
* dayjs().isBefore(dayjs('2011-01-01')) // default milliseconds
* ```
* If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
* ```
* dayjs().isBefore('2011-01-01', 'year')// => boolean
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/query/is-before
*/
isBefore(date: ConfigType, unit?: OpUnitType): boolean
/**
* This indicates whether the Day.js object is the same as the other supplied date-time.
* ```
* dayjs().isSame(dayjs('2011-01-01')) // default milliseconds
* ```
* If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
* ```
* dayjs().isSame('2011-01-01', 'year')// => boolean
* ```
* Docs: https://day.js.org/docs/en/query/is-same
*/
isSame(date: ConfigType, unit?: OpUnitType): boolean
/**
* This indicates whether the Day.js object is after the other supplied date-time.
* ```
* dayjs().isAfter(dayjs('2011-01-01')) // default milliseconds
* ```
* If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
* ```
* dayjs().isAfter('2011-01-01', 'year')// => boolean
* ```
* Units are case insensitive, and support plural and short forms.
*
* Docs: https://day.js.org/docs/en/query/is-after
*/
isAfter(date: ConfigType, unit?: OpUnitType): boolean
locale(): string
locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
}
export type PluginFunc<T = unknown> = (option: T, c: typeof Dayjs, d: typeof dayjs) => void
export function extend<T = unknown>(plugin: PluginFunc<T>, option?: T): Dayjs
export function locale(preset?: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string
export function isDayjs(d: any): d is Dayjs
export function unix(t: number): Dayjs
const Ls : { [key: string] : ILocale }
}

443

dist/index.js

@@ -1,442 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
Dayjs: () => Dayjs,
dayjs: () => dayjs,
default: () => src_default,
extend: () => extend,
isDayjs: () => isDayjs,
locale: () => parseLocale,
unix: () => unix
});
module.exports = __toCommonJS(src_exports);
// src/constants.ts
var SECONDS_A_MINUTE = 60;
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
var MILLISECONDS_A_SECOND = 1e3;
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
var INVALID_DATE_STRING = "Invalid Date";
var DEFAULT_FORMAT = "YYYY-MM-DDTHH:mm:ssZ";
var REGEX_PARSE = /^(\d{4})[/-]?(\d{1,2})?[/-]?(\d{0,2})[\sTt]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
// src/utils.ts
var mutable = (val) => val;
var pick = (object, keys) => keys.reduce((obj, key) => {
if (Object.prototype.hasOwnProperty.call(object, key))
obj[key] = object[key];
return obj;
}, {});
var cloneDate = (date) => new Date(date);
var padZoneStr = (utcOffset) => {
const negMinutes = -utcOffset;
const minutes = Math.abs(negMinutes);
const hourOffset = Math.floor(minutes / 60);
const minuteOffset = minutes % 60;
return `${negMinutes <= 0 ? "+" : "-"}${`${hourOffset}`.padStart(2, "0")}:${`${minuteOffset}`.padStart(2, "0")}`;
};
var isEmptyObject = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 0;
// src/units.ts
var units = mutable({
y: "year",
M: "month",
D: "date",
h: "hour",
m: "minute",
s: "second",
ms: "millisecond",
d: "day",
w: "week"
});
var unitsShort = Object.keys(units);
var unitsLong = Object.values(units);
var isShortUnit = (unit) => unitsShort.includes(unit);
var normalize = (unit) => {
var _a, _b;
if (isShortUnit(unit)) {
return units[unit];
}
const normalizedUnit = (_b = (_a = unit == null ? void 0 : unit.toLowerCase()) == null ? void 0 : _a.replace(/s$/, "")) != null ? _b : "";
return normalizedUnit;
};
// src/locale/en.ts
var locale = {
name: "en",
weekdays: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
months: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var en_default = locale;
// src/dayjs.ts
var globalLocale = "en";
var loadedLocales = {};
loadedLocales[globalLocale] = en_default;
var parseDate = (date) => {
if (date instanceof Date)
return cloneDate(date);
else if (date === null)
return new Date(Number.NaN);
else if (date === void 0)
return new Date();
else if (isEmptyObject(date))
return new Date();
else if (Array.isArray(date))
return new Date(date[0], date[1], date[2], date[3], date[4], date[5], date[6]);
else if (typeof date === "string" && !/z$/i.test(date)) {
const d = date.match(REGEX_PARSE);
if (d) {
const m = +d[2] - 1 || 0;
const ms = +(d[7] || "0").slice(0, 3);
return new Date(+d[1], m, +(d[3] || 1), +(d[4] || 0), +(d[5] || 0), +(d[6] || 0), ms);
}
}
return new Date(date);
};
var parseLocale = (preset, installOnly, newLocale) => {
let locale2;
if (!preset) {
return globalLocale;
}
if (typeof preset === "string") {
const presetLower = preset.toLowerCase();
if (loadedLocales[presetLower]) {
locale2 = presetLower;
}
if (newLocale) {
loadedLocales[presetLower] = newLocale;
locale2 = presetLower;
}
const presetSplit = preset.split("-");
if (!locale2 && presetSplit.length > 1) {
return parseLocale(presetSplit[0]);
}
} else {
const { name } = preset;
loadedLocales[name] = preset;
locale2 = name;
}
if (!installOnly && locale2)
globalLocale = locale2;
return locale2 || (!installOnly ? globalLocale : "");
};
var Dayjs = class extends class {
} {
constructor(date, options) {
super();
this._d = new Date();
this._options = options || {};
this._locale = parseLocale(this._options.locale, true);
this.parse(date);
this._init();
}
parse(date) {
this._d = parseDate(date);
}
_init() {
this._year = this._d.getFullYear();
this._month = this._d.getMonth();
this._date = this._d.getDate();
this._hour = this._d.getHours();
this._minute = this._d.getMinutes();
this._second = this._d.getSeconds();
this._millisecond = this._d.getMilliseconds();
this._day = this._d.getDay();
}
valueOf() {
return this._d.getTime();
}
unix() {
return Math.floor(this.valueOf() / 1e3);
}
isValid() {
return !(this._d.toString() === INVALID_DATE_STRING);
}
_startEndOf(unit, isStartOf) {
const factory = ({
year = this._year,
month = this._month,
date = this._date,
hour = this._hour,
minute = this._minute,
second = this._second,
millisecond = this._millisecond
}) => new Dayjs([year, month, date, hour, minute, second, millisecond], this._options);
const numbers = isStartOf ? { month: 0, date: 1, hour: 0, minute: 0, second: 0, millisecond: 0 } : {
month: 11,
date: 31,
hour: 23,
minute: 59,
second: 59,
millisecond: 999
};
const normalizedUnit = normalize(unit);
switch (normalizedUnit) {
case "year":
return factory(numbers);
case "month":
return factory(isStartOf ? pick(numbers, ["date", "hour", "minute", "second", "millisecond"]) : {
month: this._month + 1,
date: 0,
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
case "date":
case "day":
return factory(pick(numbers, ["hour", "minute", "second", "millisecond"]));
case "hour":
return factory(pick(numbers, ["minute", "second", "millisecond"]));
case "minute":
return factory(pick(numbers, ["second", "millisecond"]));
case "second":
return factory(pick(numbers, ["millisecond"]));
case "week": {
const weekStart = this.$locale().weekStart || 0;
const gap = (this._day < weekStart ? this._day + 7 : this._day) - weekStart;
return factory({
date: isStartOf ? this._date - gap : this._date + (6 - gap),
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
}
case "millisecond":
return this.clone();
}
}
$locale() {
return loadedLocales[this._locale];
}
locale(preset, locale2) {
if (!preset)
return this._locale;
const that = this.clone();
const nextLocaleName = parseLocale(preset, true, locale2);
if (nextLocaleName)
that._locale = nextLocaleName;
return that;
}
startOf(unit) {
return this._startEndOf(unit, true);
}
endOf(unit) {
return this._startEndOf(unit, false);
}
isSame(that, unit = "millisecond") {
const other = dayjs(that);
return this.startOf(unit) <= other && other <= this.endOf(unit);
}
isAfter(that, unit = "millisecond") {
return dayjs(that) < this.startOf(unit);
}
isBefore(that, unit = "millisecond") {
return this.endOf(unit) < dayjs(that);
}
clone() {
return new Dayjs(this._d, this._options);
}
get(unit) {
return this[`_${unit}`];
}
set(unit, value) {
const methods = {
year: "setFullYear",
month: "setMonth",
date: "setDate",
hour: "setHours",
minute: "setMinutes",
second: "setSeconds",
millisecond: "setMilliseconds",
day: "setDate"
};
const method = methods[unit];
if (!method)
return this;
const date = cloneDate(this._d);
const val = unit === "day" ? this._date + (value - this._day) : value;
if (unit === "month" || unit === "year") {
date.setDate(1);
date[method](val);
date.setDate(Math.min(this._date, dayjs(date).daysInMonth()));
} else if (method)
date[method](val);
return dayjs(date);
}
daysInMonth() {
return this.endOf("month").date();
}
toDate() {
return cloneDate(this._d);
}
toJSON() {
return this.isValid() ? this.toISOString() : null;
}
toISOString() {
return this._d.toISOString();
}
toString() {
return this._d.toUTCString();
}
utcOffset() {
return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
format(formatStr) {
const locale2 = this.$locale();
if (!this.isValid())
return locale2.invalidDate || INVALID_DATE_STRING;
const str = formatStr || DEFAULT_FORMAT;
const zoneStr = padZoneStr(this.utcOffset());
const { weekdays, months } = locale2;
const getShort = (arr, index, full, length) => (arr == null ? void 0 : arr[index]) || (full == null ? void 0 : full[index].slice(0, Math.max(0, length != null ? length : 0)));
const getHour = (num) => `${this._hour % 12 || 12}`.padStart(num, "0");
const meridiem = locale2.meridiem || ((hour, minute, isLowercase) => {
const m = hour < 12 ? "AM" : "PM";
return isLowercase ? m.toLowerCase() : m;
});
const matches = {
YY: String(this._year).slice(-2),
YYYY: this._year,
M: this._month + 1,
MM: `${this._month + 1}`.padStart(2, "0"),
MMM: getShort(locale2.monthsShort, this._month, months, 3),
MMMM: getShort(months, this._month),
D: this._date,
DD: `${this._date}`.padStart(2, "0"),
d: String(this._day),
dd: getShort(locale2.weekdaysMin, this._day, weekdays, 2),
ddd: getShort(locale2.weekdaysShort, this._day, weekdays, 3),
dddd: weekdays[this._day],
H: String(this._hour),
HH: `${this._hour}`.padStart(2, "0"),
h: getHour(1),
hh: getHour(2),
a: meridiem(this._hour, this._minute, true),
A: meridiem(this._hour, this._minute, false),
m: String(this._minute),
mm: `${this._minute}`.padStart(2, "0"),
s: String(this._second),
ss: `${this._second}`.padStart(2, "0"),
SSS: `${this._millisecond}`.padStart(3, "0"),
Z: zoneStr
};
return str.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match] || zoneStr.replace(":", ""));
}
add(number, unit) {
const normalizedUnit = normalize(unit);
const factory = (n) => this.date(this.date() + Math.round(n * number));
if (normalizedUnit === "month") {
return this.set("month", this._month + number);
} else if (normalizedUnit === "year") {
return this.set("year", this._year + number);
} else if (normalizedUnit === "day") {
return factory(1);
} else if (normalizedUnit === "week") {
return factory(7);
}
const steps = {
minute: MILLISECONDS_A_MINUTE,
hour: MILLISECONDS_A_HOUR,
second: MILLISECONDS_A_SECOND,
millisecond: 1
};
const step = steps[normalizedUnit];
const nextTimeStamp = this.valueOf() + number * step;
return new Dayjs(nextTimeStamp, this._options);
}
subtract(number, unit) {
return this.add(number * -1, unit);
}
};
var getterOrSetter = (unit) => {
function fn(value) {
if (value === void 0) {
return this.get(unit);
} else {
return this.set(unit, value);
}
}
return fn;
};
[
"year",
"month",
"date",
"hour",
"minute",
"second",
"millisecond",
"day"
].forEach((unit) => Dayjs.prototype[unit] = getterOrSetter(unit));
var isDayjs = (value) => value instanceof Dayjs;
var unix = (timestamp) => dayjs(timestamp * 1e3);
var extend = (plugin, option) => {
if (!plugin._i) {
plugin(Dayjs, dayjs, option);
plugin._i = true;
}
return dayjs;
};
var dayjs = (date, format, locale2, strict) => {
if (isDayjs(date))
return date;
if (typeof locale2 === "boolean") {
strict = locale2;
locale2 = void 0;
}
const options = {
format,
locale: locale2,
strict
};
return new Dayjs(date, options);
};
dayjs.isDayjs = isDayjs;
dayjs.unix = unix;
dayjs.extend = extend;
dayjs.locale = parseLocale;
// src/index.ts
var src_default = dayjs;
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v="en",D={};D[v]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return v;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(v=i),i||!r&&v},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var v=this.$locale().weekStart||0,D=(y<v?y+7:y)-v;return $(r?m-D:m+(6-D),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,v=O.m(this,M);return v=(l={},l[c]=v/12,l[f]=v,l[h]=v/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?v:O.a(v)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[v],w.Ls=D,w.p={},w}));

@@ -1,505 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/locale/af.ts
var af_exports = {};
__export(af_exports, {
default: () => af_default
});
module.exports = __toCommonJS(af_exports);
// src/constants.ts
var SECONDS_A_MINUTE = 60;
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
var MILLISECONDS_A_SECOND = 1e3;
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
var INVALID_DATE_STRING = "Invalid Date";
var DEFAULT_FORMAT = "YYYY-MM-DDTHH:mm:ssZ";
var REGEX_PARSE = /^(\d{4})[/-]?(\d{1,2})?[/-]?(\d{0,2})[\sTt]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
// src/utils.ts
var mutable = (val) => val;
var pick = (object, keys) => keys.reduce((obj, key) => {
if (Object.prototype.hasOwnProperty.call(object, key))
obj[key] = object[key];
return obj;
}, {});
var cloneDate = (date) => new Date(date);
var padZoneStr = (utcOffset) => {
const negMinutes = -utcOffset;
const minutes = Math.abs(negMinutes);
const hourOffset = Math.floor(minutes / 60);
const minuteOffset = minutes % 60;
return `${negMinutes <= 0 ? "+" : "-"}${`${hourOffset}`.padStart(2, "0")}:${`${minuteOffset}`.padStart(2, "0")}`;
};
var isEmptyObject = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 0;
// src/units.ts
var units = mutable({
y: "year",
M: "month",
D: "date",
h: "hour",
m: "minute",
s: "second",
ms: "millisecond",
d: "day",
w: "week"
});
var unitsShort = Object.keys(units);
var unitsLong = Object.values(units);
var isShortUnit = (unit) => unitsShort.includes(unit);
var normalize = (unit) => {
var _a, _b;
if (isShortUnit(unit)) {
return units[unit];
}
const normalizedUnit = (_b = (_a = unit == null ? void 0 : unit.toLowerCase()) == null ? void 0 : _a.replace(/s$/, "")) != null ? _b : "";
return normalizedUnit;
};
// src/locale/en.ts
var locale = {
name: "en",
weekdays: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
months: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var en_default = locale;
// src/dayjs.ts
var globalLocale = "en";
var loadedLocales = {};
loadedLocales[globalLocale] = en_default;
var parseDate = (date) => {
if (date instanceof Date)
return cloneDate(date);
else if (date === null)
return new Date(Number.NaN);
else if (date === void 0)
return new Date();
else if (isEmptyObject(date))
return new Date();
else if (Array.isArray(date))
return new Date(date[0], date[1], date[2], date[3], date[4], date[5], date[6]);
else if (typeof date === "string" && !/z$/i.test(date)) {
const d = date.match(REGEX_PARSE);
if (d) {
const m = +d[2] - 1 || 0;
const ms = +(d[7] || "0").slice(0, 3);
return new Date(+d[1], m, +(d[3] || 1), +(d[4] || 0), +(d[5] || 0), +(d[6] || 0), ms);
}
}
return new Date(date);
};
var parseLocale = (preset, installOnly, newLocale) => {
let locale3;
if (!preset) {
return globalLocale;
}
if (typeof preset === "string") {
const presetLower = preset.toLowerCase();
if (loadedLocales[presetLower]) {
locale3 = presetLower;
}
if (newLocale) {
loadedLocales[presetLower] = newLocale;
locale3 = presetLower;
}
const presetSplit = preset.split("-");
if (!locale3 && presetSplit.length > 1) {
return parseLocale(presetSplit[0]);
}
} else {
const { name } = preset;
loadedLocales[name] = preset;
locale3 = name;
}
if (!installOnly && locale3)
globalLocale = locale3;
return locale3 || (!installOnly ? globalLocale : "");
};
var Dayjs = class extends class {
} {
constructor(date, options) {
super();
this._d = new Date();
this._options = options || {};
this._locale = parseLocale(this._options.locale, true);
this.parse(date);
this._init();
}
parse(date) {
this._d = parseDate(date);
}
_init() {
this._year = this._d.getFullYear();
this._month = this._d.getMonth();
this._date = this._d.getDate();
this._hour = this._d.getHours();
this._minute = this._d.getMinutes();
this._second = this._d.getSeconds();
this._millisecond = this._d.getMilliseconds();
this._day = this._d.getDay();
}
valueOf() {
return this._d.getTime();
}
unix() {
return Math.floor(this.valueOf() / 1e3);
}
isValid() {
return !(this._d.toString() === INVALID_DATE_STRING);
}
_startEndOf(unit, isStartOf) {
const factory = ({
year = this._year,
month = this._month,
date = this._date,
hour = this._hour,
minute = this._minute,
second = this._second,
millisecond = this._millisecond
}) => new Dayjs([year, month, date, hour, minute, second, millisecond], this._options);
const numbers = isStartOf ? { month: 0, date: 1, hour: 0, minute: 0, second: 0, millisecond: 0 } : {
month: 11,
date: 31,
hour: 23,
minute: 59,
second: 59,
millisecond: 999
};
const normalizedUnit = normalize(unit);
switch (normalizedUnit) {
case "year":
return factory(numbers);
case "month":
return factory(isStartOf ? pick(numbers, ["date", "hour", "minute", "second", "millisecond"]) : {
month: this._month + 1,
date: 0,
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
case "date":
case "day":
return factory(pick(numbers, ["hour", "minute", "second", "millisecond"]));
case "hour":
return factory(pick(numbers, ["minute", "second", "millisecond"]));
case "minute":
return factory(pick(numbers, ["second", "millisecond"]));
case "second":
return factory(pick(numbers, ["millisecond"]));
case "week": {
const weekStart = this.$locale().weekStart || 0;
const gap = (this._day < weekStart ? this._day + 7 : this._day) - weekStart;
return factory({
date: isStartOf ? this._date - gap : this._date + (6 - gap),
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
}
case "millisecond":
return this.clone();
}
}
$locale() {
return loadedLocales[this._locale];
}
locale(preset, locale3) {
if (!preset)
return this._locale;
const that = this.clone();
const nextLocaleName = parseLocale(preset, true, locale3);
if (nextLocaleName)
that._locale = nextLocaleName;
return that;
}
startOf(unit) {
return this._startEndOf(unit, true);
}
endOf(unit) {
return this._startEndOf(unit, false);
}
isSame(that, unit = "millisecond") {
const other = dayjs(that);
return this.startOf(unit) <= other && other <= this.endOf(unit);
}
isAfter(that, unit = "millisecond") {
return dayjs(that) < this.startOf(unit);
}
isBefore(that, unit = "millisecond") {
return this.endOf(unit) < dayjs(that);
}
clone() {
return new Dayjs(this._d, this._options);
}
get(unit) {
return this[`_${unit}`];
}
set(unit, value) {
const methods = {
year: "setFullYear",
month: "setMonth",
date: "setDate",
hour: "setHours",
minute: "setMinutes",
second: "setSeconds",
millisecond: "setMilliseconds",
day: "setDate"
};
const method = methods[unit];
if (!method)
return this;
const date = cloneDate(this._d);
const val = unit === "day" ? this._date + (value - this._day) : value;
if (unit === "month" || unit === "year") {
date.setDate(1);
date[method](val);
date.setDate(Math.min(this._date, dayjs(date).daysInMonth()));
} else if (method)
date[method](val);
return dayjs(date);
}
daysInMonth() {
return this.endOf("month").date();
}
toDate() {
return cloneDate(this._d);
}
toJSON() {
return this.isValid() ? this.toISOString() : null;
}
toISOString() {
return this._d.toISOString();
}
toString() {
return this._d.toUTCString();
}
utcOffset() {
return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
format(formatStr) {
const locale3 = this.$locale();
if (!this.isValid())
return locale3.invalidDate || INVALID_DATE_STRING;
const str = formatStr || DEFAULT_FORMAT;
const zoneStr = padZoneStr(this.utcOffset());
const { weekdays, months } = locale3;
const getShort = (arr, index, full, length) => (arr == null ? void 0 : arr[index]) || (full == null ? void 0 : full[index].slice(0, Math.max(0, length != null ? length : 0)));
const getHour = (num) => `${this._hour % 12 || 12}`.padStart(num, "0");
const meridiem = locale3.meridiem || ((hour, minute, isLowercase) => {
const m = hour < 12 ? "AM" : "PM";
return isLowercase ? m.toLowerCase() : m;
});
const matches = {
YY: String(this._year).slice(-2),
YYYY: this._year,
M: this._month + 1,
MM: `${this._month + 1}`.padStart(2, "0"),
MMM: getShort(locale3.monthsShort, this._month, months, 3),
MMMM: getShort(months, this._month),
D: this._date,
DD: `${this._date}`.padStart(2, "0"),
d: String(this._day),
dd: getShort(locale3.weekdaysMin, this._day, weekdays, 2),
ddd: getShort(locale3.weekdaysShort, this._day, weekdays, 3),
dddd: weekdays[this._day],
H: String(this._hour),
HH: `${this._hour}`.padStart(2, "0"),
h: getHour(1),
hh: getHour(2),
a: meridiem(this._hour, this._minute, true),
A: meridiem(this._hour, this._minute, false),
m: String(this._minute),
mm: `${this._minute}`.padStart(2, "0"),
s: String(this._second),
ss: `${this._second}`.padStart(2, "0"),
SSS: `${this._millisecond}`.padStart(3, "0"),
Z: zoneStr
};
return str.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match] || zoneStr.replace(":", ""));
}
add(number, unit) {
const normalizedUnit = normalize(unit);
const factory = (n) => this.date(this.date() + Math.round(n * number));
if (normalizedUnit === "month") {
return this.set("month", this._month + number);
} else if (normalizedUnit === "year") {
return this.set("year", this._year + number);
} else if (normalizedUnit === "day") {
return factory(1);
} else if (normalizedUnit === "week") {
return factory(7);
}
const steps = {
minute: MILLISECONDS_A_MINUTE,
hour: MILLISECONDS_A_HOUR,
second: MILLISECONDS_A_SECOND,
millisecond: 1
};
const step = steps[normalizedUnit];
const nextTimeStamp = this.valueOf() + number * step;
return new Dayjs(nextTimeStamp, this._options);
}
subtract(number, unit) {
return this.add(number * -1, unit);
}
};
var getterOrSetter = (unit) => {
function fn(value) {
if (value === void 0) {
return this.get(unit);
} else {
return this.set(unit, value);
}
}
return fn;
};
[
"year",
"month",
"date",
"hour",
"minute",
"second",
"millisecond",
"day"
].forEach((unit) => Dayjs.prototype[unit] = getterOrSetter(unit));
var isDayjs = (value) => value instanceof Dayjs;
var unix = (timestamp) => dayjs(timestamp * 1e3);
var extend = (plugin, option) => {
if (!plugin._i) {
plugin(Dayjs, dayjs, option);
plugin._i = true;
}
return dayjs;
};
var dayjs = (date, format, locale3, strict) => {
if (isDayjs(date))
return date;
if (typeof locale3 === "boolean") {
strict = locale3;
locale3 = void 0;
}
const options = {
format,
locale: locale3,
strict
};
return new Dayjs(date, options);
};
dayjs.isDayjs = isDayjs;
dayjs.unix = unix;
dayjs.extend = extend;
dayjs.locale = parseLocale;
var dayjs_default = dayjs;
// src/locale/af.ts
var locale2 = {
name: "af",
weekdays: [
"Sondag",
"Maandag",
"Dinsdag",
"Woensdag",
"Donderdag",
"Vrydag",
"Saterdag"
],
months: [
"Januarie",
"Februarie",
"Maart",
"April",
"Mei",
"Junie",
"Julie",
"Augustus",
"September",
"Oktober",
"November",
"Desember"
],
weekStart: 1,
weekdaysShort: ["Son", "Maa", "Din", "Woe", "Don", "Vry", "Sat"],
monthsShort: [
"Jan",
"Feb",
"Mrt",
"Apr",
"Mei",
"Jun",
"Jul",
"Aug",
"Sep",
"Okt",
"Nov",
"Des"
],
weekdaysMin: ["So", "Ma", "Di", "Wo", "Do", "Vr", "Sa"],
ordinal: (n) => n,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD/MM/YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd, D MMMM YYYY HH:mm"
},
relativeTime: {
future: "oor %s",
past: "%s gelede",
s: "'n paar sekondes",
m: "'n minuut",
mm: "%d minute",
h: "'n uur",
hh: "%d ure",
d: "'n dag",
dd: "%d dae",
M: "'n maand",
MM: "%d maande",
y: "'n jaar",
yy: "%d jaar"
}
};
dayjs_default.locale(locale2, true);
var af_default = locale2;
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],a):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_af=a(e.dayjs)}(this,(function(e){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=a(e),t={name:"af",weekdays:"Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag".split("_"),months:"Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember".split("_"),weekStart:1,weekdaysShort:"Son_Maa_Din_Woe_Don_Vry_Sat".split("_"),monthsShort:"Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des".split("_"),weekdaysMin:"So_Ma_Di_Wo_Do_Vr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"oor %s",past:"%s gelede",s:"'n paar sekondes",m:"'n minuut",mm:"%d minute",h:"'n uur",hh:"%d ure",d:"'n dag",dd:"%d dae",M:"'n maand",MM:"%d maande",y:"'n jaar",yy:"%d jaar"}};return n.default.locale(t,null,!0),t}));

@@ -1,51 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/locale/en.ts
var en_exports = {};
__export(en_exports, {
default: () => en_default
});
module.exports = __toCommonJS(en_exports);
var locale = {
name: "en",
weekdays: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
months: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var en_default = locale;
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_en=n()}(this,(function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}}));

@@ -1,20 +0,11 @@

declare type RepeatDay<T = string> = [T, T, T, T, T, T, T];
declare type RepeatMonth<T = string> = [T, T, T, T, T, T, T, T, T, T, T, T];
declare type Format = 'LT' | 'LTS' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'l' | 'll' | 'lll' | 'llll';
declare type Relative = 'future' | 'past' | 's' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'M' | 'MM' | 'y' | 'yy';
export interface Locale {
name: string;
weekdays: RepeatDay;
weekdaysShort?: RepeatDay;
weekdaysMin?: RepeatDay;
months: RepeatMonth;
monthsShort?: RepeatMonth;
ordinal?: (number: string, period?: 'W') => string;
weekStart?: number;
yearStart?: number;
formats?: Partial<Record<Format, string>>;
relativeTime?: Record<Relative, string>;
meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
invalidDate?: string;
/// <reference path="./types.d.ts" />
declare module 'dayjs/locale/*' {
namespace locale {
interface Locale extends ILocale {}
}
const locale: locale.Locale
export = locale
}
export {};

@@ -1,92 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/locale/rn.ts
var rn_exports = {};
__export(rn_exports, {
default: () => rn_default
});
module.exports = __toCommonJS(rn_exports);
var locale = {
name: "rn",
weekdays: [
"Ku wa Mungu",
"Ku wa Mbere",
"Ku wa Kabiri",
"Ku wa Gatatu",
"Ku wa Kane",
"Ku wa Gatanu",
"Ku wa Gatandatu"
],
weekdaysShort: ["Kngu", "Kmbr", "Kbri", "Ktat", "Kkan", "Ktan", "Kdat"],
weekdaysMin: ["K7", "K1", "K2", "K3", "K4", "K5", "K6"],
months: [
"Nzero",
"Ruhuhuma",
"Ntwarante",
"Ndamukiza",
"Rusama",
"Ruhenshi",
"Mukakaro",
"Myandagaro",
"Nyakanga",
"Gitugutu",
"Munyonyo",
"Kigarama"
],
monthsShort: [
"Nzer",
"Ruhuh",
"Ntwar",
"Ndam",
"Rus",
"Ruhen",
"Muk",
"Myand",
"Nyak",
"Git",
"Muny",
"Kig"
],
weekStart: 1,
ordinal: (n) => n,
relativeTime: {
future: "mu %s",
past: "%s",
s: "amasegonda",
m: "Umunota",
mm: "%d iminota",
h: "isaha",
hh: "%d amasaha",
d: "Umunsi",
dd: "%d iminsi",
M: "ukwezi",
MM: "%d amezi",
y: "umwaka",
yy: "%d imyaka"
},
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD/MM/YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd, D MMMM YYYY HH:mm"
}
};
var rn_default = locale;
!function(a,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],e):(a="undefined"!=typeof globalThis?globalThis:a||self).dayjs_locale_rn=e(a.dayjs)}(this,(function(a){"use strict";function e(a){return a&&"object"==typeof a&&"default"in a?a:{default:a}}var t=e(a),u={name:"rn",weekdays:"Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu".split("_"),weekdaysShort:"Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat".split("_"),weekdaysMin:"K7_K1_K2_K3_K4_K5_K6".split("_"),months:"Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama".split("_"),monthsShort:"Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig".split("_"),weekStart:1,ordinal:function(a){return a},relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(u,null,!0),u}));

@@ -1,531 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/locale/zh-cn.ts
var zh_cn_exports = {};
__export(zh_cn_exports, {
default: () => zh_cn_default
});
module.exports = __toCommonJS(zh_cn_exports);
// src/constants.ts
var SECONDS_A_MINUTE = 60;
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
var MILLISECONDS_A_SECOND = 1e3;
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
var INVALID_DATE_STRING = "Invalid Date";
var DEFAULT_FORMAT = "YYYY-MM-DDTHH:mm:ssZ";
var REGEX_PARSE = /^(\d{4})[/-]?(\d{1,2})?[/-]?(\d{0,2})[\sTt]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
// src/utils.ts
var mutable = (val) => val;
var pick = (object, keys) => keys.reduce((obj, key) => {
if (Object.prototype.hasOwnProperty.call(object, key))
obj[key] = object[key];
return obj;
}, {});
var cloneDate = (date) => new Date(date);
var padZoneStr = (utcOffset) => {
const negMinutes = -utcOffset;
const minutes = Math.abs(negMinutes);
const hourOffset = Math.floor(minutes / 60);
const minuteOffset = minutes % 60;
return `${negMinutes <= 0 ? "+" : "-"}${`${hourOffset}`.padStart(2, "0")}:${`${minuteOffset}`.padStart(2, "0")}`;
};
var isEmptyObject = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 0;
// src/units.ts
var units = mutable({
y: "year",
M: "month",
D: "date",
h: "hour",
m: "minute",
s: "second",
ms: "millisecond",
d: "day",
w: "week"
});
var unitsShort = Object.keys(units);
var unitsLong = Object.values(units);
var isShortUnit = (unit) => unitsShort.includes(unit);
var normalize = (unit) => {
var _a, _b;
if (isShortUnit(unit)) {
return units[unit];
}
const normalizedUnit = (_b = (_a = unit == null ? void 0 : unit.toLowerCase()) == null ? void 0 : _a.replace(/s$/, "")) != null ? _b : "";
return normalizedUnit;
};
// src/locale/en.ts
var locale = {
name: "en",
weekdays: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
months: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var en_default = locale;
// src/dayjs.ts
var globalLocale = "en";
var loadedLocales = {};
loadedLocales[globalLocale] = en_default;
var parseDate = (date) => {
if (date instanceof Date)
return cloneDate(date);
else if (date === null)
return new Date(Number.NaN);
else if (date === void 0)
return new Date();
else if (isEmptyObject(date))
return new Date();
else if (Array.isArray(date))
return new Date(date[0], date[1], date[2], date[3], date[4], date[5], date[6]);
else if (typeof date === "string" && !/z$/i.test(date)) {
const d = date.match(REGEX_PARSE);
if (d) {
const m = +d[2] - 1 || 0;
const ms = +(d[7] || "0").slice(0, 3);
return new Date(+d[1], m, +(d[3] || 1), +(d[4] || 0), +(d[5] || 0), +(d[6] || 0), ms);
}
}
return new Date(date);
};
var parseLocale = (preset, installOnly, newLocale) => {
let locale3;
if (!preset) {
return globalLocale;
}
if (typeof preset === "string") {
const presetLower = preset.toLowerCase();
if (loadedLocales[presetLower]) {
locale3 = presetLower;
}
if (newLocale) {
loadedLocales[presetLower] = newLocale;
locale3 = presetLower;
}
const presetSplit = preset.split("-");
if (!locale3 && presetSplit.length > 1) {
return parseLocale(presetSplit[0]);
}
} else {
const { name } = preset;
loadedLocales[name] = preset;
locale3 = name;
}
if (!installOnly && locale3)
globalLocale = locale3;
return locale3 || (!installOnly ? globalLocale : "");
};
var Dayjs = class extends class {
} {
constructor(date, options) {
super();
this._d = new Date();
this._options = options || {};
this._locale = parseLocale(this._options.locale, true);
this.parse(date);
this._init();
}
parse(date) {
this._d = parseDate(date);
}
_init() {
this._year = this._d.getFullYear();
this._month = this._d.getMonth();
this._date = this._d.getDate();
this._hour = this._d.getHours();
this._minute = this._d.getMinutes();
this._second = this._d.getSeconds();
this._millisecond = this._d.getMilliseconds();
this._day = this._d.getDay();
}
valueOf() {
return this._d.getTime();
}
unix() {
return Math.floor(this.valueOf() / 1e3);
}
isValid() {
return !(this._d.toString() === INVALID_DATE_STRING);
}
_startEndOf(unit, isStartOf) {
const factory = ({
year = this._year,
month = this._month,
date = this._date,
hour = this._hour,
minute = this._minute,
second = this._second,
millisecond = this._millisecond
}) => new Dayjs([year, month, date, hour, minute, second, millisecond], this._options);
const numbers = isStartOf ? { month: 0, date: 1, hour: 0, minute: 0, second: 0, millisecond: 0 } : {
month: 11,
date: 31,
hour: 23,
minute: 59,
second: 59,
millisecond: 999
};
const normalizedUnit = normalize(unit);
switch (normalizedUnit) {
case "year":
return factory(numbers);
case "month":
return factory(isStartOf ? pick(numbers, ["date", "hour", "minute", "second", "millisecond"]) : {
month: this._month + 1,
date: 0,
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
case "date":
case "day":
return factory(pick(numbers, ["hour", "minute", "second", "millisecond"]));
case "hour":
return factory(pick(numbers, ["minute", "second", "millisecond"]));
case "minute":
return factory(pick(numbers, ["second", "millisecond"]));
case "second":
return factory(pick(numbers, ["millisecond"]));
case "week": {
const weekStart = this.$locale().weekStart || 0;
const gap = (this._day < weekStart ? this._day + 7 : this._day) - weekStart;
return factory({
date: isStartOf ? this._date - gap : this._date + (6 - gap),
...pick(numbers, ["hour", "minute", "second", "millisecond"])
});
}
case "millisecond":
return this.clone();
}
}
$locale() {
return loadedLocales[this._locale];
}
locale(preset, locale3) {
if (!preset)
return this._locale;
const that = this.clone();
const nextLocaleName = parseLocale(preset, true, locale3);
if (nextLocaleName)
that._locale = nextLocaleName;
return that;
}
startOf(unit) {
return this._startEndOf(unit, true);
}
endOf(unit) {
return this._startEndOf(unit, false);
}
isSame(that, unit = "millisecond") {
const other = dayjs(that);
return this.startOf(unit) <= other && other <= this.endOf(unit);
}
isAfter(that, unit = "millisecond") {
return dayjs(that) < this.startOf(unit);
}
isBefore(that, unit = "millisecond") {
return this.endOf(unit) < dayjs(that);
}
clone() {
return new Dayjs(this._d, this._options);
}
get(unit) {
return this[`_${unit}`];
}
set(unit, value) {
const methods = {
year: "setFullYear",
month: "setMonth",
date: "setDate",
hour: "setHours",
minute: "setMinutes",
second: "setSeconds",
millisecond: "setMilliseconds",
day: "setDate"
};
const method = methods[unit];
if (!method)
return this;
const date = cloneDate(this._d);
const val = unit === "day" ? this._date + (value - this._day) : value;
if (unit === "month" || unit === "year") {
date.setDate(1);
date[method](val);
date.setDate(Math.min(this._date, dayjs(date).daysInMonth()));
} else if (method)
date[method](val);
return dayjs(date);
}
daysInMonth() {
return this.endOf("month").date();
}
toDate() {
return cloneDate(this._d);
}
toJSON() {
return this.isValid() ? this.toISOString() : null;
}
toISOString() {
return this._d.toISOString();
}
toString() {
return this._d.toUTCString();
}
utcOffset() {
return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
format(formatStr) {
const locale3 = this.$locale();
if (!this.isValid())
return locale3.invalidDate || INVALID_DATE_STRING;
const str = formatStr || DEFAULT_FORMAT;
const zoneStr = padZoneStr(this.utcOffset());
const { weekdays, months } = locale3;
const getShort = (arr, index, full, length) => (arr == null ? void 0 : arr[index]) || (full == null ? void 0 : full[index].slice(0, Math.max(0, length != null ? length : 0)));
const getHour = (num) => `${this._hour % 12 || 12}`.padStart(num, "0");
const meridiem = locale3.meridiem || ((hour, minute, isLowercase) => {
const m = hour < 12 ? "AM" : "PM";
return isLowercase ? m.toLowerCase() : m;
});
const matches = {
YY: String(this._year).slice(-2),
YYYY: this._year,
M: this._month + 1,
MM: `${this._month + 1}`.padStart(2, "0"),
MMM: getShort(locale3.monthsShort, this._month, months, 3),
MMMM: getShort(months, this._month),
D: this._date,
DD: `${this._date}`.padStart(2, "0"),
d: String(this._day),
dd: getShort(locale3.weekdaysMin, this._day, weekdays, 2),
ddd: getShort(locale3.weekdaysShort, this._day, weekdays, 3),
dddd: weekdays[this._day],
H: String(this._hour),
HH: `${this._hour}`.padStart(2, "0"),
h: getHour(1),
hh: getHour(2),
a: meridiem(this._hour, this._minute, true),
A: meridiem(this._hour, this._minute, false),
m: String(this._minute),
mm: `${this._minute}`.padStart(2, "0"),
s: String(this._second),
ss: `${this._second}`.padStart(2, "0"),
SSS: `${this._millisecond}`.padStart(3, "0"),
Z: zoneStr
};
return str.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match] || zoneStr.replace(":", ""));
}
add(number, unit) {
const normalizedUnit = normalize(unit);
const factory = (n) => this.date(this.date() + Math.round(n * number));
if (normalizedUnit === "month") {
return this.set("month", this._month + number);
} else if (normalizedUnit === "year") {
return this.set("year", this._year + number);
} else if (normalizedUnit === "day") {
return factory(1);
} else if (normalizedUnit === "week") {
return factory(7);
}
const steps = {
minute: MILLISECONDS_A_MINUTE,
hour: MILLISECONDS_A_HOUR,
second: MILLISECONDS_A_SECOND,
millisecond: 1
};
const step = steps[normalizedUnit];
const nextTimeStamp = this.valueOf() + number * step;
return new Dayjs(nextTimeStamp, this._options);
}
subtract(number, unit) {
return this.add(number * -1, unit);
}
};
var getterOrSetter = (unit) => {
function fn(value) {
if (value === void 0) {
return this.get(unit);
} else {
return this.set(unit, value);
}
}
return fn;
};
[
"year",
"month",
"date",
"hour",
"minute",
"second",
"millisecond",
"day"
].forEach((unit) => Dayjs.prototype[unit] = getterOrSetter(unit));
var isDayjs = (value) => value instanceof Dayjs;
var unix = (timestamp) => dayjs(timestamp * 1e3);
var extend = (plugin, option) => {
if (!plugin._i) {
plugin(Dayjs, dayjs, option);
plugin._i = true;
}
return dayjs;
};
var dayjs = (date, format, locale3, strict) => {
if (isDayjs(date))
return date;
if (typeof locale3 === "boolean") {
strict = locale3;
locale3 = void 0;
}
const options = {
format,
locale: locale3,
strict
};
return new Dayjs(date, options);
};
dayjs.isDayjs = isDayjs;
dayjs.unix = unix;
dayjs.extend = extend;
dayjs.locale = parseLocale;
// src/locale/zh-cn.ts
var locale2 = {
name: "zh-cn",
weekdays: [
"\u661F\u671F\u65E5",
"\u661F\u671F\u4E00",
"\u661F\u671F\u4E8C",
"\u661F\u671F\u4E09",
"\u661F\u671F\u56DB",
"\u661F\u671F\u4E94",
"\u661F\u671F\u516D"
],
weekdaysShort: ["\u5468\u65E5", "\u5468\u4E00", "\u5468\u4E8C", "\u5468\u4E09", "\u5468\u56DB", "\u5468\u4E94", "\u5468\u516D"],
weekdaysMin: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
months: [
"\u4E00\u6708",
"\u4E8C\u6708",
"\u4E09\u6708",
"\u56DB\u6708",
"\u4E94\u6708",
"\u516D\u6708",
"\u4E03\u6708",
"\u516B\u6708",
"\u4E5D\u6708",
"\u5341\u6708",
"\u5341\u4E00\u6708",
"\u5341\u4E8C\u6708"
],
monthsShort: [
"1\u6708",
"2\u6708",
"3\u6708",
"4\u6708",
"5\u6708",
"6\u6708",
"7\u6708",
"8\u6708",
"9\u6708",
"10\u6708",
"11\u6708",
"12\u6708"
],
ordinal: (number, period) => {
switch (period) {
case "W":
return `${number}\u5468`;
default:
return `${number}\u65E5`;
}
},
weekStart: 1,
yearStart: 4,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "YYYY/MM/DD",
LL: "YYYY\u5E74M\u6708D\u65E5",
LLL: "YYYY\u5E74M\u6708D\u65E5Ah\u70B9mm\u5206",
LLLL: "YYYY\u5E74M\u6708D\u65E5ddddAh\u70B9mm\u5206",
l: "YYYY/M/D",
ll: "YYYY\u5E74M\u6708D\u65E5",
lll: "YYYY\u5E74M\u6708D\u65E5 HH:mm",
llll: "YYYY\u5E74M\u6708D\u65E5dddd HH:mm"
},
relativeTime: {
future: "%s\u5185",
past: "%s\u524D",
s: "\u51E0\u79D2",
m: "1 \u5206\u949F",
mm: "%d \u5206\u949F",
h: "1 \u5C0F\u65F6",
hh: "%d \u5C0F\u65F6",
d: "1 \u5929",
dd: "%d \u5929",
M: "1 \u4E2A\u6708",
MM: "%d \u4E2A\u6708",
y: "1 \u5E74",
yy: "%d \u5E74"
},
meridiem: (hour, minute) => {
const hm = hour * 100 + minute;
if (hm < 600) {
return "\u51CC\u6668";
} else if (hm < 900) {
return "\u65E9\u4E0A";
} else if (hm < 1100) {
return "\u4E0A\u5348";
} else if (hm < 1300) {
return "\u4E2D\u5348";
} else if (hm < 1800) {
return "\u4E0B\u5348";
}
return "\u665A\u4E0A";
}
};
dayjs.locale(locale2, true);
var zh_cn_default = locale2;
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_zh_cn=_(e.dayjs)}(this,(function(e){"use strict";function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=_(e),d={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,_){return"W"===_?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,_){var t=100*e+_;return t<600?"凌晨":t<900?"早上":t<1100?"上午":t<1300?"中午":t<1800?"下午":"晚上"}};return t.default.locale(d,null,!0),d}));

@@ -1,8 +0,10 @@

import type { Plugin } from '..';
declare module '../types' {
interface Extend {
isToday: () => boolean;
}
import { PluginFunc } from 'dayjs'
declare const plugin: PluginFunc
export = plugin
declare module 'dayjs' {
interface Dayjs {
isToday(): boolean
}
}
declare const plugin: Plugin;
export default plugin;

@@ -1,33 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/plugin/isToday.ts
var isToday_exports = {};
__export(isToday_exports, {
default: () => isToday_default
});
module.exports = __toCommonJS(isToday_exports);
var plugin = (cls, fn) => {
function isToday() {
const comparisonTemplate = "YYYY-MM-DD";
const now = fn();
return this.format(comparisonTemplate) === now.format(comparisonTemplate);
}
cls.prototype.isToday = isToday;
};
var isToday_default = plugin;
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_plugin_isToday=o()}(this,(function(){"use strict";return function(e,o,t){o.prototype.isToday=function(){var e="YYYY-MM-DD",o=t();return this.format(e)===o.format(e)}}}));

@@ -1,9 +0,10 @@

import type { Dayjs, Plugin } from '..';
declare module '../types' {
interface Extend {
toArray: typeof toArray;
}
import { PluginFunc } from 'dayjs'
declare const plugin: PluginFunc
export = plugin
declare module 'dayjs' {
interface Dayjs {
toArray(): number[]
}
}
declare function toArray(this: Dayjs): [number, number, number, number, number, number, number];
declare const plugin: Plugin;
export default plugin;

@@ -1,37 +0,1 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/plugin/toArray.ts
var toArray_exports = {};
__export(toArray_exports, {
default: () => toArray_default
});
module.exports = __toCommonJS(toArray_exports);
function toArray() {
return [
this.year(),
this.month(),
this.date(),
this.hour(),
this.minute(),
this.second(),
this.millisecond()
];
}
var plugin = (cls) => cls.prototype.toArray = toArray;
var toArray_default = plugin;
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs_plugin_toArray=e()}(this,(function(){"use strict";return function(t,e){e.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}}));
{
"name": "dayjs",
"version": "2.0.0-alpha.2",
"description": "2KB immutable date time library alternative to Moment.js with the same modern API.",
"keywords": [
"dayjs",
"date"
"version": "2.0.0-alpha.3",
"description": "2KB immutable date time library alternative to Moment.js with the same modern API ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && TZ=America/Whitehorse npm run test-tz && npm run test-tz && jest",
"test-tz": "date && jest test/timezone.test --coverage=false",
"lint": "./node_modules/.bin/eslint src/* test/* build/*",
"prettier": "prettier --write \"docs/**/*.md\"",
"build": "cross-env BABEL_ENV=build node build/index.js && npm run build:esm && npm run size",
"build:esm": "node build/esm.mjs",
"sauce": "npx karma start karma.sauce.conf.js",
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2 && npm run sauce -- 3",
"size": "size-limit && gzip-size dist/index.js"
},
"files": [
"dist"
],
"homepage": "https://day.js.org",
"license": "MIT",
"author": "iamkun",
"contributors": [
"pre-commit": [
"lint"
],
"size-limit": [
{
"name": "三咲智子",
"email": "sxzz@sxzz.moe",
"url": "https://github.com/sxzz"
"limit": "2.99 KB",
"path": "./dist/index.js"
}
],
"funding": "https://opencollective.com/dayjs",
"files": [
"dist"
"jest": {
"roots": [
"test"
],
"testRegex": "test/(.*?/)?.*test.js$",
"testURL": "http://localhost",
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*"
]
},
"release": {
"prepare": [
{
"path": "@semantic-release/changelog"
},
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
]
}
]
]
},
"keywords": [
"dayjs",
"date",
"time",
"immutable",
"moment"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./*": {
"require": "./dist/*.js",
"import": "./dist/*.mjs"
}
},
"unpkg": "./dist/index.iife.min.js",
"jsdelivr": "./dist/index.iife.min.js",
"author": "iamkun",
"license": "MIT",
"homepage": "https://day.js.org",
"repository": {

@@ -41,48 +71,36 @@ "type": "git",

},
"scripts": {
"clean": "rimraf dist",
"build": "esno build/index.ts",
"size": "pnpm run build && size-limit",
"lint": "eslint . --ext .js,.ts,.json",
"lint:fix": "pnpm run lint -- --fix",
"format": "prettier . --write",
"test": "vitest"
},
"devDependencies": {
"@size-limit/file": "^7.0.8",
"@sxzz/eslint-config-prettier": "^2.1.1",
"@sxzz/eslint-config-ts": "^2.1.1",
"@types/node": "*",
"c8": "^7.11.2",
"esbuild": "^0.14.36",
"eslint": "^8.13.0",
"eslint-define-config": "^1.3.0",
"esno": "^0.14.1",
"fast-glob": "^3.2.11",
"moment": "^2.29.3",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"size-limit": "^7.0.8",
"ts-morph": "^14.0.0",
"typescript": "^4.6.3",
"utility-types": "^3.10.0",
"vitest": "^0.9.3"
},
"engines": {
"node": ">=14.17.0"
},
"size-limit": [
{
"limit": "2.99 KB",
"path": "dist/index.min.js"
},
{
"limit": "2.99 KB",
"path": "dist/index.min.mjs"
},
{
"limit": "2.99 KB",
"path": "dist/index.iife.min.js"
}
]
"@babel/cli": "^7.0.0-beta.44",
"@babel/core": "^7.0.0-beta.44",
"@babel/node": "^7.0.0-beta.44",
"@babel/preset-env": "^7.0.0-beta.44",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-node-resolve": "^14.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.3",
"babel-plugin-external-helpers": "^6.22.0",
"cross-env": "^5.1.6",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-jest": "^21.15.0",
"fast-glob": "^3.2.12",
"gzip-size-cli": "^2.1.0",
"jasmine-core": "^2.99.1",
"jest": "^22.4.3",
"karma": "^2.0.2",
"karma-jasmine": "^1.1.2",
"karma-sauce-launcher": "^1.1.0",
"mockdate": "^2.0.2",
"moment": "2.29.2",
"moment-timezone": "0.5.31",
"ncp": "^2.0.0",
"pre-commit": "^1.2.2",
"prettier": "^1.16.1",
"rollup": "^2.79.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^7.0.2",
"size-limit": "^0.18.0",
"typescript": "^2.8.3"
}
}

@@ -1,25 +0,10 @@

## TODO
English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md) | [සිංහල](./docs/si/README-si.md)
- [x] locale
- migrate plugins
- docs
---
English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md)
<p align="center">
<a href="https://day.js.org/" target="_blank" rel="noopener noreferrer">
<img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"
>
</a>
</p>
<p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Fast <b>2kB</b> alternative to Moment.js with the same modern API</p>
<p align="center">
<a href="https://unpkg.com/dayjs/dayjs.min.js"><img
src="https://img.badgesize.io/https://unpkg.com/dayjs/dayjs.min.js?compression=gzip&style=flat-square"
<a href="https://unpkg.com/dayjs"><img
src="https://img.badgesize.io/dayjs?compression=gzip&style=flat-square"
alt="Gzip Size"></a>

@@ -35,2 +20,5 @@ <a href="https://www.npmjs.com/package/dayjs"><img src="https://img.shields.io/npm/v/dayjs.svg?style=flat-square&colorB=51C838"

<br>
<a href="https://saucelabs.com/u/dayjs">
<img width="750" src="https://user-images.githubusercontent.com/17680888/40040137-8e3323a6-584b-11e8-9dba-bbe577ee8a7b.png" alt="Sauce Test Status">
</a>
</p>

@@ -40,16 +28,12 @@

```ts
dayjs()
.startOf('month')
.add(1, 'day')
.set('year', 2018)
.format('YYYY-MM-DD HH:mm:ss')
```js
dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
```
- 🕒 Familiar Moment.js API & patterns
- 💪 Immutable
- 🔥 Chainable
- 🌐 I18n support
- 📦 2kb mini library
- 👫 All browsers supported
* 🕒 Familiar Moment.js API & patterns
* 💪 Immutable
* 🔥 Chainable
* 🌐 I18n support
* 📦 2kb mini library
* 👫 All browsers supported

@@ -76,3 +60,3 @@ ---

```ts
```javascript
dayjs('2018-08-08') // parse

@@ -97,3 +81,3 @@

```ts
```javascript
import 'dayjs/locale/es' // load on demand

@@ -105,3 +89,2 @@

```
📚[Internationalization](https://day.js.org/docs/en/i18n/i18n)

@@ -113,3 +96,3 @@

```ts
```javascript
import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand

@@ -126,9 +109,24 @@

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/dayjs#sponsor)]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
<a href="https://opencollective.com/dayjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/dayjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/3/avatar.svg"></a>
[[Become a sponsor via Github](https://github.com/sponsors/iamkun/)] [[Become a sponsor via OpenCollective](https://opencollective.com/dayjs#sponsor)]
<a href="https://github.com/alan-eu" target="_blank">
<img width="70" src="https://avatars.githubusercontent.com/u/18175329?s=52&v=4">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://www.exoflare.com/open-source/?utm_source=dayjs&utm_campaign=open_source" target="_blank">
<img width="70" src="https://user-images.githubusercontent.com/17680888/162761622-1407a849-0c41-4591-8aa9-f98114ec2092.png">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://github.com/vendure-ecommerce" target="_blank"><img width="70" src="https://avatars.githubusercontent.com/u/39629390?s=52&v=4"></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://github.com/dc7290" target="_blank"><img width="70" src="https://avatars.githubusercontent.com/u/48201151?v=4"></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://github.com/Velc" target="_blank"><img width="70" src="https://avatars.githubusercontent.com/u/1551649?s=52&v=4"></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://github.com/projectdiscovery" target="_blank"><img width="70" src="https://avatars.githubusercontent.com/u/50994705?s=52&v=4"></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://opencollective.com/datawrapper" target="_blank"><img width="70" src="https://images.opencollective.com/datawrapper/c13e229/logo.png"></a>
## Contributors

@@ -135,0 +133,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc