1. 调整计划列表展示项
2. 调整设备列表展示项
This commit is contained in:
8
node_modules/cron-parser/dist/types/index.d.ts
generated
vendored
Normal file
8
node_modules/cron-parser/dist/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { CronExpressionParser } from './CronExpressionParser';
|
||||
export { CronDate } from './CronDate';
|
||||
export { CronFieldCollection } from './CronFieldCollection';
|
||||
export { CronExpression, CronExpressionOptions } from './CronExpression';
|
||||
export { CronExpressionParser } from './CronExpressionParser';
|
||||
export { CronFileParser, CronFileParserResult } from './CronFileParser';
|
||||
export * from './fields';
|
||||
export default CronExpressionParser;
|
||||
117
node_modules/cron-parser/package.json
generated
vendored
Normal file
117
node_modules/cron-parser/package.json
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"name": "cron-parser",
|
||||
"version": "5.4.0",
|
||||
"description": "Node.js library for parsing crontab instructions",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"type": "commonjs",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"bench": "cross-env node -r ts-node/register benchmarks/index.ts",
|
||||
"bench:pattern": "cross-env node -r ts-node/register benchmarks/pattern.ts",
|
||||
"bench:clean": "rimraf benchmarks/versions && rimraf benchmarks/results",
|
||||
"build": "npm run clean && tsc -p tsconfig.json",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prepare": "husky && npm run build",
|
||||
"precommit": "lint-staged",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"lint:debug": "cross-env DEBUG=eslint:cli-engine eslint .",
|
||||
"format": "prettier --write \"**/*.{ts,js,json,md}\"",
|
||||
"format:check": "prettier --check \"**/*.{ts,js,json,md}\"",
|
||||
"test:unit": "cross-env TZ=UTC jest",
|
||||
"test:coverage": "cross-env TZ=UTC jest --coverage",
|
||||
"generate-badges": "jest-coverage-badges",
|
||||
"test:types": "npm run build && tsd",
|
||||
"test": "cross-env TZ=UTC npm run lint && npm run test:types && npm run test:coverage && npm run generate-badges",
|
||||
"docs": "rimraf docs && typedoc --out docs --readme none --name 'CronParser' src"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"luxon": "^3.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsd/typescript": "^5.8.2",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/luxon": "^3.6.2",
|
||||
"@types/node": "^22.14.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
||||
"@typescript-eslint/parser": "^8.29.0",
|
||||
"chalk": "^5.4.1",
|
||||
"cli-table3": "^0.6.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^9.23.0",
|
||||
"eslint-config-prettier": "^10.1.1",
|
||||
"eslint-plugin-prettier": "^5.2.6",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^29.7.0",
|
||||
"jest-coverage-badges": "^1.0.0",
|
||||
"lint-staged": "^15.5.0",
|
||||
"prettier": "^3.5.3",
|
||||
"rimraf": "^6.0.1",
|
||||
"sinon": "^20.0.0",
|
||||
"ts-jest": "^29.3.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsd": "^0.31.2",
|
||||
"typedoc": "^0.28.1",
|
||||
"typescript": "^5.8.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,js,json}": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"browser": {
|
||||
"fs": false,
|
||||
"fs/promises": false
|
||||
},
|
||||
"tsd": {
|
||||
"directory": "tests"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/harrisiirak/cron-parser.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cron",
|
||||
"crontab",
|
||||
"parser"
|
||||
],
|
||||
"author": "Harri Siirak",
|
||||
"contributors": [
|
||||
"Nicholas Clawson",
|
||||
"Daniel Prentis <daniel@salsitasoft.com>",
|
||||
"Renault John Lecoultre",
|
||||
"Richard Astbury <richard.astbury@gmail.com>",
|
||||
"Meaglin Wasabi <Meaglin.wasabi@gmail.com>",
|
||||
"Mike Kusold <hello@mikekusold.com>",
|
||||
"Alex Kit <alex.kit@atmajs.com>",
|
||||
"Santiago Gimeno <santiago.gimeno@gmail.com>",
|
||||
"Daniel <darc.tec@gmail.com>",
|
||||
"Christian Steininger <christian.steininger.cs@gmail.com>",
|
||||
"Mykola Piskovyi <m.piskovyi@gmail.com>",
|
||||
"Brian Vaughn <brian.david.vaughn@gmail.com>",
|
||||
"Nicholas Clawson <nickclaw@gmail.com>",
|
||||
"Yasuhiroki <yasuhiroki.duck@gmail.com>",
|
||||
"Nicholas Clawson <nickclaw@gmail.com>",
|
||||
"Brendan Warkentin <faazshift@gmail.com>",
|
||||
"Charlie Fish <fishcharlie.code@gmail.com>",
|
||||
"Ian Graves <ian+diskimage@iangrav.es>",
|
||||
"Andy Thompson <me@andytson.com>",
|
||||
"Regev Brody <regevbr@gmail.com>",
|
||||
"Michael Hobbs <michael.lee.hobbs@gmail.com>"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
7
node_modules/luxon/LICENSE.md
generated
vendored
Normal file
7
node_modules/luxon/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2019 JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
55
node_modules/luxon/README.md
generated
vendored
Normal file
55
node_modules/luxon/README.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# Luxon
|
||||
|
||||
[![MIT License][license-image]][license] [![Build Status][github-action-image]][github-action-url] [![NPM version][npm-version-image]][npm-url] [![Coverage Status][test-coverage-image]][test-coverage-url] [![PRs welcome][contributing-image]][contributing-url]
|
||||
|
||||
Luxon is a library for working with dates and times in JavaScript.
|
||||
|
||||
```js
|
||||
DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").toISO();
|
||||
```
|
||||
|
||||
## Upgrading to 3.0
|
||||
|
||||
[Guide](https://moment.github.io/luxon/#upgrading)
|
||||
|
||||
## Features
|
||||
* DateTime, Duration, and Interval types.
|
||||
* Immutable, chainable, unambiguous API.
|
||||
* Parsing and formatting for common and custom formats.
|
||||
* Native time zone and Intl support (no locale or tz files).
|
||||
|
||||
## Download/install
|
||||
|
||||
[Download/install instructions](https://moment.github.io/luxon/#/install)
|
||||
|
||||
## Documentation
|
||||
|
||||
* [General documentation](https://moment.github.io/luxon/#/?id=luxon)
|
||||
* [API docs](https://moment.github.io/luxon/api-docs/index.html)
|
||||
* [Quick tour](https://moment.github.io/luxon/#/tour)
|
||||
* [For Moment users](https://moment.github.io/luxon/#/moment)
|
||||
* [Why does Luxon exist?](https://moment.github.io/luxon/#/why)
|
||||
* [A quick demo](https://moment.github.io/luxon/demo/global.html)
|
||||
|
||||
## Development
|
||||
|
||||
See [contributing](CONTRIBUTING.md).
|
||||
|
||||
![Phasers to stun][phasers-image]
|
||||
|
||||
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[license]: LICENSE.md
|
||||
|
||||
[github-action-image]: https://github.com/moment/luxon/actions/workflows/test.yml/badge.svg
|
||||
[github-action-url]: https://github.com/moment/luxon/actions/workflows/test.yml
|
||||
|
||||
[npm-url]: https://npmjs.org/package/luxon
|
||||
[npm-version-image]: https://badge.fury.io/js/luxon.svg
|
||||
|
||||
[test-coverage-url]: https://codecov.io/gh/moment/luxon
|
||||
[test-coverage-image]: https://codecov.io/gh/moment/luxon/branch/master/graph/badge.svg
|
||||
|
||||
[contributing-url]: https://github.com/moment/luxon/blob/master/CONTRIBUTING.md
|
||||
[contributing-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
||||
|
||||
[phasers-image]: https://img.shields.io/badge/phasers-stun-brightgreen.svg
|
||||
87
node_modules/luxon/package.json
generated
vendored
Normal file
87
node_modules/luxon/package.json
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "luxon",
|
||||
"version": "3.7.2",
|
||||
"description": "Immutable date wrapper",
|
||||
"author": "Isaac Cambron",
|
||||
"keywords": [
|
||||
"date",
|
||||
"immutable"
|
||||
],
|
||||
"repository": "https://github.com/moment/luxon",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./build/es6/luxon.mjs",
|
||||
"require": "./build/node/luxon.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel-node tasks/buildAll.js",
|
||||
"build-node": "babel-node tasks/buildNode.js",
|
||||
"build-global": "babel-node tasks/buildGlobal.js",
|
||||
"jest": "jest",
|
||||
"test": "jest --coverage",
|
||||
"api-docs": "mkdir -p build && documentation build src/luxon.js -f html -o build/api-docs && sed -i.bak 's/<\\/body>/<script src=\"\\..\\/global\\/luxon.js\"><\\/script><script>console.log(\"You can try Luxon right here using the `luxon` global, like `luxon.DateTime.now()`\");<\\/script><\\/body>/g' build/api-docs/index.html && rm build/api-docs/index.html.bak",
|
||||
"copy-site": "mkdir -p build && rsync -a docs/ build/docs && rsync -a site/ build",
|
||||
"site": "npm run api-docs && npm run copy-site",
|
||||
"format": "prettier --write 'src/**/*.js' 'test/**/*.js' 'benchmarks/*.js'",
|
||||
"format-check": "prettier --check 'src/**/*.js' 'test/**/*.js' 'benchmarks/*.js'",
|
||||
"benchmark": "node benchmarks/index.js",
|
||||
"codecov": "codecov",
|
||||
"prepack": "babel-node tasks/buildAll.js",
|
||||
"prepare": "husky install",
|
||||
"show-site": "http-server build"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,json}": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/node": "^7.18.6",
|
||||
"@babel/plugin-external-helpers": "^7.18.6",
|
||||
"@babel/preset-env": "^7.18.6",
|
||||
"@rollup/plugin-babel": "^5.3.0",
|
||||
"@rollup/plugin-commonjs": "^19.0.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.0",
|
||||
"babel-jest": "^28.1.2",
|
||||
"benchmark": "latest",
|
||||
"codecov": "latest",
|
||||
"documentation": "latest",
|
||||
"fs-extra": "^6.0.1",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^7.0.0",
|
||||
"jest": "^29.4.3",
|
||||
"lint-staged": "^13.2.1",
|
||||
"prettier": "latest",
|
||||
"rollup": "^2.52.7",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"uglify-js": "^3.13.10"
|
||||
},
|
||||
"main": "build/node/luxon.js",
|
||||
"module": "src/luxon.js",
|
||||
"browser": "build/cjs-browser/luxon.js",
|
||||
"jsdelivr": "build/global/luxon.min.js",
|
||||
"unpkg": "build/global/luxon.min.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"files": [
|
||||
"build/node/luxon.js",
|
||||
"build/node/luxon.js.map",
|
||||
"build/cjs-browser/luxon.js",
|
||||
"build/cjs-browser/luxon.js.map",
|
||||
"build/amd/luxon.js",
|
||||
"build/amd/luxon.js.map",
|
||||
"build/global/luxon.js",
|
||||
"build/global/luxon.js.map",
|
||||
"build/global/luxon.min.js",
|
||||
"build/global/luxon.min.js.map",
|
||||
"build/es6/luxon.mjs",
|
||||
"build/es6/luxon.mjs.map",
|
||||
"src"
|
||||
],
|
||||
"license": "MIT",
|
||||
"sideEffects": false
|
||||
}
|
||||
2603
node_modules/luxon/src/datetime.js
generated
vendored
Normal file
2603
node_modules/luxon/src/datetime.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1009
node_modules/luxon/src/duration.js
generated
vendored
Normal file
1009
node_modules/luxon/src/duration.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
61
node_modules/luxon/src/errors.js
generated
vendored
Normal file
61
node_modules/luxon/src/errors.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// these aren't really private, but nor are they really useful to document
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
class LuxonError extends Error {}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class InvalidDateTimeError extends LuxonError {
|
||||
constructor(reason) {
|
||||
super(`Invalid DateTime: ${reason.toMessage()}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class InvalidIntervalError extends LuxonError {
|
||||
constructor(reason) {
|
||||
super(`Invalid Interval: ${reason.toMessage()}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class InvalidDurationError extends LuxonError {
|
||||
constructor(reason) {
|
||||
super(`Invalid Duration: ${reason.toMessage()}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class ConflictingSpecificationError extends LuxonError {}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class InvalidUnitError extends LuxonError {
|
||||
constructor(unit) {
|
||||
super(`Invalid unit ${unit}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class InvalidArgumentError extends LuxonError {}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class ZoneIsAbstractError extends LuxonError {
|
||||
constructor() {
|
||||
super("Zone is an abstract class");
|
||||
}
|
||||
}
|
||||
205
node_modules/luxon/src/info.js
generated
vendored
Normal file
205
node_modules/luxon/src/info.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
import DateTime from "./datetime.js";
|
||||
import Settings from "./settings.js";
|
||||
import Locale from "./impl/locale.js";
|
||||
import IANAZone from "./zones/IANAZone.js";
|
||||
import { normalizeZone } from "./impl/zoneUtil.js";
|
||||
|
||||
import { hasLocaleWeekInfo, hasRelative } from "./impl/util.js";
|
||||
|
||||
/**
|
||||
* The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment.
|
||||
*/
|
||||
export default class Info {
|
||||
/**
|
||||
* Return whether the specified zone contains a DST.
|
||||
* @param {string|Zone} [zone='local'] - Zone to check. Defaults to the environment's local zone.
|
||||
* @return {boolean}
|
||||
*/
|
||||
static hasDST(zone = Settings.defaultZone) {
|
||||
const proto = DateTime.now().setZone(zone).set({ month: 12 });
|
||||
|
||||
return !zone.isUniversal && proto.offset !== proto.set({ month: 6 }).offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the specified zone is a valid IANA specifier.
|
||||
* @param {string} zone - Zone to check
|
||||
* @return {boolean}
|
||||
*/
|
||||
static isValidIANAZone(zone) {
|
||||
return IANAZone.isValidZone(zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input into a {@link Zone} instance.
|
||||
*
|
||||
* * If `input` is already a Zone instance, it is returned unchanged.
|
||||
* * If `input` is a string containing a valid time zone name, a Zone instance
|
||||
* with that name is returned.
|
||||
* * If `input` is a string that doesn't refer to a known time zone, a Zone
|
||||
* instance with {@link Zone#isValid} == false is returned.
|
||||
* * If `input is a number, a Zone instance with the specified fixed offset
|
||||
* in minutes is returned.
|
||||
* * If `input` is `null` or `undefined`, the default zone is returned.
|
||||
* @param {string|Zone|number} [input] - the value to be converted
|
||||
* @return {Zone}
|
||||
*/
|
||||
static normalizeZone(input) {
|
||||
return normalizeZone(input, Settings.defaultZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the weekday on which the week starts according to the given locale.
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number} the start of the week, 1 for Monday through 7 for Sunday
|
||||
*/
|
||||
static getStartOfWeek({ locale = null, locObj = null } = {}) {
|
||||
return (locObj || Locale.create(locale)).getStartOfWeek();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum number of days necessary in a week before it is considered part of the next year according
|
||||
* to the given locale.
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number}
|
||||
*/
|
||||
static getMinimumDaysInFirstWeek({ locale = null, locObj = null } = {}) {
|
||||
return (locObj || Locale.create(locale)).getMinDaysInFirstWeek();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the weekdays, which are considered the weekend according to the given locale
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number[]} an array of weekdays, 1 for Monday through 7 for Sunday
|
||||
*/
|
||||
static getWeekendWeekdays({ locale = null, locObj = null } = {}) {
|
||||
// copy the array, because we cache it internally
|
||||
return (locObj || Locale.create(locale)).getWeekendDays().slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of standalone month names.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
||||
* @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.numberingSystem=null] - the numbering system
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @param {string} [opts.outputCalendar='gregory'] - the calendar
|
||||
* @example Info.months()[0] //=> 'January'
|
||||
* @example Info.months('short')[0] //=> 'Jan'
|
||||
* @example Info.months('numeric')[0] //=> '1'
|
||||
* @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
|
||||
* @example Info.months('numeric', { locale: 'ar' })[0] //=> '١'
|
||||
* @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'
|
||||
* @return {Array}
|
||||
*/
|
||||
static months(
|
||||
length = "long",
|
||||
{ locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}
|
||||
) {
|
||||
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of format month names.
|
||||
* Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that
|
||||
* changes the string.
|
||||
* See {@link Info#months}
|
||||
* @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.numberingSystem=null] - the numbering system
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @param {string} [opts.outputCalendar='gregory'] - the calendar
|
||||
* @return {Array}
|
||||
*/
|
||||
static monthsFormat(
|
||||
length = "long",
|
||||
{ locale = null, numberingSystem = null, locObj = null, outputCalendar = "gregory" } = {}
|
||||
) {
|
||||
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of standalone week names.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
||||
* @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.numberingSystem=null] - the numbering system
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @example Info.weekdays()[0] //=> 'Monday'
|
||||
* @example Info.weekdays('short')[0] //=> 'Mon'
|
||||
* @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'
|
||||
* @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'
|
||||
* @return {Array}
|
||||
*/
|
||||
static weekdays(length = "long", { locale = null, numberingSystem = null, locObj = null } = {}) {
|
||||
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of format week names.
|
||||
* Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that
|
||||
* changes the string.
|
||||
* See {@link Info#weekdays}
|
||||
* @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale=null] - the locale code
|
||||
* @param {string} [opts.numberingSystem=null] - the numbering system
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @return {Array}
|
||||
*/
|
||||
static weekdaysFormat(
|
||||
length = "long",
|
||||
{ locale = null, numberingSystem = null, locObj = null } = {}
|
||||
) {
|
||||
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of meridiems.
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @example Info.meridiems() //=> [ 'AM', 'PM' ]
|
||||
* @example Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]
|
||||
* @return {Array}
|
||||
*/
|
||||
static meridiems({ locale = null } = {}) {
|
||||
return Locale.create(locale).meridiems();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.
|
||||
* @param {string} [length='short'] - the length of the era representation, such as "short" or "long".
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @example Info.eras() //=> [ 'BC', 'AD' ]
|
||||
* @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]
|
||||
* @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]
|
||||
* @return {Array}
|
||||
*/
|
||||
static eras(length = "short", { locale = null } = {}) {
|
||||
return Locale.create(locale, null, "gregory").eras(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the set of available features in this environment.
|
||||
* Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case.
|
||||
* Keys:
|
||||
* * `relative`: whether this environment supports relative time formatting
|
||||
* * `localeWeek`: whether this environment supports different weekdays for the start of the week based on the locale
|
||||
* @example Info.features() //=> { relative: false, localeWeek: true }
|
||||
* @return {Object}
|
||||
*/
|
||||
static features() {
|
||||
return { relative: hasRelative(), localeWeek: hasLocaleWeekInfo() };
|
||||
}
|
||||
}
|
||||
669
node_modules/luxon/src/interval.js
generated
vendored
Normal file
669
node_modules/luxon/src/interval.js
generated
vendored
Normal file
@@ -0,0 +1,669 @@
|
||||
import DateTime, { friendlyDateTime } from "./datetime.js";
|
||||
import Duration from "./duration.js";
|
||||
import Settings from "./settings.js";
|
||||
import { InvalidArgumentError, InvalidIntervalError } from "./errors.js";
|
||||
import Invalid from "./impl/invalid.js";
|
||||
import Formatter from "./impl/formatter.js";
|
||||
import * as Formats from "./impl/formats.js";
|
||||
|
||||
const INVALID = "Invalid Interval";
|
||||
|
||||
// checks if the start is equal to or before the end
|
||||
function validateStartEnd(start, end) {
|
||||
if (!start || !start.isValid) {
|
||||
return Interval.invalid("missing or invalid start");
|
||||
} else if (!end || !end.isValid) {
|
||||
return Interval.invalid("missing or invalid end");
|
||||
} else if (end < start) {
|
||||
return Interval.invalid(
|
||||
"end before start",
|
||||
`The end of an interval must be after its start, but you had start=${start.toISO()} and end=${end.toISO()}`
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. Conceptually, it's a container for those two endpoints, accompanied by methods for creating, parsing, interrogating, comparing, transforming, and formatting them.
|
||||
*
|
||||
* Here is a brief overview of the most commonly used methods and getters in Interval:
|
||||
*
|
||||
* * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
|
||||
* * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
|
||||
* * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}.
|
||||
* * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
|
||||
* * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
|
||||
* * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toLocaleString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}.
|
||||
*/
|
||||
export default class Interval {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
constructor(config) {
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
this.s = config.start;
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
this.e = config.end;
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
this.invalid = config.invalid || null;
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
this.isLuxonInterval = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invalid Interval.
|
||||
* @param {string} reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent
|
||||
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
|
||||
* @return {Interval}
|
||||
*/
|
||||
static invalid(reason, explanation = null) {
|
||||
if (!reason) {
|
||||
throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
|
||||
}
|
||||
|
||||
const invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
||||
|
||||
if (Settings.throwOnInvalid) {
|
||||
throw new InvalidIntervalError(invalid);
|
||||
} else {
|
||||
return new Interval({ invalid });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end.
|
||||
* @param {DateTime|Date|Object} start
|
||||
* @param {DateTime|Date|Object} end
|
||||
* @return {Interval}
|
||||
*/
|
||||
static fromDateTimes(start, end) {
|
||||
const builtStart = friendlyDateTime(start),
|
||||
builtEnd = friendlyDateTime(end);
|
||||
|
||||
const validateError = validateStartEnd(builtStart, builtEnd);
|
||||
|
||||
if (validateError == null) {
|
||||
return new Interval({
|
||||
start: builtStart,
|
||||
end: builtEnd,
|
||||
});
|
||||
} else {
|
||||
return validateError;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Interval from a start DateTime and a Duration to extend to.
|
||||
* @param {DateTime|Date|Object} start
|
||||
* @param {Duration|Object|number} duration - the length of the Interval.
|
||||
* @return {Interval}
|
||||
*/
|
||||
static after(start, duration) {
|
||||
const dur = Duration.fromDurationLike(duration),
|
||||
dt = friendlyDateTime(start);
|
||||
return Interval.fromDateTimes(dt, dt.plus(dur));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Interval from an end DateTime and a Duration to extend backwards to.
|
||||
* @param {DateTime|Date|Object} end
|
||||
* @param {Duration|Object|number} duration - the length of the Interval.
|
||||
* @return {Interval}
|
||||
*/
|
||||
static before(end, duration) {
|
||||
const dur = Duration.fromDurationLike(duration),
|
||||
dt = friendlyDateTime(end);
|
||||
return Interval.fromDateTimes(dt.minus(dur), dt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Interval from an ISO 8601 string.
|
||||
* Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats.
|
||||
* @param {string} text - the ISO string to parse
|
||||
* @param {Object} [opts] - options to pass {@link DateTime#fromISO} and optionally {@link Duration#fromISO}
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
||||
* @return {Interval}
|
||||
*/
|
||||
static fromISO(text, opts) {
|
||||
const [s, e] = (text || "").split("/", 2);
|
||||
if (s && e) {
|
||||
let start, startIsValid;
|
||||
try {
|
||||
start = DateTime.fromISO(s, opts);
|
||||
startIsValid = start.isValid;
|
||||
} catch (e) {
|
||||
startIsValid = false;
|
||||
}
|
||||
|
||||
let end, endIsValid;
|
||||
try {
|
||||
end = DateTime.fromISO(e, opts);
|
||||
endIsValid = end.isValid;
|
||||
} catch (e) {
|
||||
endIsValid = false;
|
||||
}
|
||||
|
||||
if (startIsValid && endIsValid) {
|
||||
return Interval.fromDateTimes(start, end);
|
||||
}
|
||||
|
||||
if (startIsValid) {
|
||||
const dur = Duration.fromISO(e, opts);
|
||||
if (dur.isValid) {
|
||||
return Interval.after(start, dur);
|
||||
}
|
||||
} else if (endIsValid) {
|
||||
const dur = Duration.fromISO(s, opts);
|
||||
if (dur.isValid) {
|
||||
return Interval.before(end, dur);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Interval.invalid("unparsable", `the input "${text}" can't be parsed as ISO 8601`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an object is an Interval. Works across context boundaries
|
||||
* @param {object} o
|
||||
* @return {boolean}
|
||||
*/
|
||||
static isInterval(o) {
|
||||
return (o && o.isLuxonInterval) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start of the Interval
|
||||
* @type {DateTime}
|
||||
*/
|
||||
get start() {
|
||||
return this.isValid ? this.s : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end of the Interval. This is the first instant which is not part of the interval
|
||||
* (Interval is half-open).
|
||||
* @type {DateTime}
|
||||
*/
|
||||
get end() {
|
||||
return this.isValid ? this.e : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last DateTime included in the interval (since end is not part of the interval)
|
||||
* @type {DateTime}
|
||||
*/
|
||||
get lastDateTime() {
|
||||
return this.isValid ? (this.e ? this.e.minus(1) : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isValid() {
|
||||
return this.invalidReason === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error code if this Interval is invalid, or null if the Interval is valid
|
||||
* @type {string}
|
||||
*/
|
||||
get invalidReason() {
|
||||
return this.invalid ? this.invalid.reason : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an explanation of why this Interval became invalid, or null if the Interval is valid
|
||||
* @type {string}
|
||||
*/
|
||||
get invalidExplanation() {
|
||||
return this.invalid ? this.invalid.explanation : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the Interval in the specified unit.
|
||||
* @param {string} unit - the unit (such as 'hours' or 'days') to return the length in.
|
||||
* @return {number}
|
||||
*/
|
||||
length(unit = "milliseconds") {
|
||||
return this.isValid ? this.toDuration(...[unit]).get(unit) : NaN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of minutes, hours, days, months, or years included in the Interval, even in part.
|
||||
* Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
|
||||
* asks 'what dates are included in this interval?', not 'how many days long is this interval?'
|
||||
* @param {string} [unit='milliseconds'] - the unit of time to count.
|
||||
* @param {Object} opts - options
|
||||
* @param {boolean} [opts.useLocaleWeeks=false] - If true, use weeks based on the locale, i.e. use the locale-dependent start of the week; this operation will always use the locale of the start DateTime
|
||||
* @return {number}
|
||||
*/
|
||||
count(unit = "milliseconds", opts) {
|
||||
if (!this.isValid) return NaN;
|
||||
const start = this.start.startOf(unit, opts);
|
||||
let end;
|
||||
if (opts?.useLocaleWeeks) {
|
||||
end = this.end.reconfigure({ locale: start.locale });
|
||||
} else {
|
||||
end = this.end;
|
||||
}
|
||||
end = end.startOf(unit, opts);
|
||||
return Math.floor(end.diff(start, unit).get(unit)) + (end.valueOf() !== this.end.valueOf());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Interval's start and end are both in the same unit of time
|
||||
* @param {string} unit - the unit of time to check sameness on
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasSame(unit) {
|
||||
return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval has the same start and end DateTimes.
|
||||
* @return {boolean}
|
||||
*/
|
||||
isEmpty() {
|
||||
return this.s.valueOf() === this.e.valueOf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval's start is after the specified DateTime.
|
||||
* @param {DateTime} dateTime
|
||||
* @return {boolean}
|
||||
*/
|
||||
isAfter(dateTime) {
|
||||
if (!this.isValid) return false;
|
||||
return this.s > dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval's end is before the specified DateTime.
|
||||
* @param {DateTime} dateTime
|
||||
* @return {boolean}
|
||||
*/
|
||||
isBefore(dateTime) {
|
||||
if (!this.isValid) return false;
|
||||
return this.e <= dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval contains the specified DateTime.
|
||||
* @param {DateTime} dateTime
|
||||
* @return {boolean}
|
||||
*/
|
||||
contains(dateTime) {
|
||||
if (!this.isValid) return false;
|
||||
return this.s <= dateTime && this.e > dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Sets" the start and/or end dates. Returns a newly-constructed Interval.
|
||||
* @param {Object} values - the values to set
|
||||
* @param {DateTime} values.start - the starting DateTime
|
||||
* @param {DateTime} values.end - the ending DateTime
|
||||
* @return {Interval}
|
||||
*/
|
||||
set({ start, end } = {}) {
|
||||
if (!this.isValid) return this;
|
||||
return Interval.fromDateTimes(start || this.s, end || this.e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split this Interval at each of the specified DateTimes
|
||||
* @param {...DateTime} dateTimes - the unit of time to count.
|
||||
* @return {Array}
|
||||
*/
|
||||
splitAt(...dateTimes) {
|
||||
if (!this.isValid) return [];
|
||||
const sorted = dateTimes
|
||||
.map(friendlyDateTime)
|
||||
.filter((d) => this.contains(d))
|
||||
.sort((a, b) => a.toMillis() - b.toMillis()),
|
||||
results = [];
|
||||
let { s } = this,
|
||||
i = 0;
|
||||
|
||||
while (s < this.e) {
|
||||
const added = sorted[i] || this.e,
|
||||
next = +added > +this.e ? this.e : added;
|
||||
results.push(Interval.fromDateTimes(s, next));
|
||||
s = next;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split this Interval into smaller Intervals, each of the specified length.
|
||||
* Left over time is grouped into a smaller interval
|
||||
* @param {Duration|Object|number} duration - The length of each resulting interval.
|
||||
* @return {Array}
|
||||
*/
|
||||
splitBy(duration) {
|
||||
const dur = Duration.fromDurationLike(duration);
|
||||
|
||||
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let { s } = this,
|
||||
idx = 1,
|
||||
next;
|
||||
|
||||
const results = [];
|
||||
while (s < this.e) {
|
||||
const added = this.start.plus(dur.mapUnits((x) => x * idx));
|
||||
next = +added > +this.e ? this.e : added;
|
||||
results.push(Interval.fromDateTimes(s, next));
|
||||
s = next;
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split this Interval into the specified number of smaller intervals.
|
||||
* @param {number} numberOfParts - The number of Intervals to divide the Interval into.
|
||||
* @return {Array}
|
||||
*/
|
||||
divideEqually(numberOfParts) {
|
||||
if (!this.isValid) return [];
|
||||
return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval overlaps with the specified Interval
|
||||
* @param {Interval} other
|
||||
* @return {boolean}
|
||||
*/
|
||||
overlaps(other) {
|
||||
return this.e > other.s && this.s < other.e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval's end is adjacent to the specified Interval's start.
|
||||
* @param {Interval} other
|
||||
* @return {boolean}
|
||||
*/
|
||||
abutsStart(other) {
|
||||
if (!this.isValid) return false;
|
||||
return +this.e === +other.s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval's start is adjacent to the specified Interval's end.
|
||||
* @param {Interval} other
|
||||
* @return {boolean}
|
||||
*/
|
||||
abutsEnd(other) {
|
||||
if (!this.isValid) return false;
|
||||
return +other.e === +this.s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this Interval fully contains the specified Interval, specifically if the intersect (of this Interval and the other Interval) is equal to the other Interval; false otherwise.
|
||||
* @param {Interval} other
|
||||
* @return {boolean}
|
||||
*/
|
||||
engulfs(other) {
|
||||
if (!this.isValid) return false;
|
||||
return this.s <= other.s && this.e >= other.e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Interval has the same start and end as the specified Interval.
|
||||
* @param {Interval} other
|
||||
* @return {boolean}
|
||||
*/
|
||||
equals(other) {
|
||||
if (!this.isValid || !other.isValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.s.equals(other.s) && this.e.equals(other.e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Interval representing the intersection of this Interval and the specified Interval.
|
||||
* Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals.
|
||||
* Returns null if the intersection is empty, meaning, the intervals don't intersect.
|
||||
* @param {Interval} other
|
||||
* @return {Interval}
|
||||
*/
|
||||
intersection(other) {
|
||||
if (!this.isValid) return this;
|
||||
const s = this.s > other.s ? this.s : other.s,
|
||||
e = this.e < other.e ? this.e : other.e;
|
||||
|
||||
if (s >= e) {
|
||||
return null;
|
||||
} else {
|
||||
return Interval.fromDateTimes(s, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Interval representing the union of this Interval and the specified Interval.
|
||||
* Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals.
|
||||
* @param {Interval} other
|
||||
* @return {Interval}
|
||||
*/
|
||||
union(other) {
|
||||
if (!this.isValid) return this;
|
||||
const s = this.s < other.s ? this.s : other.s,
|
||||
e = this.e > other.e ? this.e : other.e;
|
||||
return Interval.fromDateTimes(s, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge an array of Intervals into an equivalent minimal set of Intervals.
|
||||
* Combines overlapping and adjacent Intervals.
|
||||
* The resulting array will contain the Intervals in ascending order, that is, starting with the earliest Interval
|
||||
* and ending with the latest.
|
||||
*
|
||||
* @param {Array} intervals
|
||||
* @return {Array}
|
||||
*/
|
||||
static merge(intervals) {
|
||||
const [found, final] = intervals
|
||||
.sort((a, b) => a.s - b.s)
|
||||
.reduce(
|
||||
([sofar, current], item) => {
|
||||
if (!current) {
|
||||
return [sofar, item];
|
||||
} else if (current.overlaps(item) || current.abutsStart(item)) {
|
||||
return [sofar, current.union(item)];
|
||||
} else {
|
||||
return [sofar.concat([current]), item];
|
||||
}
|
||||
},
|
||||
[[], null]
|
||||
);
|
||||
if (final) {
|
||||
found.push(final);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.
|
||||
* @param {Array} intervals
|
||||
* @return {Array}
|
||||
*/
|
||||
static xor(intervals) {
|
||||
let start = null,
|
||||
currentCount = 0;
|
||||
const results = [],
|
||||
ends = intervals.map((i) => [
|
||||
{ time: i.s, type: "s" },
|
||||
{ time: i.e, type: "e" },
|
||||
]),
|
||||
flattened = Array.prototype.concat(...ends),
|
||||
arr = flattened.sort((a, b) => a.time - b.time);
|
||||
|
||||
for (const i of arr) {
|
||||
currentCount += i.type === "s" ? 1 : -1;
|
||||
|
||||
if (currentCount === 1) {
|
||||
start = i.time;
|
||||
} else {
|
||||
if (start && +start !== +i.time) {
|
||||
results.push(Interval.fromDateTimes(start, i.time));
|
||||
}
|
||||
|
||||
start = null;
|
||||
}
|
||||
}
|
||||
|
||||
return Interval.merge(results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.
|
||||
* @param {...Interval} intervals
|
||||
* @return {Array}
|
||||
*/
|
||||
difference(...intervals) {
|
||||
return Interval.xor([this].concat(intervals))
|
||||
.map((i) => this.intersection(i))
|
||||
.filter((i) => i && !i.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this Interval appropriate for debugging.
|
||||
* @return {string}
|
||||
*/
|
||||
toString() {
|
||||
if (!this.isValid) return INVALID;
|
||||
return `[${this.s.toISO()} – ${this.e.toISO()})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this Interval appropriate for the REPL.
|
||||
* @return {string}
|
||||
*/
|
||||
[Symbol.for("nodejs.util.inspect.custom")]() {
|
||||
if (this.isValid) {
|
||||
return `Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`;
|
||||
} else {
|
||||
return `Interval { Invalid, reason: ${this.invalidReason} }`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a localized string representing this Interval. Accepts the same options as the
|
||||
* Intl.DateTimeFormat constructor and any presets defined by Luxon, such as
|
||||
* {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method
|
||||
* is browser-specific, but in general it will return an appropriate representation of the
|
||||
* Interval in the assigned locale. Defaults to the system's locale if no locale has been
|
||||
* specified.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
||||
* @param {Object} [formatOpts=DateTime.DATE_SHORT] - Either a DateTime preset or
|
||||
* Intl.DateTimeFormat constructor options.
|
||||
* @param {Object} opts - Options to override the configuration of the start DateTime.
|
||||
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022
|
||||
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022
|
||||
* @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022
|
||||
* @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM
|
||||
* @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> Mon, Nov 07, 6:00 – 8:00 p
|
||||
* @return {string}
|
||||
*/
|
||||
toLocaleString(formatOpts = Formats.DATE_SHORT, opts = {}) {
|
||||
return this.isValid
|
||||
? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this)
|
||||
: INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ISO 8601-compliant string representation of this Interval.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
||||
* @param {Object} opts - The same options as {@link DateTime#toISO}
|
||||
* @return {string}
|
||||
*/
|
||||
toISO(opts) {
|
||||
if (!this.isValid) return INVALID;
|
||||
return `${this.s.toISO(opts)}/${this.e.toISO(opts)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ISO 8601-compliant string representation of date of this Interval.
|
||||
* The time components are ignored.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
||||
* @return {string}
|
||||
*/
|
||||
toISODate() {
|
||||
if (!this.isValid) return INVALID;
|
||||
return `${this.s.toISODate()}/${this.e.toISODate()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ISO 8601-compliant string representation of time of this Interval.
|
||||
* The date components are ignored.
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
||||
* @param {Object} opts - The same options as {@link DateTime#toISO}
|
||||
* @return {string}
|
||||
*/
|
||||
toISOTime(opts) {
|
||||
if (!this.isValid) return INVALID;
|
||||
return `${this.s.toISOTime(opts)}/${this.e.toISOTime(opts)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this Interval formatted according to the specified format
|
||||
* string. **You may not want this.** See {@link Interval#toLocaleString} for a more flexible
|
||||
* formatting tool.
|
||||
* @param {string} dateFormat - The format string. This string formats the start and end time.
|
||||
* See {@link DateTime#toFormat} for details.
|
||||
* @param {Object} opts - Options.
|
||||
* @param {string} [opts.separator = ' – '] - A separator to place between the start and end
|
||||
* representations.
|
||||
* @return {string}
|
||||
*/
|
||||
toFormat(dateFormat, { separator = " – " } = {}) {
|
||||
if (!this.isValid) return INVALID;
|
||||
return `${this.s.toFormat(dateFormat)}${separator}${this.e.toFormat(dateFormat)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Duration representing the time spanned by this interval.
|
||||
* @param {string|string[]} [unit=['milliseconds']] - the unit or units (such as 'hours' or 'days') to include in the duration.
|
||||
* @param {Object} opts - options that affect the creation of the Duration
|
||||
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
||||
* @example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 }
|
||||
* @example Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 }
|
||||
* @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 }
|
||||
* @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 }
|
||||
* @example Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 }
|
||||
* @return {Duration}
|
||||
*/
|
||||
toDuration(unit, opts) {
|
||||
if (!this.isValid) {
|
||||
return Duration.invalid(this.invalidReason);
|
||||
}
|
||||
return this.e.diff(this.s, unit, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes
|
||||
* @param {function} mapFn
|
||||
* @return {Interval}
|
||||
* @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC())
|
||||
* @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 }))
|
||||
*/
|
||||
mapEndpoints(mapFn) {
|
||||
return Interval.fromDateTimes(mapFn(this.s), mapFn(this.e));
|
||||
}
|
||||
}
|
||||
26
node_modules/luxon/src/luxon.js
generated
vendored
Normal file
26
node_modules/luxon/src/luxon.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import DateTime from "./datetime.js";
|
||||
import Duration from "./duration.js";
|
||||
import Interval from "./interval.js";
|
||||
import Info from "./info.js";
|
||||
import Zone from "./zone.js";
|
||||
import FixedOffsetZone from "./zones/fixedOffsetZone.js";
|
||||
import IANAZone from "./zones/IANAZone.js";
|
||||
import InvalidZone from "./zones/invalidZone.js";
|
||||
import SystemZone from "./zones/systemZone.js";
|
||||
import Settings from "./settings.js";
|
||||
|
||||
const VERSION = "3.7.2";
|
||||
|
||||
export {
|
||||
VERSION,
|
||||
DateTime,
|
||||
Duration,
|
||||
Interval,
|
||||
Info,
|
||||
Zone,
|
||||
FixedOffsetZone,
|
||||
IANAZone,
|
||||
InvalidZone,
|
||||
SystemZone,
|
||||
Settings,
|
||||
};
|
||||
4
node_modules/luxon/src/package.json
generated
vendored
Normal file
4
node_modules/luxon/src/package.json
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "module",
|
||||
"version": "3.7.2"
|
||||
}
|
||||
180
node_modules/luxon/src/settings.js
generated
vendored
Normal file
180
node_modules/luxon/src/settings.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
import SystemZone from "./zones/systemZone.js";
|
||||
import IANAZone from "./zones/IANAZone.js";
|
||||
import Locale from "./impl/locale.js";
|
||||
import DateTime from "./datetime.js";
|
||||
|
||||
import { normalizeZone } from "./impl/zoneUtil.js";
|
||||
import { validateWeekSettings } from "./impl/util.js";
|
||||
import { resetDigitRegexCache } from "./impl/digits.js";
|
||||
|
||||
let now = () => Date.now(),
|
||||
defaultZone = "system",
|
||||
defaultLocale = null,
|
||||
defaultNumberingSystem = null,
|
||||
defaultOutputCalendar = null,
|
||||
twoDigitCutoffYear = 60,
|
||||
throwOnInvalid,
|
||||
defaultWeekSettings = null;
|
||||
|
||||
/**
|
||||
* Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here.
|
||||
*/
|
||||
export default class Settings {
|
||||
/**
|
||||
* Get the callback for returning the current timestamp.
|
||||
* @type {function}
|
||||
*/
|
||||
static get now() {
|
||||
return now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback for returning the current timestamp.
|
||||
* The function should return a number, which will be interpreted as an Epoch millisecond count
|
||||
* @type {function}
|
||||
* @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
|
||||
* @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
|
||||
*/
|
||||
static set now(n) {
|
||||
now = n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default time zone to create DateTimes in. Does not affect existing instances.
|
||||
* Use the value "system" to reset this value to the system's time zone.
|
||||
* @type {string}
|
||||
*/
|
||||
static set defaultZone(zone) {
|
||||
defaultZone = zone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default time zone object currently used to create DateTimes. Does not affect existing instances.
|
||||
* The default value is the system's time zone (the one set on the machine that runs this code).
|
||||
* @type {Zone}
|
||||
*/
|
||||
static get defaultZone() {
|
||||
return normalizeZone(defaultZone, SystemZone.instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default locale to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static get defaultLocale() {
|
||||
return defaultLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default locale to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static set defaultLocale(locale) {
|
||||
defaultLocale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default numbering system to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static get defaultNumberingSystem() {
|
||||
return defaultNumberingSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default numbering system to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static set defaultNumberingSystem(numberingSystem) {
|
||||
defaultNumberingSystem = numberingSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default output calendar to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static get defaultOutputCalendar() {
|
||||
return defaultOutputCalendar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default output calendar to create DateTimes with. Does not affect existing instances.
|
||||
* @type {string}
|
||||
*/
|
||||
static set defaultOutputCalendar(outputCalendar) {
|
||||
defaultOutputCalendar = outputCalendar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} WeekSettings
|
||||
* @property {number} firstDay
|
||||
* @property {number} minimalDays
|
||||
* @property {number[]} weekend
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return {WeekSettings|null}
|
||||
*/
|
||||
static get defaultWeekSettings() {
|
||||
return defaultWeekSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding the default locale week settings, i.e. the start of the week, the weekend and
|
||||
* how many days are required in the first week of a year.
|
||||
* Does not affect existing instances.
|
||||
*
|
||||
* @param {WeekSettings|null} weekSettings
|
||||
*/
|
||||
static set defaultWeekSettings(weekSettings) {
|
||||
defaultWeekSettings = validateWeekSettings(weekSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cutoff year for whether a 2-digit year string is interpreted in the current or previous century. Numbers higher than the cutoff will be considered to mean 19xx and numbers lower or equal to the cutoff will be considered 20xx.
|
||||
* @type {number}
|
||||
*/
|
||||
static get twoDigitCutoffYear() {
|
||||
return twoDigitCutoffYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cutoff year for whether a 2-digit year string is interpreted in the current or previous century. Numbers higher than the cutoff will be considered to mean 19xx and numbers lower or equal to the cutoff will be considered 20xx.
|
||||
* @type {number}
|
||||
* @example Settings.twoDigitCutoffYear = 0 // all 'yy' are interpreted as 20th century
|
||||
* @example Settings.twoDigitCutoffYear = 99 // all 'yy' are interpreted as 21st century
|
||||
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 2049; '50' -> 1950
|
||||
* @example Settings.twoDigitCutoffYear = 1950 // interpreted as 50
|
||||
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpreted as 50
|
||||
*/
|
||||
static set twoDigitCutoffYear(cutoffYear) {
|
||||
twoDigitCutoffYear = cutoffYear % 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
||||
* @type {boolean}
|
||||
*/
|
||||
static get throwOnInvalid() {
|
||||
return throwOnInvalid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
|
||||
* @type {boolean}
|
||||
*/
|
||||
static set throwOnInvalid(t) {
|
||||
throwOnInvalid = t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset Luxon's global caches. Should only be necessary in testing scenarios.
|
||||
* @return {void}
|
||||
*/
|
||||
static resetCaches() {
|
||||
Locale.resetCache();
|
||||
IANAZone.resetCache();
|
||||
DateTime.resetCache();
|
||||
resetDigitRegexCache();
|
||||
}
|
||||
}
|
||||
97
node_modules/luxon/src/zone.js
generated
vendored
Normal file
97
node_modules/luxon/src/zone.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { ZoneIsAbstractError } from "./errors.js";
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
export default class Zone {
|
||||
/**
|
||||
* The type of zone
|
||||
* @abstract
|
||||
* @type {string}
|
||||
*/
|
||||
get type() {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this zone.
|
||||
* @abstract
|
||||
* @type {string}
|
||||
*/
|
||||
get name() {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* The IANA name of this zone.
|
||||
* Defaults to `name` if not overwritten by a subclass.
|
||||
* @abstract
|
||||
* @type {string}
|
||||
*/
|
||||
get ianaName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the offset is known to be fixed for the whole year.
|
||||
* @abstract
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isUniversal() {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset's common name (such as EST) at the specified timestamp
|
||||
* @abstract
|
||||
* @param {number} ts - Epoch milliseconds for which to get the name
|
||||
* @param {Object} opts - Options to affect the format
|
||||
* @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
|
||||
* @param {string} opts.locale - What locale to return the offset name in.
|
||||
* @return {string}
|
||||
*/
|
||||
offsetName(ts, opts) {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset's value as a string
|
||||
* @abstract
|
||||
* @param {number} ts - Epoch milliseconds for which to get the offset
|
||||
* @param {string} format - What style of offset to return.
|
||||
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
||||
* @return {string}
|
||||
*/
|
||||
formatOffset(ts, format) {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the offset in minutes for this zone at the specified timestamp.
|
||||
* @abstract
|
||||
* @param {number} ts - Epoch milliseconds for which to compute the offset
|
||||
* @return {number}
|
||||
*/
|
||||
offset(ts) {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Zone is equal to another zone
|
||||
* @abstract
|
||||
* @param {Zone} otherZone - the zone to compare
|
||||
* @return {boolean}
|
||||
*/
|
||||
equals(otherZone) {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this Zone is valid.
|
||||
* @abstract
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isValid() {
|
||||
throw new ZoneIsAbstractError();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user