@softwareventures/date
Advanced tools
+1
-1
@@ -354,3 +354,3 @@ "use strict"; | ||
| const match = /^([+-]?\d{4,})-?(\d{2})-?(\d{2})$/u.exec(text); | ||
| if (match == null || match[1] == null || match[2] == null || match[3] == null) { | ||
| if ((match === null || match === void 0 ? void 0 : match[1]) == null || match[2] == null || match[3] == null) { | ||
| return null; | ||
@@ -357,0 +357,0 @@ } |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uFAAuF;;;AAGvF,uDAAqD;AACrD,wCAAyC;AACzC,6DAAmD;AACnD,wDAAwD;AACxD,qCAAoC;AACpC,uCAAiC;AAuBpB,QAAA,OAAO,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACxE,QAAA,QAAQ,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACzE,QAAA,KAAK,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACtE,QAAA,KAAK,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACtE,QAAA,GAAG,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACpE,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACrE,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACrE,QAAA,MAAM,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACvE,QAAA,SAAS,GAAG,CAAC,CAAC,CAAC,2DAA2D;AAC1E,QAAA,OAAO,GAAG,EAAE,CAAC,CAAC,2DAA2D;AACzE,QAAA,QAAQ,GAAG,EAAE,CAAC,CAAC,2DAA2D;AAC1E,QAAA,QAAQ,GAAG,EAAE,CAAC,CAAC,2DAA2D;AAEvF;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CAAC,IAAY;IACnC,OAAO,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,C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AY,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,oCAAoC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEnC,OAAO,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;AAC9B,CAAC;AAXD,oCAWC;AAED;;2DAE2D;AAC9C,QAAA,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC","sourcesContent":["/** @file Data types and functions for working with dates in the Gregorian calendar. */\n\nimport type {Comparator} from \"@softwareventures/ordered\";\nimport {Comparison} from \"@softwareventures/ordered\";\nimport isInteger = require(\"is-integer\");\nimport isIntegerInRange from \"is-integer-in-range\";\nimport * as format from \"@softwareventures/format-date\";\nimport {hasProperty} from \"unknown\";\nimport {JsDate} from \"./js-date\";\n\n/** A date in the Gregorian calendar, with no associated time zone. */\nexport interface Date {\n /** The day of the month. Should be in the range 1-31. */\n day: number;\n /** The month of the year. Should be in the range 1-12. */\n month: number;\n /**\n * The year.\n *\n * Positive values represent years in the Common Era (CE/AD). For example\n * 2020 represents 2020 CE, the year this module was first published to npm.\n *\n * Negative values or zero represent years before the Common Era (BCE/BC).\n * Zero represents 1 BCE, -1 represents 2 BCE, -2 represents 3 BCE, etc.\n *\n * Note that there is no year zero in the Gregorian calendar. The year\n * 1 BCE was immediately followed by 1 CE.\n */\n year: number;\n}\n\nexport const JANUARY = 1; // eslint-disable-line @typescript-eslint/naming-convention\nexport const FEBRUARY = 2; // eslint-disable-line @typescript-eslint/naming-convention\nexport const MARCH = 3; // eslint-disable-line @typescript-eslint/naming-convention\nexport const APRIL = 4; // eslint-disable-line @typescript-eslint/naming-convention\nexport const MAY = 5; // eslint-disable-line @typescript-eslint/naming-convention\nexport const JUNE = 6; // eslint-disable-line @typescript-eslint/naming-convention\nexport const JULY = 7; // eslint-disable-line @typescript-eslint/naming-convention\nexport const AUGUST = 8; // eslint-disable-line @typescript-eslint/naming-convention\nexport const SEPTEMBER = 9; // eslint-disable-line @typescript-eslint/naming-convention\nexport const OCTOBER = 10; // eslint-disable-line @typescript-eslint/naming-convention\nexport const NOVEMBER = 11; // eslint-disable-line @typescript-eslint/naming-convention\nexport const DECEMBER = 12; // eslint-disable-line @typescript-eslint/naming-convention\n\n/**\n * Tests if the specified year is a leap year. Returns true if it is,\n * otherwise false.\n *\n * Positive values represent years in the Common Era (CE/AD). For example\n * 2020 represents 2020 CE, the year this module was first published to npm.\n *\n * Negative values or zero represent years before the Common Era (BCE/BC).\n * Zero represents 1 BCE, -1 represents 2 BCE, -2 represents 3 BCE, etc.\n *\n * Note that there is no year zero in the Gregorian calendar. The year\n * 1 BCE was immediately followed by 1 CE.\n */\nexport function isLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\n/**\n * Returns the number of days in the specified month in the specified year.\n *\n * @param month - An integer representing the month, in the range 1 (January)\n * to 12 (December).\n *\n * @param year - An integer representing the year. Positive values represent\n * years in the Common Era (CE/AD). For example 2020 represents 2020 CE, the\n * year this module was first published to npm. Negative values or zero\n * represent years before the Common Era (BCE/BC). Zero represents 1 BCE,\n * -1 represents 2 BCE, -2 represents 3 BCE, etc. There is no year zero in\n * the Gregorian calendar. The year 1 BCE was immediately followed by 1 CE.\n */\nexport function daysInMonth(month: number, year: number): number {\n if (month < JANUARY || month > DECEMBER) {\n throw new Error(\"Invalid month\");\n } else if (month === FEBRUARY && isLeapYear(year)) {\n return 29;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1]!;\n }\n}\n\n/**\n * Tests if the specified value has the shape of a Date object.\n *\n * Returns true if the value is an object with numeric year, month and day\n * fields.\n *\n * The fields may be non-integers or outside the valid range, meaning that the\n * object may not represent a valid date.\n *\n * To also test that the year, month, day are integers within the valid range,\n * use {@link isValidDate} instead.\n */\nexport function isDate(value: unknown): value is Date {\n return (\n typeof value === \"object\" &&\n value != null &&\n hasProperty(value, \"year\") &&\n typeof value.year === \"number\" &&\n hasProperty(value, \"month\") &&\n typeof value.month === \"number\" &&\n hasProperty(value, \"day\") &&\n typeof (value as {day: unknown}).day === \"number\"\n );\n}\n\n/**\n * Tests if the specified value is a Date object representing a valid date.\n *\n * Returns true if the value is an object with a numeric year, month and day\n * fields and the fields are all integers inside the valid range.\n */\nexport function isValidDate(value: unknown): value is Date {\n return isDate(value) && isValid(value);\n}\n\n/**\n * Tests if the specified Date object represents a valid date.\n *\n * Returns true if the year, month and day fields are all integers inside the\n * valid range.\n */\nexport function isValid(date: Readonly<Date>): boolean {\n return (\n isInteger(date.year) &&\n isIntegerInRange(date.month, JANUARY, DECEMBER) &&\n isIntegerInRange(date.day, 1, daysInMonth(date.month, date.year))\n );\n}\n\n/**\n * Asserts that the specified Date object represents a valid date.\n *\n * @throws {Error} if any of the year, month or day fields are non-integers or\n * outside the valid range.\n */\nexport function validate(date: Readonly<Date>): void {\n if (!isValid(date)) {\n throw new Error(\"Invalid date\");\n }\n}\n\n/**\n * Constructs a normalized date object from the specified year, month and day.\n *\n * If the month or day fields are outside the valid range, then they will\n * roll over into the next month or year.\n */\nexport function date(date: Readonly<Date>): Date {\n return normalize(date);\n}\n\n/**\n * Normalizes the specified date object so that it represents a valid date.\n *\n * If the month or day fields are outside the valid range, then they will\n * roll over into the next month or year.\n */\nexport function normalize(date: Readonly<Date>): Date {\n return fromReferenceDays(toReferenceDays(date));\n}\n\n/**\n * Converts the specified date to a count of the number of days since the\n * reference date of 1st January, 1 CE.\n */\nexport function toReferenceDays(date: Partial<Readonly<Date>>): number {\n const day = date.day ?? 1;\n const month = date.month ?? 1;\n const year = date.year ?? 1;\n\n const referenceMonths = (year - 1) * 12 + month - 1;\n\n return (\n Math.floor((referenceMonths * 365) / 12) +\n Math.floor((referenceMonths + 10) / 48) -\n Math.floor((referenceMonths + 10) / 1200) +\n Math.floor((referenceMonths + 10) / 4800) +\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [0, 1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0][(12 + (referenceMonths % 12)) % 12]! +\n day -\n 1\n );\n}\n\n/**\n * Creates a date corresponding to the specified count of the number of days\n * since the reference date of 1st January, 1 CE.\n */\nexport function fromReferenceDays(referenceDays: number): Date {\n const quadricentennium = Math.floor((referenceDays + 366) / 146097);\n const dayInQuadricentennium = referenceDays + 366 - quadricentennium * 146097;\n const centuryInQuadricentennium =\n dayInQuadricentennium === 0 ? 0 : Math.floor((dayInQuadricentennium - 1) / 36524);\n const longCentury = centuryInQuadricentennium === 0;\n const dayInCentury =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dayInQuadricentennium - [0, 36525, 73049, 109573][centuryInQuadricentennium]!;\n const quadrenniumInCentury = Math.floor(\n (dayInCentury + Number(centuryInQuadricentennium !== 0)) / 1461\n );\n const longQuadrennium = quadrenniumInCentury !== 0 || longCentury;\n const dayInQuadrennium =\n dayInCentury -\n quadrenniumInCentury * 1461 +\n Number(quadrenniumInCentury !== 0 && !longCentury);\n const yearInQuadrennium =\n dayInQuadrennium === 0 ? 0 : Math.floor((dayInQuadrennium - Number(longQuadrennium)) / 365);\n const dayInYear =\n dayInQuadrennium -\n yearInQuadrennium * 365 -\n Number(yearInQuadrennium !== 0 && longQuadrennium);\n const leapDay = Number(longQuadrennium && yearInQuadrennium === 0);\n\n const year =\n quadricentennium * 400 +\n centuryInQuadricentennium * 100 +\n quadrenniumInCentury * 4 +\n yearInQuadrennium;\n let month: number;\n let day: number;\n\n if (dayInYear < 181 + leapDay) {\n if (dayInYear < 90 + leapDay) {\n if (dayInYear < 31) {\n month = 1;\n day = dayInYear + 1;\n } else if (dayInYear < 59 + leapDay) {\n month = 2;\n day = dayInYear - 30;\n } else {\n month = 3;\n day = dayInYear - 58 - leapDay;\n }\n } else if (dayInYear < 120 + leapDay) {\n month = 4;\n day = dayInYear - 89 - leapDay;\n } else if (dayInYear < 151 + leapDay) {\n month = 5;\n day = dayInYear - 119 - leapDay;\n } else {\n month = 6;\n day = dayInYear - 150 - leapDay;\n }\n } else if (dayInYear < 273 + leapDay) {\n if (dayInYear < 212 + leapDay) {\n month = 7;\n day = dayInYear - 180 - leapDay;\n } else if (dayInYear < 243 + leapDay) {\n month = 8;\n day = dayInYear - 211 - leapDay;\n } else {\n month = 9;\n day = dayInYear - 242 - leapDay;\n }\n } else if (dayInYear < 304 + leapDay) {\n month = 10;\n day = dayInYear - 272 - leapDay;\n } else if (dayInYear < 334 + leapDay) {\n month = 11;\n day = dayInYear - 303 - leapDay;\n } else {\n month = 12;\n day = dayInYear - 333 - leapDay;\n }\n\n return {day, month, year};\n}\n\nexport function equal(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) === toReferenceDays(b);\n}\n\nexport function equalFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => equal(a, b);\n}\n\nexport function notEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) !== toReferenceDays(b);\n}\n\nexport function notEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => notEqual(a, b);\n}\n\nexport const compare: Comparator<Readonly<Date>> = (a, b) => {\n const ad = toReferenceDays(a);\n const bd = toReferenceDays(b);\n\n if (ad < bd) {\n return Comparison.before;\n } else if (ad > bd) {\n return Comparison.after;\n } else if (ad === bd) {\n return Comparison.equal;\n } else {\n return Comparison.undefined;\n }\n};\n\nexport function compareFn(b: Readonly<Date>): (a: Readonly<Date>) => Comparison {\n return a => compare(a, b);\n}\n\nexport function before(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) < toReferenceDays(b);\n}\n\nexport function beforeFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => before(a, b);\n}\n\nexport function beforeOrEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) <= toReferenceDays(b);\n}\n\nexport function beforeOrEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => beforeOrEqual(a, b);\n}\n\nexport function after(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) > toReferenceDays(b);\n}\n\nexport function afterFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => after(a, b);\n}\n\nexport function afterOrEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) >= toReferenceDays(b);\n}\n\nexport function afterOrEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => afterOrEqual(a, b);\n}\n\nexport function earliest<T extends Readonly<Date>, U extends Readonly<Date>>(a: T, b: U): T | U {\n return after(a, b) ? b : a;\n}\n\nexport function earliestFn<T extends Readonly<Date>, U extends Readonly<Date>>(\n b: U\n): (a: T) => T | U {\n return a => earliest(a, b);\n}\n\nexport function latest<T extends Readonly<Date>, U extends Readonly<Date>>(a: T, b: U): T | U {\n return before(a, b) ? b : a;\n}\n\nexport function latestFn<T extends Readonly<Date>, U extends Readonly<Date>>(\n b: U\n): (a: T) => T | U {\n return a => latest(a, b);\n}\n\nexport function todayUtc(): Date {\n const today = new JsDate();\n return {day: today.getUTCDate(), month: today.getUTCMonth() + 1, year: today.getUTCFullYear()};\n}\n\nexport function todayLocal(): Date {\n const today = new JsDate();\n return {day: today.getDate(), month: today.getMonth() + 1, year: today.getFullYear()};\n}\n\n/** Parses a Date from text in ISO 8601 format.\n *\n * The ISO 8601 text must not specify a time zone offset.\n *\n * If the specified text is not a valid ISO 8601 date then this function\n * returns `null`.\n *\n * Both extended `YYYY-MM-DD` and basic `YYYYMMDD` ISO 8601 formats are\n * accepted. */\nexport function parseIso8601(text: string): Date | null {\n const match = /^([+-]?\\d{4,})-?(\\d{2})-?(\\d{2})$/u.exec(text);\n if (match == null || match[1] == null || match[2] == null || match[3] == null) {\n return null;\n }\n\n const year = parseInt(match[1], 10);\n const month = parseInt(match[2], 10);\n const day = parseInt(match[3], 10);\n\n return {day, month, year};\n}\n\n/** Formats the specified Date as IS0 8601 extended, e.g. `2021-05-01`.\n *\n * For other formats, see @softwareventures/format-date. */\nexport const formatIso8601 = format.iso8601;\n"]} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uFAAuF;;;AAGvF,uDAAqD;AACrD,wCAAyC;AACzC,6DAAmD;AACnD,wDAAwD;AACxD,qCAAoC;AACpC,uCAAiC;AAuBpB,QAAA,OAAO,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACxE,QAAA,QAAQ,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACzE,QAAA,KAAK,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACtE,QAAA,KAAK,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACtE,QAAA,GAAG,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACpE,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACrE,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACrE,QAAA,MAAM,GAAG,CAAC,CAAC,CAAC,2DAA2D;AACvE,QAAA,SAAS,GAAG,CAAC,CAAC,CAAC,2DAA2D;AAC1E,QAAA,OAAO,GAAG,EAAE,CAAC,CAAC,2DAA2D;AACzE,QAAA,QAAQ,GAAG,EAAE,CAAC,CAAC,2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gBAAM,EAAE,CAAC;IAC3B,OAAO,EAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,EAAC,CAAC;AAC1F,CAAC;AAHD,gCAGC;AAED;;;;;;;;eAQe;AACf,SAAgB,YAAY,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,oCAAoC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,KAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEnC,OAAO,EAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;AAC9B,CAAC;AAXD,oCAWC;AAED;;2DAE2D;AAC9C,QAAA,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC","sourcesContent":["/** @file Data types and functions for working with dates in the Gregorian calendar. */\n\nimport type {Comparator} from \"@softwareventures/ordered\";\nimport {Comparison} from \"@softwareventures/ordered\";\nimport isInteger = require(\"is-integer\");\nimport isIntegerInRange from \"is-integer-in-range\";\nimport * as format from \"@softwareventures/format-date\";\nimport {hasProperty} from \"unknown\";\nimport {JsDate} from \"./js-date\";\n\n/** A date in the Gregorian calendar, with no associated time zone. */\nexport interface Date {\n /** The day of the month. Should be in the range 1-31. */\n day: number;\n /** The month of the year. Should be in the range 1-12. */\n month: number;\n /**\n * The year.\n *\n * Positive values represent years in the Common Era (CE/AD). For example\n * 2020 represents 2020 CE, the year this module was first published to npm.\n *\n * Negative values or zero represent years before the Common Era (BCE/BC).\n * Zero represents 1 BCE, -1 represents 2 BCE, -2 represents 3 BCE, etc.\n *\n * Note that there is no year zero in the Gregorian calendar. The year\n * 1 BCE was immediately followed by 1 CE.\n */\n year: number;\n}\n\nexport const JANUARY = 1; // eslint-disable-line @typescript-eslint/naming-convention\nexport const FEBRUARY = 2; // eslint-disable-line @typescript-eslint/naming-convention\nexport const MARCH = 3; // eslint-disable-line @typescript-eslint/naming-convention\nexport const APRIL = 4; // eslint-disable-line @typescript-eslint/naming-convention\nexport const MAY = 5; // eslint-disable-line @typescript-eslint/naming-convention\nexport const JUNE = 6; // eslint-disable-line @typescript-eslint/naming-convention\nexport const JULY = 7; // eslint-disable-line @typescript-eslint/naming-convention\nexport const AUGUST = 8; // eslint-disable-line @typescript-eslint/naming-convention\nexport const SEPTEMBER = 9; // eslint-disable-line @typescript-eslint/naming-convention\nexport const OCTOBER = 10; // eslint-disable-line @typescript-eslint/naming-convention\nexport const NOVEMBER = 11; // eslint-disable-line @typescript-eslint/naming-convention\nexport const DECEMBER = 12; // eslint-disable-line @typescript-eslint/naming-convention\n\n/**\n * Tests if the specified year is a leap year. Returns true if it is,\n * otherwise false.\n *\n * Positive values represent years in the Common Era (CE/AD). For example\n * 2020 represents 2020 CE, the year this module was first published to npm.\n *\n * Negative values or zero represent years before the Common Era (BCE/BC).\n * Zero represents 1 BCE, -1 represents 2 BCE, -2 represents 3 BCE, etc.\n *\n * Note that there is no year zero in the Gregorian calendar. The year\n * 1 BCE was immediately followed by 1 CE.\n */\nexport function isLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\n/**\n * Returns the number of days in the specified month in the specified year.\n *\n * @param month - An integer representing the month, in the range 1 (January)\n * to 12 (December).\n *\n * @param year - An integer representing the year. Positive values represent\n * years in the Common Era (CE/AD). For example 2020 represents 2020 CE, the\n * year this module was first published to npm. Negative values or zero\n * represent years before the Common Era (BCE/BC). Zero represents 1 BCE,\n * -1 represents 2 BCE, -2 represents 3 BCE, etc. There is no year zero in\n * the Gregorian calendar. The year 1 BCE was immediately followed by 1 CE.\n */\nexport function daysInMonth(month: number, year: number): number {\n if (month < JANUARY || month > DECEMBER) {\n throw new Error(\"Invalid month\");\n } else if (month === FEBRUARY && isLeapYear(year)) {\n return 29;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1]!;\n }\n}\n\n/**\n * Tests if the specified value has the shape of a Date object.\n *\n * Returns true if the value is an object with numeric year, month and day\n * fields.\n *\n * The fields may be non-integers or outside the valid range, meaning that the\n * object may not represent a valid date.\n *\n * To also test that the year, month, day are integers within the valid range,\n * use {@link isValidDate} instead.\n */\nexport function isDate(value: unknown): value is Date {\n return (\n typeof value === \"object\" &&\n value != null &&\n hasProperty(value, \"year\") &&\n typeof value.year === \"number\" &&\n hasProperty(value, \"month\") &&\n typeof value.month === \"number\" &&\n hasProperty(value, \"day\") &&\n typeof (value as {day: unknown}).day === \"number\"\n );\n}\n\n/**\n * Tests if the specified value is a Date object representing a valid date.\n *\n * Returns true if the value is an object with a numeric year, month and day\n * fields and the fields are all integers inside the valid range.\n */\nexport function isValidDate(value: unknown): value is Date {\n return isDate(value) && isValid(value);\n}\n\n/**\n * Tests if the specified Date object represents a valid date.\n *\n * Returns true if the year, month and day fields are all integers inside the\n * valid range.\n */\nexport function isValid(date: Readonly<Date>): boolean {\n return (\n isInteger(date.year) &&\n isIntegerInRange(date.month, JANUARY, DECEMBER) &&\n isIntegerInRange(date.day, 1, daysInMonth(date.month, date.year))\n );\n}\n\n/**\n * Asserts that the specified Date object represents a valid date.\n *\n * @throws {Error} if any of the year, month or day fields are non-integers or\n * outside the valid range.\n */\nexport function validate(date: Readonly<Date>): void {\n if (!isValid(date)) {\n throw new Error(\"Invalid date\");\n }\n}\n\n/**\n * Constructs a normalized date object from the specified year, month and day.\n *\n * If the month or day fields are outside the valid range, then they will\n * roll over into the next month or year.\n */\nexport function date(date: Readonly<Date>): Date {\n return normalize(date);\n}\n\n/**\n * Normalizes the specified date object so that it represents a valid date.\n *\n * If the month or day fields are outside the valid range, then they will\n * roll over into the next month or year.\n */\nexport function normalize(date: Readonly<Date>): Date {\n return fromReferenceDays(toReferenceDays(date));\n}\n\n/**\n * Converts the specified date to a count of the number of days since the\n * reference date of 1st January, 1 CE.\n */\nexport function toReferenceDays(date: Partial<Readonly<Date>>): number {\n const day = date.day ?? 1;\n const month = date.month ?? 1;\n const year = date.year ?? 1;\n\n const referenceMonths = (year - 1) * 12 + month - 1;\n\n return (\n Math.floor((referenceMonths * 365) / 12) +\n Math.floor((referenceMonths + 10) / 48) -\n Math.floor((referenceMonths + 10) / 1200) +\n Math.floor((referenceMonths + 10) / 4800) +\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [0, 1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0][(12 + (referenceMonths % 12)) % 12]! +\n day -\n 1\n );\n}\n\n/**\n * Creates a date corresponding to the specified count of the number of days\n * since the reference date of 1st January, 1 CE.\n */\nexport function fromReferenceDays(referenceDays: number): Date {\n const quadricentennium = Math.floor((referenceDays + 366) / 146097);\n const dayInQuadricentennium = referenceDays + 366 - quadricentennium * 146097;\n const centuryInQuadricentennium =\n dayInQuadricentennium === 0 ? 0 : Math.floor((dayInQuadricentennium - 1) / 36524);\n const longCentury = centuryInQuadricentennium === 0;\n const dayInCentury =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dayInQuadricentennium - [0, 36525, 73049, 109573][centuryInQuadricentennium]!;\n const quadrenniumInCentury = Math.floor(\n (dayInCentury + Number(centuryInQuadricentennium !== 0)) / 1461\n );\n const longQuadrennium = quadrenniumInCentury !== 0 || longCentury;\n const dayInQuadrennium =\n dayInCentury -\n quadrenniumInCentury * 1461 +\n Number(quadrenniumInCentury !== 0 && !longCentury);\n const yearInQuadrennium =\n dayInQuadrennium === 0 ? 0 : Math.floor((dayInQuadrennium - Number(longQuadrennium)) / 365);\n const dayInYear =\n dayInQuadrennium -\n yearInQuadrennium * 365 -\n Number(yearInQuadrennium !== 0 && longQuadrennium);\n const leapDay = Number(longQuadrennium && yearInQuadrennium === 0);\n\n const year =\n quadricentennium * 400 +\n centuryInQuadricentennium * 100 +\n quadrenniumInCentury * 4 +\n yearInQuadrennium;\n let month: number;\n let day: number;\n\n if (dayInYear < 181 + leapDay) {\n if (dayInYear < 90 + leapDay) {\n if (dayInYear < 31) {\n month = 1;\n day = dayInYear + 1;\n } else if (dayInYear < 59 + leapDay) {\n month = 2;\n day = dayInYear - 30;\n } else {\n month = 3;\n day = dayInYear - 58 - leapDay;\n }\n } else if (dayInYear < 120 + leapDay) {\n month = 4;\n day = dayInYear - 89 - leapDay;\n } else if (dayInYear < 151 + leapDay) {\n month = 5;\n day = dayInYear - 119 - leapDay;\n } else {\n month = 6;\n day = dayInYear - 150 - leapDay;\n }\n } else if (dayInYear < 273 + leapDay) {\n if (dayInYear < 212 + leapDay) {\n month = 7;\n day = dayInYear - 180 - leapDay;\n } else if (dayInYear < 243 + leapDay) {\n month = 8;\n day = dayInYear - 211 - leapDay;\n } else {\n month = 9;\n day = dayInYear - 242 - leapDay;\n }\n } else if (dayInYear < 304 + leapDay) {\n month = 10;\n day = dayInYear - 272 - leapDay;\n } else if (dayInYear < 334 + leapDay) {\n month = 11;\n day = dayInYear - 303 - leapDay;\n } else {\n month = 12;\n day = dayInYear - 333 - leapDay;\n }\n\n return {day, month, year};\n}\n\nexport function equal(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) === toReferenceDays(b);\n}\n\nexport function equalFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => equal(a, b);\n}\n\nexport function notEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) !== toReferenceDays(b);\n}\n\nexport function notEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => notEqual(a, b);\n}\n\nexport const compare: Comparator<Readonly<Date>> = (a, b) => {\n const ad = toReferenceDays(a);\n const bd = toReferenceDays(b);\n\n if (ad < bd) {\n return Comparison.before;\n } else if (ad > bd) {\n return Comparison.after;\n } else if (ad === bd) {\n return Comparison.equal;\n } else {\n return Comparison.undefined;\n }\n};\n\nexport function compareFn(b: Readonly<Date>): (a: Readonly<Date>) => Comparison {\n return a => compare(a, b);\n}\n\nexport function before(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) < toReferenceDays(b);\n}\n\nexport function beforeFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => before(a, b);\n}\n\nexport function beforeOrEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) <= toReferenceDays(b);\n}\n\nexport function beforeOrEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => beforeOrEqual(a, b);\n}\n\nexport function after(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) > toReferenceDays(b);\n}\n\nexport function afterFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => after(a, b);\n}\n\nexport function afterOrEqual(a: Readonly<Date>, b: Readonly<Date>): boolean {\n return toReferenceDays(a) >= toReferenceDays(b);\n}\n\nexport function afterOrEqualFn(b: Readonly<Date>): (a: Readonly<Date>) => boolean {\n return a => afterOrEqual(a, b);\n}\n\nexport function earliest<T extends Readonly<Date>, U extends Readonly<Date>>(a: T, b: U): T | U {\n return after(a, b) ? b : a;\n}\n\nexport function earliestFn<T extends Readonly<Date>, U extends Readonly<Date>>(\n b: U\n): (a: T) => T | U {\n return a => earliest(a, b);\n}\n\nexport function latest<T extends Readonly<Date>, U extends Readonly<Date>>(a: T, b: U): T | U {\n return before(a, b) ? b : a;\n}\n\nexport function latestFn<T extends Readonly<Date>, U extends Readonly<Date>>(\n b: U\n): (a: T) => T | U {\n return a => latest(a, b);\n}\n\nexport function todayUtc(): Date {\n const today = new JsDate();\n return {day: today.getUTCDate(), month: today.getUTCMonth() + 1, year: today.getUTCFullYear()};\n}\n\nexport function todayLocal(): Date {\n const today = new JsDate();\n return {day: today.getDate(), month: today.getMonth() + 1, year: today.getFullYear()};\n}\n\n/** Parses a Date from text in ISO 8601 format.\n *\n * The ISO 8601 text must not specify a time zone offset.\n *\n * If the specified text is not a valid ISO 8601 date then this function\n * returns `null`.\n *\n * Both extended `YYYY-MM-DD` and basic `YYYYMMDD` ISO 8601 formats are\n * accepted. */\nexport function parseIso8601(text: string): Date | null {\n const match = /^([+-]?\\d{4,})-?(\\d{2})-?(\\d{2})$/u.exec(text);\n if (match?.[1] == null || match[2] == null || match[3] == null) {\n return null;\n }\n\n const year = parseInt(match[1], 10);\n const month = parseInt(match[2], 10);\n const day = parseInt(match[3], 10);\n\n return {day, month, year};\n}\n\n/** Formats the specified Date as IS0 8601 extended, e.g. `2021-05-01`.\n *\n * For other formats, see @softwareventures/format-date. */\nexport const formatIso8601 = format.iso8601;\n"]} |
+5
-5
| { | ||
| "name": "@softwareventures/date", | ||
| "version": "3.1.1", | ||
| "version": "3.1.2", | ||
| "description": "An abstract date, with no associated time zone", | ||
@@ -40,4 +40,4 @@ "keywords": [ | ||
| "@commitlint/config-conventional": "18.5.0", | ||
| "@commitlint/cz-commitlint": "17.8.1", | ||
| "@softwareventures/eslint-config": "7.1.4", | ||
| "@commitlint/cz-commitlint": "18.5.0", | ||
| "@softwareventures/eslint-config": "7.1.5", | ||
| "@softwareventures/precise-commits": "3.0.33", | ||
@@ -47,4 +47,4 @@ "@softwareventures/prettier-config": "4.0.0", | ||
| "@softwareventures/tsconfig": "7.1.0", | ||
| "@typescript-eslint/eslint-plugin": "5.62.0", | ||
| "@typescript-eslint/parser": "5.62.0", | ||
| "@typescript-eslint/eslint-plugin": "6.19.1", | ||
| "@typescript-eslint/parser": "6.19.1", | ||
| "ava": "6.1.0", | ||
@@ -51,0 +51,0 @@ "commitizen": "4.3.0", |
49743
0.04%