mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 06:40:20 +03:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19efa59aa9 | ||
|
|
bb6995320c | ||
|
|
f9cc935f14 | ||
|
|
9501a60dc0 |
No files matched your search
Vendored
+4
-12
@@ -37,6 +37,7 @@ declare module '@vue/runtime-core' {
|
||||
'CFileUpload.demo': typeof import('./src/ui/c-file-upload/c-file-upload.demo.vue')['default']
|
||||
ChmodCalculator: typeof import('./src/tools/chmod-calculator/chmod-calculator.vue')['default']
|
||||
Chronometer: typeof import('./src/tools/chronometer/chronometer.vue')['default']
|
||||
CidrInCidr: typeof import('./src/tools/cidr-in-cidr/cidr-in-cidr.vue')['default']
|
||||
CInputText: typeof import('./src/ui/c-input-text/c-input-text.vue')['default']
|
||||
'CInputText.demo': typeof import('./src/ui/c-input-text/c-input-text.demo.vue')['default']
|
||||
CKeyValueList: typeof import('./src/ui/c-key-value-list/c-key-value-list.vue')['default']
|
||||
@@ -64,15 +65,12 @@ declare module '@vue/runtime-core' {
|
||||
'CTextCopyable.demo': typeof import('./src/ui/c-text-copyable/c-text-copyable.demo.vue')['default']
|
||||
CTooltip: typeof import('./src/ui/c-tooltip/c-tooltip.vue')['default']
|
||||
'CTooltip.demo': typeof import('./src/ui/c-tooltip/c-tooltip.demo.vue')['default']
|
||||
DateDurationCalculator: typeof import('./src/tools/date-duration-calculator/date-duration-calculator.vue')['default']
|
||||
DateTimeConverter: typeof import('./src/tools/date-time-converter/date-time-converter.vue')['default']
|
||||
DaysCalculator: typeof import('./src/tools/days-calculator/days-calculator.vue')['default']
|
||||
'DemoHome.page': typeof import('./src/ui/demo/demo-home.page.vue')['default']
|
||||
DemoWrapper: typeof import('./src/ui/demo/demo-wrapper.vue')['default']
|
||||
DeviceInformation: typeof import('./src/tools/device-information/device-information.vue')['default']
|
||||
DiffViewer: typeof import('./src/tools/json-diff/diff-viewer/diff-viewer.vue')['default']
|
||||
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
||||
DurationCalculator: typeof import('./src/tools/duration-calculator/duration-calculator.vue')['default']
|
||||
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
||||
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
|
||||
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
|
||||
@@ -106,6 +104,7 @@ declare module '@vue/runtime-core' {
|
||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
||||
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
|
||||
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
|
||||
IpInRange: typeof import('./src/tools/cidr-in-cidr/cidr-in-cidr.vue')['default']
|
||||
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
|
||||
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
|
||||
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
|
||||
@@ -133,25 +132,17 @@ declare module '@vue/runtime-core' {
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NP: typeof import('naive-ui')['NP']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
@@ -170,6 +161,7 @@ declare module '@vue/runtime-core' {
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
|
||||
|
||||
+5
-11
@@ -25,10 +25,10 @@
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && NODE_OPTIONS=--max_old_space_size=4096 vite build",
|
||||
"preview": "vite preview --port 5050",
|
||||
"test": "TZ=UTC npm run test:unit",
|
||||
"test:unit": "TZ=UTC vitest --environment jsdom",
|
||||
"test:e2e": "TZ=UTC playwright test",
|
||||
"test:e2e:dev": "TZ=UTC BASE_URL=http://localhost:5173 NO_WEB_SERVER=true playwright test",
|
||||
"test": "npm run test:unit",
|
||||
"test:unit": "vitest --environment jsdom",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:dev": "BASE_URL=http://localhost:5173 NO_WEB_SERVER=true playwright test",
|
||||
"coverage": "vitest run --coverage",
|
||||
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
||||
"lint": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
|
||||
@@ -46,7 +46,6 @@
|
||||
"@tiptap/starter-kit": "2.1.6",
|
||||
"@tiptap/vue-3": "2.0.3",
|
||||
"@types/figlet": "^1.5.8",
|
||||
"@types/luxon": "^3.4.2",
|
||||
"@types/markdown-it": "^13.0.7",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vicons/tabler": "^0.12.0",
|
||||
@@ -57,15 +56,12 @@
|
||||
"change-case": "^4.1.2",
|
||||
"colord": "^2.9.3",
|
||||
"composerize-ts": "^0.6.2",
|
||||
"countries-and-timezones": "^3.7.2",
|
||||
"country-code-lookup": "^0.1.0",
|
||||
"cron-validator": "^1.3.1",
|
||||
"cronstrue": "^2.26.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"date-holidays": "^3.23.12",
|
||||
"dompurify": "^3.0.6",
|
||||
"duration-fns": "^3.0.2",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
"figlet": "^1.7.0",
|
||||
@@ -74,12 +70,12 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
"luxon": "^3.5.0",
|
||||
"markdown-it": "^14.0.0",
|
||||
"marked": "^10.0.0",
|
||||
"mathjs": "^11.9.1",
|
||||
@@ -89,11 +85,9 @@
|
||||
"netmask": "^2.0.2",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"parse-duration": "^1.1.0",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"pretty-ms": "^9.1.0",
|
||||
"qrcode": "^1.5.1",
|
||||
"randexp": "^0.5.3",
|
||||
"sql-formatter": "^13.0.0",
|
||||
|
||||
Generated
+134
-253
@@ -19,7 +19,7 @@ dependencies:
|
||||
version: 2.2.1
|
||||
'@tabler/icons-vue':
|
||||
specifier: ^3.20.0
|
||||
version: 3.26.0(vue@3.3.4)
|
||||
version: 3.28.1(vue@3.3.4)
|
||||
'@tiptap/pm':
|
||||
specifier: 2.1.6
|
||||
version: 2.1.6
|
||||
@@ -32,9 +32,6 @@ dependencies:
|
||||
'@types/figlet':
|
||||
specifier: ^1.5.8
|
||||
version: 1.5.8
|
||||
'@types/luxon':
|
||||
specifier: ^3.4.2
|
||||
version: 3.4.2
|
||||
'@types/markdown-it':
|
||||
specifier: ^13.0.7
|
||||
version: 13.0.9
|
||||
@@ -65,9 +62,6 @@ dependencies:
|
||||
composerize-ts:
|
||||
specifier: ^0.6.2
|
||||
version: 0.6.2
|
||||
countries-and-timezones:
|
||||
specifier: ^3.7.2
|
||||
version: 3.7.2
|
||||
country-code-lookup:
|
||||
specifier: ^0.1.0
|
||||
version: 0.1.0
|
||||
@@ -83,15 +77,9 @@ dependencies:
|
||||
date-fns:
|
||||
specifier: ^2.29.3
|
||||
version: 2.29.3
|
||||
date-holidays:
|
||||
specifier: ^3.23.12
|
||||
version: 3.23.12
|
||||
dompurify:
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6
|
||||
duration-fns:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2
|
||||
email-normalizer:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
@@ -116,6 +104,9 @@ dependencies:
|
||||
ibantools:
|
||||
specifier: ^4.3.3
|
||||
version: 4.3.3
|
||||
ip-matching:
|
||||
specifier: ^2.1.2
|
||||
version: 2.1.2
|
||||
js-base64:
|
||||
specifier: ^3.7.6
|
||||
version: 3.7.7
|
||||
@@ -131,9 +122,6 @@ dependencies:
|
||||
lodash:
|
||||
specifier: ^4.17.21
|
||||
version: 4.17.21
|
||||
luxon:
|
||||
specifier: ^3.5.0
|
||||
version: 3.5.0
|
||||
markdown-it:
|
||||
specifier: ^14.0.0
|
||||
version: 14.1.0
|
||||
@@ -161,9 +149,6 @@ dependencies:
|
||||
oui-data:
|
||||
specifier: ^1.0.10
|
||||
version: 1.0.10
|
||||
parse-duration:
|
||||
specifier: ^1.1.0
|
||||
version: 1.1.0
|
||||
pdf-signature-reader:
|
||||
specifier: ^1.4.2
|
||||
version: 1.4.2
|
||||
@@ -173,9 +158,6 @@ dependencies:
|
||||
plausible-tracker:
|
||||
specifier: ^0.3.8
|
||||
version: 0.3.8
|
||||
pretty-ms:
|
||||
specifier: ^9.1.0
|
||||
version: 9.1.0
|
||||
qrcode:
|
||||
specifier: ^1.5.1
|
||||
version: 1.5.1
|
||||
@@ -327,10 +309,10 @@ devDependencies:
|
||||
version: 5.2.2
|
||||
unocss:
|
||||
specifier: ^0.65.1
|
||||
version: 0.65.3(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
version: 0.65.4(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
unocss-preset-scrollbar:
|
||||
specifier: ^0.2.1
|
||||
version: 0.2.1(unocss@0.65.3)
|
||||
version: 0.2.1(unocss@0.65.4)
|
||||
unplugin-icons:
|
||||
specifier: ^0.17.0
|
||||
version: 0.17.0(@vue/compiler-sfc@3.2.47)
|
||||
@@ -988,12 +970,12 @@ packages:
|
||||
dependencies:
|
||||
'@babel/types': 7.23.0
|
||||
|
||||
/@babel/parser@7.26.3:
|
||||
resolution: {integrity: sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==}
|
||||
/@babel/parser@7.26.5:
|
||||
resolution: {integrity: sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@babel/types': 7.26.3
|
||||
'@babel/types': 7.26.5
|
||||
dev: false
|
||||
|
||||
/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.22.15(@babel/core@7.23.2):
|
||||
@@ -1983,8 +1965,8 @@ packages:
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
to-fast-properties: 2.0.0
|
||||
|
||||
/@babel/types@7.26.3:
|
||||
resolution: {integrity: sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==}
|
||||
/@babel/types@7.26.5:
|
||||
resolution: {integrity: sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
dependencies:
|
||||
'@babel/helper-string-parser': 7.25.9
|
||||
@@ -3207,17 +3189,17 @@ packages:
|
||||
resolution: {integrity: sha512-BjJ/7vWNowlX3Z8O4ywT58DqbNRyYlkk6Yz/D13aB7hGmfQTvGX4Tkgtm/ApYlu9M7lCQi15xUEidqMUmdMYwg==}
|
||||
dev: false
|
||||
|
||||
/@tabler/icons-vue@3.26.0(vue@3.3.4):
|
||||
resolution: {integrity: sha512-jsZxEfiJSB+HtNpk4+RXMXV8aA8dedJ9+VhQnhNAiYH1dq/TQoSdlvL/707sTiG8NfVKixTNHasjm6MiiDS1Bw==}
|
||||
/@tabler/icons-vue@3.28.1(vue@3.3.4):
|
||||
resolution: {integrity: sha512-tYu1iIyNTGUn2LZ8Rrn3BjO5lYtXQOTqbm3Z3wocMqNRa4eyfUhsjCyH6F8zJQO85YgPXhl6oWFc9HElC9ctKQ==}
|
||||
peerDependencies:
|
||||
vue: '>=3.0.1'
|
||||
dependencies:
|
||||
'@tabler/icons': 3.26.0
|
||||
'@tabler/icons': 3.28.1
|
||||
vue: 3.3.4
|
||||
dev: false
|
||||
|
||||
/@tabler/icons@3.26.0:
|
||||
resolution: {integrity: sha512-oO3D4ss+DxzxqU1aDy0f1HmToyrO0gcQWIMpzHAfV1quPUx0BZYvNm5xz1DQb4DxNm/+xNvbBGLJy4pzTLYWag==}
|
||||
/@tabler/icons@3.28.1:
|
||||
resolution: {integrity: sha512-h7nqKEvFooLtFxhMOC1/2eiV+KRXhBUuDUUJrJlt6Ft6tuMw2eU/9GLQgrTk41DNmIEzp/LI83K9J9UUU8YBYQ==}
|
||||
dev: false
|
||||
|
||||
/@tiptap/core@2.1.12(@tiptap/pm@2.1.6):
|
||||
@@ -3563,10 +3545,6 @@ packages:
|
||||
resolution: {integrity: sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==}
|
||||
dev: false
|
||||
|
||||
/@types/luxon@3.4.2:
|
||||
resolution: {integrity: sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==}
|
||||
dev: false
|
||||
|
||||
/@types/markdown-it@12.2.3:
|
||||
resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==}
|
||||
dependencies:
|
||||
@@ -3966,24 +3944,24 @@ packages:
|
||||
dependencies:
|
||||
'@unhead/dom': 0.5.1
|
||||
'@unhead/schema': 0.5.1
|
||||
'@vueuse/shared': 12.2.0(typescript@5.2.2)
|
||||
'@vueuse/shared': 12.4.0(typescript@5.2.2)
|
||||
unhead: 0.5.1
|
||||
vue: 3.3.4
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
/@unocss/astro@0.65.3(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-shEKzsYOz1KMO36jzoNzTltzaUkQOe+UHgiRpsGE28ldSymGfOfiJQzG9T4+Q3Ckk0C86UyVP3Uerxx1qoYwAA==}
|
||||
/@unocss/astro@0.65.4(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-ex1CJOQ6yeftBEPcbA9/W47/YoV+mhQnrAoc8MA1VVrvvFKDitICFU62+nSt3NWRe53XL/fXnQbcbCb8AAgKlA==}
|
||||
peerDependencies:
|
||||
vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0
|
||||
peerDependenciesMeta:
|
||||
vite:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/reset': 0.65.3
|
||||
'@unocss/vite': 0.65.3(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/reset': 0.65.4
|
||||
'@unocss/vite': 0.65.4(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
vite: 4.4.9(@types/node@18.15.11)(less@4.1.3)
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
@@ -3991,16 +3969,16 @@ packages:
|
||||
- vue
|
||||
dev: true
|
||||
|
||||
/@unocss/cli@0.65.3(rollup@2.79.1):
|
||||
resolution: {integrity: sha512-VIV6/aLJ0mWOJ8/iK7nWVCR6G/hM/6W7EGSO1gpLHWn4Rj+T6NtCmk/U4nao9pTYg/nVBBBCL3ydRguF3DA0ow==}
|
||||
/@unocss/cli@0.65.4(rollup@2.79.1):
|
||||
resolution: {integrity: sha512-D/4hY5Hezh3QETscl4i+ojb+q8YU9Cl9AYJ8v3gsjc/GjTmEuIOD5V4x+/aN25vY5wjqgoApOgaIDGCV3b+2Ig==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@rollup/pluginutils': 5.1.4(rollup@2.79.1)
|
||||
'@unocss/config': 0.65.3
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/preset-uno': 0.65.3
|
||||
'@unocss/config': 0.65.4
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/preset-uno': 0.65.4
|
||||
cac: 6.7.14
|
||||
chokidar: 3.6.0
|
||||
colorette: 2.0.20
|
||||
@@ -4022,11 +4000,11 @@ packages:
|
||||
unconfig: 0.3.11
|
||||
dev: true
|
||||
|
||||
/@unocss/config@0.65.3:
|
||||
resolution: {integrity: sha512-H+UpEPo47DeEsLbjHMby42MJ+lx7vXltFOdpgXFKutLkT034VoXmN1lgrAh9lZ4ow3iuUfEatHyuWffpOQf9gA==}
|
||||
/@unocss/config@0.65.4:
|
||||
resolution: {integrity: sha512-/vCt4AXnJ4p4Ow6xqsYwdrelF9533yhZjzkg3SQmL3rKeSkicPayKpeq8nkYECdhDI03VTCVD+6oh5Y/26Hg7A==}
|
||||
engines: {node: '>=14'}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
unconfig: 0.6.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -4040,8 +4018,8 @@ packages:
|
||||
resolution: {integrity: sha512-cqQW/4gCuk+bFMPg9lBanuRNQ9Lx1l4PpMN/6uKxI5WROpq7ce/Xb4uGvAxKLh3ITtFSpXs2cLfsy7QD6cVD/Q==}
|
||||
dev: true
|
||||
|
||||
/@unocss/core@0.65.3:
|
||||
resolution: {integrity: sha512-xYkJ63lIadL6KqvGcaE2fFeLvo6rC1F+e+R9EFn0Aj0ArMRhiltZk8vvLFHP7iYjjdTdqDkAr/7IdrTosTo8Pg==}
|
||||
/@unocss/core@0.65.4:
|
||||
resolution: {integrity: sha512-a2JOoFutrhqd5RgPhIR5FIXrDoHDU3gwCbPrpT6KYTjsqlSc/fv02yZ+JGOZFN3MCFhCmaPTs+idDFtwb3xU8g==}
|
||||
dev: true
|
||||
|
||||
/@unocss/eslint-config@0.57.1(eslint@8.47.0)(typescript@5.2.2):
|
||||
@@ -4070,17 +4048,18 @@ packages:
|
||||
- typescript
|
||||
dev: true
|
||||
|
||||
/@unocss/extractor-arbitrary-variants@0.65.3:
|
||||
resolution: {integrity: sha512-ZVGCjOZuU8daGxY7MUJQrI7aVKzZi1llRk53QgEUTU1q60X/fi8M2+A9mwEgG9MBVHBdsuvxqZ9Dp79IktSyLw==}
|
||||
/@unocss/extractor-arbitrary-variants@0.65.4:
|
||||
resolution: {integrity: sha512-GbvTgsDaHplfWfsQtOY8RrvEZvptmvR9k9NwQ5NsZBNIG1JepYVel93CVQvsxT5KioKcoWngXxTYLNOGyxLs0g==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/inspector@0.65.3(vue@3.3.4):
|
||||
resolution: {integrity: sha512-medDlG0FsCvKBBprC5FZxYrWTLV+iNSnc8S84VI4J/iKZQ43X34Edy+Rudy+YsPXQ8qZcuYQ7RDSHsPnP6X+Bg==}
|
||||
/@unocss/inspector@0.65.4(vue@3.3.4):
|
||||
resolution: {integrity: sha512-byg9x549Ul17U4Ety7ufDwC0UOygypoq4QnLEPzhlZ0KJG1f7WmXKYanOhupeg3h4qCj6Nc/xdZYMGbHl9QRIg==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
colorette: 2.0.20
|
||||
gzip-size: 6.0.0
|
||||
sirv: 3.0.0
|
||||
vue-flow-layout: 0.1.1(vue@3.3.4)
|
||||
@@ -4088,15 +4067,15 @@ packages:
|
||||
- vue
|
||||
dev: true
|
||||
|
||||
/@unocss/postcss@0.65.3(postcss@8.4.31):
|
||||
resolution: {integrity: sha512-WCAycMhigioWn8IV3w3ptsstvRvEW86vHpELOMSXKcbminaOJ7RkfpoCKwfSzL73CBSYwovVCWS/y4LFP85NQQ==}
|
||||
/@unocss/postcss@0.65.4(postcss@8.4.31):
|
||||
resolution: {integrity: sha512-8peDRo0+rNQsnKh/H2uZEVy67sV2cC16rAeSLpgbVJUMNfZlmF0rC2DNGsOV17uconUXSwz7+mGcHKNiv+8YlQ==}
|
||||
engines: {node: '>=14'}
|
||||
peerDependencies:
|
||||
postcss: ^8.4.21
|
||||
dependencies:
|
||||
'@unocss/config': 0.65.3
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/config': 0.65.4
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
css-tree: 3.1.0
|
||||
postcss: 8.4.31
|
||||
tinyglobby: 0.2.10
|
||||
@@ -4104,17 +4083,17 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-attributify@0.65.3:
|
||||
resolution: {integrity: sha512-0nDKoR8x32ul1Ne7BbJqzAq5D1RM0C7+DTiLxhWonjCcZwCQpas/npTU6wvwQhc5ksuON0xtoQyl4a6zLNA5Vg==}
|
||||
/@unocss/preset-attributify@0.65.4:
|
||||
resolution: {integrity: sha512-zxE9hJJ5b37phjdzDdZsxX559ZlmH9rFlY5LVEcQySTnsfY0znviHxPbD2iRpCBCRd+YC5HfFd2jb3XlnTKMJQ==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-icons@0.65.3:
|
||||
resolution: {integrity: sha512-3V4d5M+a2mTGnLjSsXyNL+/+nzjasdsJEJdXarLnj9Ez0KaBCvi32OjyoYrZUSMC5GCSreVNUOVBZKcxfdtitA==}
|
||||
/@unocss/preset-icons@0.65.4:
|
||||
resolution: {integrity: sha512-5sSzTN72X2Ag3VH48xY1pYudeWnql9jqdMiwgZuLJcmvETBNGelXy2wGxm7tsUUEx/l40Yr04Ck8XRPGT9jLBw==}
|
||||
dependencies:
|
||||
'@iconify/utils': 2.2.1
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
ofetch: 1.4.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -4126,99 +4105,99 @@ packages:
|
||||
'@unocss/core': 0.31.17
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-mini@0.65.3:
|
||||
resolution: {integrity: sha512-HG7mRfq0S2VKkw40duumoyIYaMBQGW1Uxb+Kw8HLGvoamnDmOZKb+TOXxys17Z5Z0vloi2CN1qqyJhYC0G6MSg==}
|
||||
/@unocss/preset-mini@0.65.4:
|
||||
resolution: {integrity: sha512-dcO2PzSl87qN1KdQWcfZDIKEhpdFeImWbYfiXtE7k6pi1393FJkdHEopgI/1ZciIQN1CkTvQJ5c7EpEVWftYRA==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/extractor-arbitrary-variants': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/extractor-arbitrary-variants': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-tagify@0.65.3:
|
||||
resolution: {integrity: sha512-IWRQ/CO+KmspIBPq6pNfYQmUzZkMqTa/Cr7fB4R+ZQFIe9OO3Cpj18R5VL3qujVC+dePiAFiP/tVLt6/mCQzuw==}
|
||||
/@unocss/preset-tagify@0.65.4:
|
||||
resolution: {integrity: sha512-qll6koqdFEkvmz594vKnxj9+3nfM3ugkJxYHrTkqtwx7DAnTgtM8fInFFGZelvjwUzR3o3+Zw6uMhFkLTVTfvg==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-typography@0.65.3:
|
||||
resolution: {integrity: sha512-PYcVU1uYGJRuj8FqHVUaRYS15X/+m58v2uUXW+qoqv9jh3KGabu3yPac1UILHTtdE3Y6PSflf3Hf9M9MqxAgog==}
|
||||
/@unocss/preset-typography@0.65.4:
|
||||
resolution: {integrity: sha512-Dl940ATrviWD9Vh+4fcN0QZXb6wA7al+c7QkdVAzW7I+NtdN2ELvLcN0cY22KnLRpwztzmg52Qp2J/1QnqrLTw==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/preset-mini': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/preset-mini': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-uno@0.65.3:
|
||||
resolution: {integrity: sha512-1O9qVAG/W7t4X9VExuUPGGy+4n8yxfpuQ3NeFgXlEkT1Mi3cokS0Eb0quvttgLGbjQ2waoS4MWbGyMmDGHWnYQ==}
|
||||
/@unocss/preset-uno@0.65.4:
|
||||
resolution: {integrity: sha512-56bdBtf476i+soQCQmT36uGzcF2z+7DGCnG1hwWiw6XAbL6gmRMQsubwi1c8z8TcTQNBsOFUnOziFil0gbWufw==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/preset-mini': 0.65.3
|
||||
'@unocss/preset-wind': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/preset-mini': 0.65.4
|
||||
'@unocss/preset-wind': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-web-fonts@0.65.3:
|
||||
resolution: {integrity: sha512-hDuDbZawPc7ebtNoYI5zKpqURjAH5lLKqVRwdQXQiJ2T8IfT246HkL6+pcpdjAkHy3oJDUxGwrD/tYFcu9fcdA==}
|
||||
/@unocss/preset-web-fonts@0.65.4:
|
||||
resolution: {integrity: sha512-UB/MvXHUTqMNVH1bbiKZ/ZtZUI5tsYlTYAvBrnXPO1Cztuwr8hJKSi4RCfI9g+YYtKHX4uYuxUbW5bcN85gmBQ==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
ofetch: 1.4.1
|
||||
dev: true
|
||||
|
||||
/@unocss/preset-wind@0.65.3:
|
||||
resolution: {integrity: sha512-esptoeJEN1QZEXwMIU3OXumSi3TEbIXZg1SuuUYqOWXzldxANsfXSMdHtsiXUSMNwNsfmQl4XfBlGNYYK/7eyg==}
|
||||
/@unocss/preset-wind@0.65.4:
|
||||
resolution: {integrity: sha512-0rbNbw5E8Lvh2yf4R1Mq+lxI/wL5Tm6+r+crE0uAAhCPe9kxPHW4k+x1cWKDIwq6Vudlm3cNX85N49wN5tYgdA==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/preset-mini': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/preset-mini': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/reset@0.65.3:
|
||||
resolution: {integrity: sha512-elwdQJ6tF4IpVUv7euK8MOKXTcQMeImsimaCViqe0yL0onPChgK16qs5xgVbBGrj9B57bmWgoUp0af/J03oNYA==}
|
||||
/@unocss/reset@0.65.4:
|
||||
resolution: {integrity: sha512-m685H0KFvVMz6R2i5GDIFv4RS9Z7y2G8hJK7xg2OWli+7w8l2ZMihYvXKofPsst4q/ms8EgKXpWc/qqUOTucvA==}
|
||||
dev: true
|
||||
|
||||
/@unocss/rule-utils@0.65.3:
|
||||
resolution: {integrity: sha512-jndyth0X11FbvIDForYq90b+N5xsR31FRsmvp7AC7dcW71clemUEDHCwqzSJn8cVFwahgvlwWbEoYHPEgQrtIQ==}
|
||||
/@unocss/rule-utils@0.65.4:
|
||||
resolution: {integrity: sha512-+EzdJEWcqGcO6HwbBTe7vEdBRpuKkBiz4MycQeLD6GEio04T45y6VHHO7/WTqxltbO4YwwW9/s2TKRMxKtoG8g==}
|
||||
engines: {node: '>=14'}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
magic-string: 0.30.17
|
||||
dev: true
|
||||
|
||||
/@unocss/transformer-attributify-jsx@0.65.3:
|
||||
resolution: {integrity: sha512-mfPpsqdpig2Jgd9BDL79XP1VpDslndSLVEr/xzV1LQOL4FVLe8IIiO6hqeeUNVuV99wxCa8QAigbI2vbUi5p+Q==}
|
||||
/@unocss/transformer-attributify-jsx@0.65.4:
|
||||
resolution: {integrity: sha512-n438EzWdTKlLCOlAUSpFjmH6FflctqzIReMzMZSJDkmkorymc+C5GpjN3Nty2cKRJXIl6Vwq0oxPuB59RT+FIw==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/transformer-compile-class@0.65.3:
|
||||
resolution: {integrity: sha512-cndbJUYqOACeFvldCAVd8edD56XcufFCAwbCm4uio1DjwpqJmtoaJHnLlrE2Pytleej1IAhDuoyaJAnSU9hIDA==}
|
||||
/@unocss/transformer-compile-class@0.65.4:
|
||||
resolution: {integrity: sha512-n1yHDC/iIbcj/9fBUTXkSoASKfLBuRoCN7P1a0ecPc8Gu+uOGfoxafOhrlqC+tpD3hlQGoL+0h74BHSKh+L23Q==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/transformer-directives@0.65.3:
|
||||
resolution: {integrity: sha512-Jn2b9NSzbp+X5YLY1MWJzXY6dMUYhAuE+xjdiwFNACdbSvnjV+WLX1rOFeeNZx0rP2e5sPeDsv7MTF71uZeohg==}
|
||||
/@unocss/transformer-directives@0.65.4:
|
||||
resolution: {integrity: sha512-zkoDEwzPkgXi6ohW7P11gbArwfTRMZ9knYSUYoPEltQz+UZYzeRQ85exiAmdz5MsbCAuhQEr577Kd/CWfhjEuA==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/rule-utils': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/rule-utils': 0.65.4
|
||||
css-tree: 3.1.0
|
||||
dev: true
|
||||
|
||||
/@unocss/transformer-variant-group@0.65.3:
|
||||
resolution: {integrity: sha512-l18P2lyELe6AiRYr9cPbctRn+ITUgncPqhetH46ZoGHKrVR7MSFYHSo0gUJBusBYJisNHTjhaQvNQcDGD3BPWQ==}
|
||||
/@unocss/transformer-variant-group@0.65.4:
|
||||
resolution: {integrity: sha512-ggO6xMGeOeoD5GHS2xXBJrYFuzqyiZ25tM0zHAMJn9QU9GIu1NwWvcXluvLCF/MRIygBJGPpAE98aEICI6ifEA==}
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/core': 0.65.4
|
||||
dev: true
|
||||
|
||||
/@unocss/vite@0.65.3(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-GMJ9Aj3M1L/m5CiHbMpOJ9WEfF+c+13Q6zW22n+iz5CYhqXAwyDrtV2afpFBF3w5PLUHC4aW3C4nNQTUTUuPeA==}
|
||||
/@unocss/vite@0.65.4(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-02pRcVLfb5UUxMJwudnjS/0ZQdSlskjuXVHdpZpLBZCA8hhoru2uEOsPbUOBRNNMjDj6ld00pmgk/+im07M35Q==}
|
||||
peerDependencies:
|
||||
vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@rollup/pluginutils': 5.1.4(rollup@2.79.1)
|
||||
'@unocss/config': 0.65.3
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/inspector': 0.65.3(vue@3.3.4)
|
||||
'@unocss/config': 0.65.4
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/inspector': 0.65.4(vue@3.3.4)
|
||||
chokidar: 3.6.0
|
||||
magic-string: 0.30.17
|
||||
tinyglobby: 0.2.10
|
||||
@@ -4374,7 +4353,7 @@ packages:
|
||||
/@vue/compiler-core@3.5.13:
|
||||
resolution: {integrity: sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==}
|
||||
dependencies:
|
||||
'@babel/parser': 7.26.3
|
||||
'@babel/parser': 7.26.5
|
||||
'@vue/shared': 3.5.13
|
||||
entities: 4.5.0
|
||||
estree-walker: 2.0.2
|
||||
@@ -4441,7 +4420,7 @@ packages:
|
||||
/@vue/compiler-sfc@3.5.13:
|
||||
resolution: {integrity: sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==}
|
||||
dependencies:
|
||||
'@babel/parser': 7.26.3
|
||||
'@babel/parser': 7.26.5
|
||||
'@vue/compiler-core': 3.5.13
|
||||
'@vue/compiler-dom': 3.5.13
|
||||
'@vue/compiler-ssr': 3.5.13
|
||||
@@ -4694,8 +4673,8 @@ packages:
|
||||
- vue
|
||||
dev: false
|
||||
|
||||
/@vueuse/shared@12.2.0(typescript@5.2.2):
|
||||
resolution: {integrity: sha512-SRr4AZwv/giS+EmyA1ZIzn3/iALjjnWAGaBNmoDTMEob9JwQaevAocuaMDnPAvU7Z35Y5g3CFRusCWgp1gVJ3Q==}
|
||||
/@vueuse/shared@12.4.0(typescript@5.2.2):
|
||||
resolution: {integrity: sha512-9yLgbHVIF12OSCojnjTIoZL1+UA10+O4E1aD6Hpfo/DKVm5o3SZIwz6CupqGy3+IcKI8d6Jnl26EQj/YucnW0Q==}
|
||||
dependencies:
|
||||
vue: 3.5.13(typescript@5.2.2)
|
||||
transitivePeerDependencies:
|
||||
@@ -4845,11 +4824,6 @@ packages:
|
||||
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
|
||||
dev: true
|
||||
|
||||
/astronomia@4.1.1:
|
||||
resolution: {integrity: sha512-TcJD9lUC5eAo0/Ji7rnQauX/yQbi0yZWM+JsNr77W3OA5fsrgvuFgubLMFwfw4VlZ29cu9dG/yfJbfvuTSftjg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dev: false
|
||||
|
||||
/async-validator@4.2.5:
|
||||
resolution: {integrity: sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==}
|
||||
dev: false
|
||||
@@ -5018,13 +4992,6 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/caldate@2.0.5:
|
||||
resolution: {integrity: sha512-JndhrUuDuE975KUhFqJaVR1OQkCHZqpOrJur/CFXEIEhWhBMjxO85cRSK8q4FW+B+yyPq6GYua2u4KvNzTcq0w==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
moment-timezone: 0.5.46
|
||||
dev: false
|
||||
|
||||
/call-bind@1.0.5:
|
||||
resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==}
|
||||
dependencies:
|
||||
@@ -5360,11 +5327,6 @@ packages:
|
||||
browserslist: 4.22.1
|
||||
dev: true
|
||||
|
||||
/countries-and-timezones@3.7.2:
|
||||
resolution: {integrity: sha512-BHAMt4pKb3U3r/mRfiIlVnDhRd8m6VC20gwCWtpZGZkSsjZmnMDKFnnjWYGWhBmypQAqcQILFJwmEhIgWGVTmw==}
|
||||
engines: {node: '>=8.x', npm: '>=5.x'}
|
||||
dev: false
|
||||
|
||||
/country-code-lookup@0.1.0:
|
||||
resolution: {integrity: sha512-IOI66HEG+8bXfWPy+sTzuN7161vmDZOHg1wgIPFf3WfD73FeLajnn6C+fnxOIa9RL1WRBDMXQQWW/FOaOYaQ3w==}
|
||||
dev: false
|
||||
@@ -5494,23 +5456,6 @@ packages:
|
||||
whatwg-url: 12.0.1
|
||||
dev: true
|
||||
|
||||
/date-bengali-revised@2.0.2:
|
||||
resolution: {integrity: sha512-q9iDru4+TSA9k4zfm0CFHJj6nBsxP7AYgWC/qodK/i7oOIlj5K2z5IcQDtESfs/Qwqt/xJYaP86tkazd/vRptg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dev: false
|
||||
|
||||
/date-chinese@2.1.4:
|
||||
resolution: {integrity: sha512-WY+6+Qw92ZGWFvGtStmNQHEYpNa87b8IAQ5T8VKt4wqrn24lBXyyBnWI5jAIyy7h/KVwJZ06bD8l/b7yss82Ww==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
astronomia: 4.1.1
|
||||
dev: false
|
||||
|
||||
/date-easter@1.0.3:
|
||||
resolution: {integrity: sha512-aOViyIgpM4W0OWUiLqivznwTtuMlD/rdUWhc5IatYnplhPiWrLv75cnifaKYhmQwUBLAMWLNG4/9mlLIbXoGBQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dev: false
|
||||
|
||||
/date-fns-tz@2.0.0(date-fns@2.30.0):
|
||||
resolution: {integrity: sha512-OAtcLdB9vxSXTWHdT8b398ARImVwQMyjfYGkKD2zaGpHseG2UPHbHjXELReErZFxWdSLph3c2zOaaTyHfOhERQ==}
|
||||
peerDependencies:
|
||||
@@ -5531,31 +5476,6 @@ packages:
|
||||
'@babel/runtime': 7.23.2
|
||||
dev: false
|
||||
|
||||
/date-holidays-parser@3.4.4:
|
||||
resolution: {integrity: sha512-R5aO4oT8H51ZKdvApqHrqYEiNBrqT6tRj2PFXNcZfqMI4nxY7KKKly0ZsmquR5gY+x9ldKR8SAMdozzIInaoXg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
astronomia: 4.1.1
|
||||
caldate: 2.0.5
|
||||
date-bengali-revised: 2.0.2
|
||||
date-chinese: 2.1.4
|
||||
date-easter: 1.0.3
|
||||
deepmerge: 4.3.1
|
||||
jalaali-js: 1.2.7
|
||||
moment-timezone: 0.5.46
|
||||
dev: false
|
||||
|
||||
/date-holidays@3.23.12:
|
||||
resolution: {integrity: sha512-DLyP0PPVgNydgaTAY7SBS26+5h3KO1Z8FRKiAROkz0hAGNBLGAM48SMabfVa2ACRHH7Qw3LXYvlJkt9oa9WePA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
date-holidays-parser: 3.4.4
|
||||
js-yaml: 4.1.0
|
||||
lodash: 4.17.21
|
||||
prepin: 1.0.3
|
||||
dev: false
|
||||
|
||||
/de-indent@1.0.2:
|
||||
resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==}
|
||||
dev: false
|
||||
@@ -5773,10 +5693,6 @@ packages:
|
||||
resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==}
|
||||
dev: true
|
||||
|
||||
/duration-fns@3.0.2:
|
||||
resolution: {integrity: sha512-w82IXh/6aWNHFA0qlQazJYJrZTWieTItuuGTE7YX4cxPaZTWhmVImbsBBiMK1/OhGDgiinuCpJoSFILYLDSKDg==}
|
||||
dev: false
|
||||
|
||||
/editorconfig@0.15.3:
|
||||
resolution: {integrity: sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==}
|
||||
dependencies:
|
||||
@@ -5804,7 +5720,7 @@ packages:
|
||||
/email-normalizer@1.0.0:
|
||||
resolution: {integrity: sha512-wZYuuMtL4kUOmg/TPtCrf9hAZjbFq+FcjWA85Z5nr2lGllRnWJPxCJw3gy4Cx+adMoyVw4VJfGGvt/OHgIW+qg==}
|
||||
dependencies:
|
||||
typescript: 5.5.4
|
||||
typescript: 5.7.3
|
||||
dev: false
|
||||
|
||||
/emitter-component@1.1.1:
|
||||
@@ -7121,6 +7037,10 @@ packages:
|
||||
jsbn: 1.1.0
|
||||
dev: false
|
||||
|
||||
/ip-matching@2.1.2:
|
||||
resolution: {integrity: sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg==}
|
||||
dev: false
|
||||
|
||||
/is-alphabetical@1.0.4:
|
||||
resolution: {integrity: sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==}
|
||||
dev: true
|
||||
@@ -7390,10 +7310,6 @@ packages:
|
||||
minimatch: 3.1.2
|
||||
dev: true
|
||||
|
||||
/jalaali-js@1.2.7:
|
||||
resolution: {integrity: sha512-gE+YHWSbygYAoJa+Xg8LWxGILqFOxZSBQQw39ghel01fVFUxV7bjL0x1JFsHcLQ3uPjvn81HQMa+kxwyPWnxGQ==}
|
||||
dev: false
|
||||
|
||||
/javascript-natural-sort@0.7.1:
|
||||
resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==}
|
||||
dev: false
|
||||
@@ -7451,6 +7367,7 @@ packages:
|
||||
hasBin: true
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
dev: true
|
||||
|
||||
/jsbn@1.1.0:
|
||||
resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==}
|
||||
@@ -7720,11 +7637,6 @@ packages:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
/luxon@3.5.0:
|
||||
resolution: {integrity: sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==}
|
||||
engines: {node: '>=12'}
|
||||
dev: false
|
||||
|
||||
/magic-string@0.25.9:
|
||||
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
|
||||
dependencies:
|
||||
@@ -7949,16 +7861,6 @@ packages:
|
||||
ufo: 1.5.4
|
||||
dev: true
|
||||
|
||||
/moment-timezone@0.5.46:
|
||||
resolution: {integrity: sha512-ZXm9b36esbe7OmdABqIWJuBBiLLwAjrN7CE+7sYdCCx82Nabt1wHDj8TVseS59QIlfFPbOoiBPm6ca9BioG4hw==}
|
||||
dependencies:
|
||||
moment: 2.30.1
|
||||
dev: false
|
||||
|
||||
/moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
dev: false
|
||||
|
||||
/monaco-editor@0.43.0:
|
||||
resolution: {integrity: sha512-cnoqwQi/9fml2Szamv1XbSJieGJ1Dc8tENVMD26Kcfl7xGQWp7OBKMjlwKVGYFJ3/AXJjSOGvcqK7Ry/j9BM1Q==}
|
||||
dev: false
|
||||
@@ -8290,10 +8192,6 @@ packages:
|
||||
callsites: 3.1.0
|
||||
dev: true
|
||||
|
||||
/parse-duration@1.1.0:
|
||||
resolution: {integrity: sha512-z6t9dvSJYaPoQq7quMzdEagSFtpGu+utzHqqxmpVWNNZRIXnvqyCvn9XsTdh7c/w0Bqmdz3RB3YnRaKtpRtEXQ==}
|
||||
dev: false
|
||||
|
||||
/parse-entities@2.0.0:
|
||||
resolution: {integrity: sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==}
|
||||
dependencies:
|
||||
@@ -8315,11 +8213,6 @@ packages:
|
||||
lines-and-columns: 1.2.4
|
||||
dev: true
|
||||
|
||||
/parse-ms@4.0.0:
|
||||
resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==}
|
||||
engines: {node: '>=18'}
|
||||
dev: false
|
||||
|
||||
/parse-node-version@1.0.1:
|
||||
resolution: {integrity: sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==}
|
||||
engines: {node: '>= 0.10'}
|
||||
@@ -8533,11 +8426,6 @@ packages:
|
||||
engines: {node: '>= 0.8.0'}
|
||||
dev: true
|
||||
|
||||
/prepin@1.0.3:
|
||||
resolution: {integrity: sha512-0XL2hreherEEvUy0fiaGEfN/ioXFV+JpImqIzQjxk6iBg4jQ2ARKqvC4+BmRD8w/pnpD+lbxvh0Ub+z7yBEjvA==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/prettier@3.0.0:
|
||||
resolution: {integrity: sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -8562,13 +8450,6 @@ packages:
|
||||
react-is: 18.2.0
|
||||
dev: true
|
||||
|
||||
/pretty-ms@9.1.0:
|
||||
resolution: {integrity: sha512-o1piW0n3tgKIKCwk2vpM/vOV13zjJzvP37Ioze54YlTHE06m4tjEbzg9WsKkvTuyYln2DHjo5pY4qrZGI0otpw==}
|
||||
engines: {node: '>=18'}
|
||||
dependencies:
|
||||
parse-ms: 4.0.0
|
||||
dev: false
|
||||
|
||||
/prosemirror-changeset@2.2.1:
|
||||
resolution: {integrity: sha512-J7msc6wbxB4ekDFj+n9gTW/jav/p53kdlivvuppHsrZXCaQdVgRghoZbSS3kwrRyAstRVQ4/+u5k7YfLgkkQvQ==}
|
||||
dependencies:
|
||||
@@ -9721,8 +9602,8 @@ packages:
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
/typescript@5.5.4:
|
||||
resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==}
|
||||
/typescript@5.7.3:
|
||||
resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
@@ -9861,20 +9742,20 @@ packages:
|
||||
engines: {node: '>= 10.0.0'}
|
||||
dev: true
|
||||
|
||||
/unocss-preset-scrollbar@0.2.1(unocss@0.65.3):
|
||||
/unocss-preset-scrollbar@0.2.1(unocss@0.65.4):
|
||||
resolution: {integrity: sha512-7ubHdOaUwr7xBn1glPpICNNsM2SZGjvWK5uRPNiQYsrZ9YFjsCGHk9x5S2R8pTkuMDQeiaSa/UQbYhjC8Fra5g==}
|
||||
peerDependencies:
|
||||
unocss: '>= 0.31.13 < 1'
|
||||
dependencies:
|
||||
'@unocss/preset-mini': 0.31.17
|
||||
unocss: 0.65.3(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
unocss: 0.65.4(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
dev: true
|
||||
|
||||
/unocss@0.65.3(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-v/nQ7BVIeW9UlEPElOu6xwqp0TTF2dZeIOfzos52b/N0cwWB9dBOjZM5hTn//ePQVzXm/M/n+Lm8E7gRP4TUfg==}
|
||||
/unocss@0.65.4(postcss@8.4.31)(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-KUCW5OzI20Ik6j1zXkkrpWhxZ59TwSKl6+DvmYHEzMfaEcrHlBZaFSApAoSt2CYSvo6SluGiKyr+Im1UTkd4KA==}
|
||||
engines: {node: '>=14'}
|
||||
peerDependencies:
|
||||
'@unocss/webpack': 0.65.3
|
||||
'@unocss/webpack': 0.65.4
|
||||
vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0
|
||||
peerDependenciesMeta:
|
||||
'@unocss/webpack':
|
||||
@@ -9882,23 +9763,23 @@ packages:
|
||||
vite:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@unocss/astro': 0.65.3(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
'@unocss/cli': 0.65.3(rollup@2.79.1)
|
||||
'@unocss/core': 0.65.3
|
||||
'@unocss/postcss': 0.65.3(postcss@8.4.31)
|
||||
'@unocss/preset-attributify': 0.65.3
|
||||
'@unocss/preset-icons': 0.65.3
|
||||
'@unocss/preset-mini': 0.65.3
|
||||
'@unocss/preset-tagify': 0.65.3
|
||||
'@unocss/preset-typography': 0.65.3
|
||||
'@unocss/preset-uno': 0.65.3
|
||||
'@unocss/preset-web-fonts': 0.65.3
|
||||
'@unocss/preset-wind': 0.65.3
|
||||
'@unocss/transformer-attributify-jsx': 0.65.3
|
||||
'@unocss/transformer-compile-class': 0.65.3
|
||||
'@unocss/transformer-directives': 0.65.3
|
||||
'@unocss/transformer-variant-group': 0.65.3
|
||||
'@unocss/vite': 0.65.3(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
'@unocss/astro': 0.65.4(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
'@unocss/cli': 0.65.4(rollup@2.79.1)
|
||||
'@unocss/core': 0.65.4
|
||||
'@unocss/postcss': 0.65.4(postcss@8.4.31)
|
||||
'@unocss/preset-attributify': 0.65.4
|
||||
'@unocss/preset-icons': 0.65.4
|
||||
'@unocss/preset-mini': 0.65.4
|
||||
'@unocss/preset-tagify': 0.65.4
|
||||
'@unocss/preset-typography': 0.65.4
|
||||
'@unocss/preset-uno': 0.65.4
|
||||
'@unocss/preset-web-fonts': 0.65.4
|
||||
'@unocss/preset-wind': 0.65.4
|
||||
'@unocss/transformer-attributify-jsx': 0.65.4
|
||||
'@unocss/transformer-compile-class': 0.65.4
|
||||
'@unocss/transformer-directives': 0.65.4
|
||||
'@unocss/transformer-variant-group': 0.65.4
|
||||
'@unocss/vite': 0.65.4(rollup@2.79.1)(vite@4.4.9)(vue@3.3.4)
|
||||
vite: 4.4.9(@types/node@18.15.11)(less@4.1.3)
|
||||
transitivePeerDependencies:
|
||||
- postcss
|
||||
|
||||
@@ -128,7 +128,7 @@ function activateOption(option: PaletteOption) {
|
||||
<c-input-text ref="inputRef" v-model:value="searchPrompt" raw-text placeholder="Type to search a tool or a command..." autofocus clearable />
|
||||
|
||||
<div v-for="(options, category) in filteredSearchResult" :key="category">
|
||||
<div ml-3 mt-3 text-sm text-primary font-bold op-60>
|
||||
<div ml-3 mt-3 text-sm font-bold text-primary op-60>
|
||||
{{ category }}
|
||||
</div>
|
||||
<command-palette-option v-for="option in options" :key="option.name" :option="option" :selected="selectedOptionIndex === getOptionIndex(option)" @activated="activateOption" />
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { cidrInCidr } from './cidr-in-cidr.service';
|
||||
|
||||
describe('cidr-in-cidr', () => {
|
||||
describe('cidrInCidr', () => {
|
||||
it('should return correct inclusion', () => {
|
||||
expect(cidrInCidr({ baseRange: '192.168.0.0/16', ipOrRangeToTest: '192.168.0.1' }).isIncluded).toBe(true); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.1.0/24', ipOrRangeToTest: '192.168.0.10' }).isIncluded).toBe(false); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.1.*', ipOrRangeToTest: '192.168.0.10' }).isIncluded).toBe(false); // NOSONAR
|
||||
|
||||
expect(cidrInCidr({ baseRange: '192.168.0.0/24', ipOrRangeToTest: '192.168.0.0/28' }).isIncluded).toBe(true); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.0/24', ipOrRangeToTest: '192.168.1.0/28' }).isIncluded).toBe(false); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.*', ipOrRangeToTest: '192.168.1.0/28' }).isIncluded).toBe(false); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.0.*', ipOrRangeToTest: '192.168.0.0/28' }).isIncluded).toBe(true); // NOSONAR
|
||||
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.1-192.168.20.15', ipOrRangeToTest: '192.168.20.12' }).isIncluded).toBe(true); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.1-192.168.20.15', ipOrRangeToTest: '192.168.20.20' }).isIncluded).toBe(false); // NOSONAR
|
||||
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.1-192.168.20.15', ipOrRangeToTest: '192.168.20.9-192.168.20.12' }).isIncluded).toBe(true); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.1-192.168.20.15', ipOrRangeToTest: '192.168.20.9-192.168.20.20' }).isIncluded).toBe(false); // NOSONAR
|
||||
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.0-192.168.20.255', ipOrRangeToTest: '192.168.20.0/28' }).isIncluded).toBe(true); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.0-192.168.20.255', ipOrRangeToTest: '192.168.1.0/28' }).isIncluded).toBe(false); // NOSONAR
|
||||
expect(cidrInCidr({ baseRange: '192.168.0.0-192.168.1.255', ipOrRangeToTest: '192.168.1.0/28' }).isIncluded).toBe(true); // NOSONAR
|
||||
});
|
||||
it('should return correct subnet', () => {
|
||||
expect(cidrInCidr({ baseRange: '192.168.0.0/16', ipOrRangeToTest: '192.168.0.1' }).baseSubnets).to.deep.eq([ // NOSONAR
|
||||
{
|
||||
cidr: '192.168.0.0/16', // NOSONAR
|
||||
end: '192.168.255.255', // NOSONAR
|
||||
start: '192.168.0.0', // NOSONAR
|
||||
},
|
||||
]);
|
||||
expect(cidrInCidr({ baseRange: '192.168.20.1-192.168.20.3', ipOrRangeToTest: '192.168.1.0/28' }).baseSubnets).to.deep.eq([ // NOSONAR
|
||||
{
|
||||
cidr: '192.168.20.1/32', // NOSONAR
|
||||
end: '192.168.20.1', // NOSONAR
|
||||
start: '192.168.20.1', // NOSONAR
|
||||
},
|
||||
{
|
||||
cidr: '192.168.20.2/31', // NOSONAR
|
||||
end: '192.168.20.3', // NOSONAR
|
||||
start: '192.168.20.2', // NOSONAR
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { getMatch } from 'ip-matching';
|
||||
|
||||
export function cidrInCidr(
|
||||
{ baseRange, ipOrRangeToTest }:
|
||||
{
|
||||
baseRange: string
|
||||
ipOrRangeToTest: string
|
||||
}) {
|
||||
const baseMatchMasks = getMatch(baseRange)?.convertToMasks() || [];
|
||||
const ipOrRangeToTestMatchMasks = getMatch(ipOrRangeToTest)?.convertToMasks() || [];
|
||||
|
||||
const baseSubnets = baseMatchMasks.map((mask) => {
|
||||
const subnet = mask.convertToSubnet();
|
||||
if (!subnet) {
|
||||
return { cidr: '', start: '', end: '' };
|
||||
}
|
||||
return {
|
||||
cidr: subnet.toString(),
|
||||
start: subnet.getFirst().toString(),
|
||||
end: subnet.getLast().toString(),
|
||||
};
|
||||
}).filter(subnet => subnet.cidr !== '');
|
||||
|
||||
return {
|
||||
baseSubnets,
|
||||
isIncluded: baseMatchMasks.some(baseMask => ipOrRangeToTestMatchMasks.every(ipOrRangeMask => ipOrRangeMask.isSubsetOf(baseMask))),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<script setup lang="ts">
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { Check as CheckIcon, LetterX as CrossIcon } from '@vicons/tabler';
|
||||
import { getMatch } from 'ip-matching';
|
||||
import { cidrInCidr } from './cidr-in-cidr.service';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import SpanCopyable from '@/components/SpanCopyable.vue';
|
||||
|
||||
const baseRange = useStorage('cidr-in-cidr:range', '192.168.0.1/24'); // NOSONAR
|
||||
const ipOrRangeToTest = useStorage('cidr-in-cidr:ip', '192.168.0.1'); // NOSONAR
|
||||
|
||||
const matchResult = computed(() => withDefaultOnError(
|
||||
() => cidrInCidr({ baseRange: baseRange.value, ipOrRangeToTest: ipOrRangeToTest.value }),
|
||||
{ baseSubnets: [], isIncluded: false }));
|
||||
|
||||
const rangeValidationRules = [
|
||||
{
|
||||
message: 'We cannot parse this CIDR/IP Range/Mask/Wildcard, check the format',
|
||||
validator: (value: string) => isNotThrowing(() => getMatch(value)) && getMatch(value),
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="baseRange"
|
||||
label="An IPv4/6 CIDR/Range/Mask/Wildcard (base network)"
|
||||
placeholder="The ipv4/6 CIDR..."
|
||||
:validation-rules="rangeValidationRules"
|
||||
mb-4
|
||||
/>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="ipOrRangeToTest"
|
||||
label="An IPv4/6 CIDR/Range/Mask/Wildcard (to test for inclusion)"
|
||||
placeholder="The An IPv4/6 CIDR/Range/Mask/Wildcard..."
|
||||
:validation-rules="rangeValidationRules"
|
||||
mb-4
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<div flex justify-center>
|
||||
<span v-if="matchResult.isIncluded">
|
||||
<n-icon color="green">
|
||||
<CheckIcon />
|
||||
</n-icon>
|
||||
Included
|
||||
</span>
|
||||
<span v-else>
|
||||
<n-icon color="red">
|
||||
<CrossIcon />
|
||||
</n-icon>
|
||||
Not included
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-card title="Subnets">
|
||||
<n-table>
|
||||
<tbody>
|
||||
<tr v-for="{ cidr, start, end } in matchResult.baseSubnets" :key="cidr">
|
||||
<td font-bold>
|
||||
<SpanCopyable :value="cidr" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="start" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="end" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
import { UnfoldMoreOutlined } from '@vicons/material';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'IPv4-6/IPRange/CIDR in IPRange/CIDR/IPMask',
|
||||
path: '/cidr-in-cidr',
|
||||
description: 'Given a CIDR/IP Range/Wildcard IP/IP Mask, tell if a given IPv4-6/Range/CIDR/Wildcard IP/IP Mask is in subnet range',
|
||||
keywords: ['ip', 'cidr', 'range', 'mask', 'wildcard', 'ipv4', 'ipv6', 'subnet', 'include', 'inclusion'],
|
||||
component: () => import('./cidr-in-cidr.vue'),
|
||||
redirectFrom: ['/ip-in-range'],
|
||||
icon: UnfoldMoreOutlined,
|
||||
createdAt: new Date('2025-01-12'),
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { addToDate } from './date-duration-calculator.service';
|
||||
|
||||
describe('date-duration-calculator', () => {
|
||||
describe('addToDate', () => {
|
||||
it('compute right values', () => {
|
||||
expect(addToDate(new Date('2024-08-15T07:21:46Z'), '+1d 1m 20s')).to.deep.eq(
|
||||
{
|
||||
date: new Date('2024-08-16T07:23:06.000Z'),
|
||||
durationPretty: '1d 1m 20s',
|
||||
durationSeconds: 86480,
|
||||
errors: [],
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
import { computeDuration } from '../duration-calculator/duration-calculator.service';
|
||||
|
||||
export function addToDate(date: Date, durations: string) {
|
||||
const { total, errors } = computeDuration(durations);
|
||||
|
||||
return {
|
||||
errors,
|
||||
date: new Date(date.getTime() + total.milliseconds),
|
||||
durationSeconds: total.seconds,
|
||||
durationPretty: total.prettified,
|
||||
};
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { addToDate } from './date-duration-calculator.service';
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
const inputReferenceDate = ref(now);
|
||||
const inputDurations = ref('');
|
||||
const resultDateAdder = computed(() => addToDate(new Date(inputReferenceDate.value), inputDurations.value));
|
||||
const errorsDateAdder = computed(() => resultDateAdder.value.errors.join('\n'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-card title="Date + Duration Calculator" mb-2>
|
||||
<n-form-item label="Reference Date:" label-placement="left" mb-1>
|
||||
<n-date-picker v-model:value="inputReferenceDate" type="datetime" />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="inputDurations"
|
||||
multiline
|
||||
rows="5"
|
||||
label="Duration(s)"
|
||||
placeholder="Please enter duration, one per line with optional sign"
|
||||
mb-2
|
||||
/>
|
||||
<n-p>Supports: comment (# line), HH:MM:SS.FFF, 3d 1h 3s..., P4DT12H20M20.3S..</n-p>
|
||||
|
||||
<c-card v-if="errorsDateAdder" title="Lines errors">
|
||||
<textarea-copyable :value="errorsDateAdder" />
|
||||
</c-card>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<input-copyable v-if="resultDateAdder" label="Result Date:" label-position="left" label-width="150px" :value="resultDateAdder.date.toString()" mb-1 />
|
||||
<input-copyable v-if="resultDateAdder" label="Result ISO Date:" label-position="left" label-width="150px" :value="resultDateAdder.date.toISOString()" mb-1 />
|
||||
<input-copyable v-if="resultDateAdder" label="Duration (seconds):" label-position="left" label-width="150px" :value="resultDateAdder.durationSeconds" mb-1 />
|
||||
<input-copyable v-if="resultDateAdder" label="Duration:" label-position="left" label-width="150px" :value="resultDateAdder.durationPretty" mb-1 />
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Calendar } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Date+Durations Calculator',
|
||||
path: '/date-duration-calculator',
|
||||
description: 'Add/substract durations from a specific date',
|
||||
keywords: ['date', 'duration', 'addition', 'calculator'],
|
||||
component: () => import('./date-duration-calculator.vue'),
|
||||
icon: Calendar,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -1,611 +0,0 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { DayOfWeek, Holiday } from './business-time-calculator';
|
||||
import { BusinessTime } from './business-time-calculator';
|
||||
|
||||
const weekDays: DayOfWeek[] = [
|
||||
'monday',
|
||||
'tuesday',
|
||||
'wednesday',
|
||||
'thursday',
|
||||
'friday',
|
||||
];
|
||||
|
||||
const allDays: DayOfWeek[] = [
|
||||
'monday',
|
||||
'tuesday',
|
||||
'wednesday',
|
||||
'thursday',
|
||||
'friday',
|
||||
'saturday',
|
||||
'sunday',
|
||||
];
|
||||
|
||||
interface TestCase {
|
||||
businessTimezone: string
|
||||
businessDays: DayOfWeek[]
|
||||
businessHours: number[]
|
||||
holidays: Holiday[]
|
||||
start?: string
|
||||
end?: string
|
||||
expected: any
|
||||
}
|
||||
|
||||
type BusinessTimeMethod = keyof InstanceType<typeof BusinessTime>;
|
||||
|
||||
function testEachComputeTime(testCases: TestCase[],
|
||||
businessTimeFunctionName: BusinessTimeMethod) {
|
||||
for (const {
|
||||
start,
|
||||
end,
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
expected,
|
||||
} of testCases) {
|
||||
if (!start || !end) {
|
||||
throw new Error('Start and end dates must be defined');
|
||||
}
|
||||
|
||||
const startDatetime = DateTime.fromISO(start) as DateTime;
|
||||
if (!startDatetime.isValid) {
|
||||
throw new Error(`Invalid start datetime: ${start}`);
|
||||
}
|
||||
const endDatetime = DateTime.fromISO(end) as DateTime;
|
||||
if (!endDatetime.isValid) {
|
||||
throw new Error(`Invalid end datetime: ${end}`);
|
||||
}
|
||||
const businessTime = new BusinessTime({
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
});
|
||||
|
||||
expect(
|
||||
businessTime[businessTimeFunctionName]({
|
||||
start: startDatetime,
|
||||
end: endDatetime,
|
||||
} as never)).to.deep.eq(expected);
|
||||
}
|
||||
}
|
||||
|
||||
function testEachMoveDateInBusinessTime(testCases: (TestCase & { datetime: string; moveBehind: boolean })[]) {
|
||||
for (const {
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
datetime,
|
||||
moveBehind,
|
||||
expected,
|
||||
} of testCases) {
|
||||
const businessTime = new BusinessTime({
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
});
|
||||
|
||||
expect(
|
||||
businessTime
|
||||
._moveDateInBusinessTime({
|
||||
datetime: DateTime.fromISO(datetime),
|
||||
moveBehind,
|
||||
})
|
||||
.toISO()).to.deep.eq(
|
||||
expected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function testEachIsBusinessDay(testCases: (TestCase & { datetime: string })[]) {
|
||||
for (const {
|
||||
datetime,
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
expected,
|
||||
} of testCases) {
|
||||
const datetimeObj = DateTime.fromISO(datetime) as DateTime;
|
||||
if (!datetimeObj.isValid) {
|
||||
throw new Error(`Invalid datetime: ${datetime}`);
|
||||
}
|
||||
const businessTime = new BusinessTime({
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
});
|
||||
|
||||
expect(businessTime.isBusinessDay(datetimeObj)).to.deep.eq(expected);
|
||||
}
|
||||
}
|
||||
|
||||
function testEachAddBusinessSecondsToDate(testCases: (TestCase & { datetime: string; seconds: number })[]) {
|
||||
for (const {
|
||||
seconds,
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
datetime,
|
||||
expected,
|
||||
} of testCases) {
|
||||
const datetimeObj = DateTime.fromISO(datetime) as DateTime;
|
||||
if (!datetimeObj.isValid) {
|
||||
throw new Error(`Invalid datetime: ${datetime}`);
|
||||
}
|
||||
const businessTime = new BusinessTime({
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
});
|
||||
|
||||
expect(
|
||||
businessTime
|
||||
.addBusinessSecondsToDate({ datetime: datetimeObj, seconds })
|
||||
.toISO()).to.deep.eq(
|
||||
expected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function testEachRemoveBusinessSecondsToDate(testCases: (TestCase & { datetime: string; seconds: number })[]) {
|
||||
for (const {
|
||||
seconds,
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
datetime,
|
||||
expected,
|
||||
} of testCases) {
|
||||
const datetimeObj = DateTime.fromISO(datetime) as DateTime;
|
||||
if (!datetimeObj.isValid) {
|
||||
throw new Error(`Invalid datetime: ${datetime}`);
|
||||
}
|
||||
const businessTime = new BusinessTime({
|
||||
businessTimezone,
|
||||
businessHours,
|
||||
businessDays,
|
||||
holidays,
|
||||
});
|
||||
|
||||
expect(
|
||||
businessTime
|
||||
.removeBusinessSecondsFromDate({ datetime: datetimeObj, seconds })
|
||||
.toISO()).to.deep.eq(
|
||||
expected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
describe('BusinessTime', () => {
|
||||
it('compute business days', () => {
|
||||
testEachComputeTime(
|
||||
[
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T09:00:00.000+01:00',
|
||||
end: '2020-12-29T23:00:00.000+01:00',
|
||||
expected: 2,
|
||||
},
|
||||
],
|
||||
'computeBusinessDaysInInterval',
|
||||
);
|
||||
});
|
||||
|
||||
it('compute business hours', () => {
|
||||
testEachComputeTime(
|
||||
[
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T13:45:00.000+01:00',
|
||||
end: '2020-12-28T14:00:00.000+01:00',
|
||||
expected: 0.25,
|
||||
}, // same hour
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: ['25/12', '26/12'],
|
||||
start: '2020-12-25T10:45:00.000+01:00',
|
||||
end: '2020-12-27T10:00:00.000+01:00',
|
||||
expected: 0,
|
||||
}, // holidays days
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: ['25/12/2020', '26/12/2020'],
|
||||
start: '2020-12-25T10:45:00.000+01:00',
|
||||
end: '2020-12-27T10:00:00.000+01:00',
|
||||
expected: 0,
|
||||
}, // holidays days and dates
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: ['25/12/2022', '26/12/2022'],
|
||||
start: '2020-12-25T10:45:00.000+01:00',
|
||||
end: '2020-12-27T10:00:00.000+01:00',
|
||||
expected: 8.25,
|
||||
}, // holidays days and dates (wrong year)
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T14:00:00.000+01:00',
|
||||
end: '2020-12-28T18:30:00.000+01:00',
|
||||
expected: 4.5,
|
||||
}, // same day
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-18T14:00:00.000+01:00',
|
||||
end: '2020-12-21T14:30:00.000+01:00',
|
||||
expected: 9.5,
|
||||
}, // cross weekend
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T15:00:00.000+01:00',
|
||||
end: '2020-12-28T20:00:00.000+01:00',
|
||||
expected: 4,
|
||||
}, // 4 hours in Rome
|
||||
{
|
||||
businessTimezone: 'America/Los_Angeles',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T15:00:00.000+01:00',
|
||||
end: '2020-12-28T20:00:00.000+01:00',
|
||||
expected: 1,
|
||||
}, // 1 hour in San Francisco
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2021-01-04T10:00:00.000+01:00',
|
||||
end: '2021-03-01T10:00:00.000+01:00',
|
||||
expected: 360,
|
||||
}, // 8 weeks, 45 hours / week => 360
|
||||
],
|
||||
'computeBusinessHoursInInterval',
|
||||
);
|
||||
});
|
||||
|
||||
it('compute business minutes', () => {
|
||||
testEachComputeTime(
|
||||
[
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T13:45:00.000+01:00',
|
||||
end: '2020-12-28T14:00:00.000+01:00',
|
||||
expected: 15,
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: ['01/01'],
|
||||
start: '2020-12-31T13:45:00.000+01:00',
|
||||
end: '2021-01-04T19:00:00.000+01:00',
|
||||
expected: 855,
|
||||
},
|
||||
],
|
||||
'computeBusinessMinutesInInterval',
|
||||
);
|
||||
});
|
||||
|
||||
it('compute business seconds', () => {
|
||||
testEachComputeTime(
|
||||
[
|
||||
{
|
||||
businessTimezone: 'America/Los_Angeles',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
start: '2020-12-28T15:00:00.000+01:00',
|
||||
end: '2020-12-28T20:00:00.000+01:00',
|
||||
expected: 3600,
|
||||
}, // 1 hour in San Francisco
|
||||
],
|
||||
'computeBusinessSecondsInInterval',
|
||||
);
|
||||
});
|
||||
|
||||
it('compute isBusinessDay', () => {
|
||||
testEachIsBusinessDay([
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: ['25/12', '26/12'],
|
||||
datetime: '2020-12-28T14:00:00.000+01:00',
|
||||
expected: true,
|
||||
}, // monday
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'friday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: ['26/12'],
|
||||
datetime: '2020-12-25T14:00:00.000+01:00',
|
||||
expected: true,
|
||||
}, // Christmas 2020 (friday) configured as business day
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
holidays: ['25/12', '26/12'],
|
||||
businessHours: [10, 19],
|
||||
datetime: '2020-12-27T14:00:00.000+01:00',
|
||||
expected: false,
|
||||
}, // tuesday configured as rest day
|
||||
{
|
||||
businessTimezone: 'America/Los_Angeles',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: ['25/12', '26/12'],
|
||||
datetime: '2020-12-28T01:00:00.000+01:00',
|
||||
expected: false,
|
||||
}, // monday in Rome, sunday in San Francisco
|
||||
]);
|
||||
});
|
||||
|
||||
it('compute moveDateInBusinessTime', () => {
|
||||
testEachMoveDateInBusinessTime([
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: [],
|
||||
moveBehind: false,
|
||||
datetime: '2020-12-28T11:00:00.000+01:00',
|
||||
expected: '2020-12-28T13:00:00.000+01:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: [],
|
||||
moveBehind: false,
|
||||
datetime: '2020-12-28T14:00:00.000+01:00',
|
||||
expected: '2020-12-28T14:00:00.000+01:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: ['01/01'],
|
||||
moveBehind: false,
|
||||
datetime: '2020-12-28T16:00:00.000+01:00',
|
||||
expected: '2021-01-04T13:00:00.000+01:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'America/Los_Angeles',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
moveBehind: false,
|
||||
datetime: '2021-06-15T00:00:00.000+02:00', // tuesday
|
||||
expected: '2021-06-14T15:00:00.000-07:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: [],
|
||||
moveBehind: true,
|
||||
datetime: '2022-04-12T11:00:00.000+02:00',
|
||||
expected: '2022-04-11T15:00:00.000+02:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: [],
|
||||
moveBehind: true,
|
||||
datetime: '2020-12-28T14:00:00.000+01:00',
|
||||
expected: '2020-12-28T14:00:00.000+01:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday'],
|
||||
businessHours: [13, 15],
|
||||
holidays: ['01/01'],
|
||||
moveBehind: true,
|
||||
datetime: '2022-04-11T11:00:00.000+02:00',
|
||||
expected: '2022-04-04T15:00:00.000+02:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'America/Los_Angeles',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
moveBehind: true,
|
||||
datetime: '2021-06-15T00:00:00.000+02:00', // tuesday
|
||||
expected: '2021-06-14T15:00:00.000-07:00',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('add business seconds to date', () => {
|
||||
testEachAddBusinessSecondsToDate([
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
datetime: '2020-12-28T10:45:00.000+01:00',
|
||||
seconds: 3600 * 10,
|
||||
expected: '2020-12-29T10:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: weekDays,
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
datetime: '2022-04-04T19:45:00.000+02:00',
|
||||
seconds: 3600 * 10,
|
||||
expected: '2022-04-06T09:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 24],
|
||||
holidays: ['01/01'],
|
||||
datetime: '2020-12-28T10:45:00.000+01:00',
|
||||
seconds: 3600 * 96,
|
||||
expected: '2021-01-02T09:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 24],
|
||||
holidays: [],
|
||||
datetime: '2020-12-28T10:45:00.000+01:00',
|
||||
seconds: 3600 * 96,
|
||||
expected: '2021-01-01T09:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 12],
|
||||
holidays: [],
|
||||
datetime: '2020-12-28T10:45:00.000+01:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2020-12-30T09:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 12],
|
||||
holidays: [],
|
||||
datetime: '2022-04-11T18:00:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-13T10:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [12, 24],
|
||||
holidays: [],
|
||||
datetime: '2022-04-04T10:00:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-05T22:00:00.000+00:00',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('remove business seconds from date', () => {
|
||||
testEachRemoveBusinessSecondsToDate([
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
datetime: '2020-12-28T10:45:00.000+01:00',
|
||||
seconds: 3600 * 10,
|
||||
expected: '2020-12-24T17:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
|
||||
businessHours: [10, 19],
|
||||
holidays: [],
|
||||
datetime: '2022-04-08T19:45:00.000+02:00',
|
||||
seconds: 3600 * 10,
|
||||
expected: '2022-04-07T16:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 24],
|
||||
holidays: ['25/12'],
|
||||
datetime: '2020-12-28T10:11:11.111+01:00',
|
||||
seconds: 3600 * 96, // 4 days
|
||||
expected: '2020-12-23T09:11:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], // handle weekend
|
||||
businessHours: [0, 24],
|
||||
holidays: [],
|
||||
datetime: '2022-04-11T12:00:00.000+02:00',
|
||||
seconds: 3600 * 48, // 2 days
|
||||
expected: '2022-04-07T10:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], // handle weekend
|
||||
businessHours: [1, 24],
|
||||
holidays: [],
|
||||
datetime: '2022-04-11T12:00:00.000+02:00',
|
||||
seconds: 3600 * 48, // 2 days
|
||||
expected: '2022-04-07T08:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 12],
|
||||
holidays: [],
|
||||
datetime: '2022-04-08T10:45:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-06T08:45:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [0, 12],
|
||||
holidays: [],
|
||||
datetime: '2022-04-08T18:00:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-06T22:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: allDays,
|
||||
businessHours: [12, 24],
|
||||
holidays: [],
|
||||
datetime: '2022-04-08T10:00:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-06T10:00:00.000+00:00',
|
||||
},
|
||||
{
|
||||
businessTimezone: 'Europe/Rome',
|
||||
businessDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], // handle weekend
|
||||
businessHours: [12, 24],
|
||||
holidays: [],
|
||||
datetime: '2022-04-11T10:00:00.000+02:00',
|
||||
seconds: 3600 * 24,
|
||||
expected: '2022-04-07T10:00:00.000+00:00',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('compute working hours', () => {
|
||||
expect(BusinessTime.computeWorkingHours(10, 19)).toBe(9);
|
||||
expect(BusinessTime.computeWorkingHours(0, 24)).toBe(24);
|
||||
expect(BusinessTime.computeWorkingHours(18, 3)).toBe(9);
|
||||
expect(BusinessTime.computeWorkingHours(22, 0)).toBe(2);
|
||||
});
|
||||
});
|
||||
@@ -1,341 +0,0 @@
|
||||
import type { DateTime } from 'luxon';
|
||||
|
||||
export type DayOfWeek =
|
||||
| 'monday'
|
||||
| 'tuesday'
|
||||
| 'wednesday'
|
||||
| 'thursday'
|
||||
| 'friday'
|
||||
| 'saturday'
|
||||
| 'sunday';
|
||||
|
||||
const weekDayToName = {
|
||||
1: 'monday',
|
||||
2: 'tuesday',
|
||||
3: 'wednesday',
|
||||
4: 'thursday',
|
||||
5: 'friday',
|
||||
6: 'saturday',
|
||||
7: 'sunday',
|
||||
};
|
||||
|
||||
export type Holiday = `${3 | 2 | 1 | 0}${number}/${1 | 0}${number}` | `${3 | 2 | 1 | 0}${number}/${1 | 0}${number}/${number}${number}${number}${number}`;
|
||||
|
||||
export class BusinessTime {
|
||||
private readonly businessTimezone: string;
|
||||
|
||||
private readonly businessDays: DayOfWeek[];
|
||||
private readonly holidays: Holiday[];
|
||||
private readonly startOfDayTime: { hour: number; minute: number; second: number };
|
||||
private readonly endOfDayTime: { hour: number; minute: number; second: number };
|
||||
|
||||
static readonly computeWorkingHours = (startHour: number, endHour: number) => {
|
||||
if (endHour < startHour) {
|
||||
const workingHours = Math.abs(Math.abs(startHour - 24) + endHour);
|
||||
return workingHours;
|
||||
}
|
||||
|
||||
const workingHours = endHour - startHour;
|
||||
return workingHours;
|
||||
};
|
||||
|
||||
constructor({
|
||||
businessTimezone,
|
||||
businessDays,
|
||||
businessHours,
|
||||
holidays,
|
||||
}: {
|
||||
businessTimezone: string
|
||||
businessDays: DayOfWeek[]
|
||||
businessHours: number[]
|
||||
holidays: Holiday[]
|
||||
}) {
|
||||
this.businessTimezone = businessTimezone;
|
||||
this.businessDays = businessDays;
|
||||
this.holidays = holidays;
|
||||
this.startOfDayTime = {
|
||||
hour: businessHours[0],
|
||||
minute: 0,
|
||||
second: 0,
|
||||
};
|
||||
this.endOfDayTime = {
|
||||
hour: businessHours[1],
|
||||
minute: 0,
|
||||
second: 0,
|
||||
};
|
||||
}
|
||||
|
||||
computeWorkingHours = () => {
|
||||
const workingHours = BusinessTime.computeWorkingHours(
|
||||
this.startOfDayTime.hour,
|
||||
this.endOfDayTime.hour,
|
||||
);
|
||||
return workingHours;
|
||||
};
|
||||
|
||||
isBusinessDay(datetime: DateTime) {
|
||||
const date = datetime.setZone(this.businessTimezone);
|
||||
if (!date.isValid) {
|
||||
throw new Error('Invalid date');
|
||||
}
|
||||
|
||||
const dayMonth = date.toFormat('dd/MM') as Holiday;
|
||||
const dayMonthYear = date.toFormat('dd/MM/yyyy') as Holiday;
|
||||
if (this.holidays.includes(dayMonth) || this.holidays.includes(dayMonthYear)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.businessDays.includes(weekDayToName[date.weekday] as DayOfWeek)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
computeBusinessDaysInInterval({
|
||||
start,
|
||||
end,
|
||||
}: {
|
||||
start: DateTime
|
||||
end: DateTime
|
||||
}) {
|
||||
const businessHours = this.computeBusinessHoursInInterval({ start, end });
|
||||
const workingHours = this.computeWorkingHours();
|
||||
return businessHours / workingHours;
|
||||
}
|
||||
|
||||
computeBusinessHoursInInterval({
|
||||
start,
|
||||
end,
|
||||
}: {
|
||||
start: DateTime
|
||||
end: DateTime
|
||||
}) {
|
||||
return this.computeBusinessTimeInInterval({ start, end, unit: 'hours' });
|
||||
}
|
||||
|
||||
computeBusinessMinutesInInterval({
|
||||
start,
|
||||
end,
|
||||
}: {
|
||||
start: DateTime
|
||||
end: DateTime
|
||||
}) {
|
||||
return this.computeBusinessTimeInInterval({ start, end, unit: 'minutes' });
|
||||
}
|
||||
|
||||
computeBusinessSecondsInInterval({
|
||||
start,
|
||||
end,
|
||||
}: {
|
||||
start: DateTime
|
||||
end: DateTime
|
||||
}) {
|
||||
return this.computeBusinessTimeInInterval({ start, end, unit: 'seconds' });
|
||||
}
|
||||
|
||||
computeBusinessTimeInInterval({
|
||||
start,
|
||||
end,
|
||||
unit,
|
||||
}: {
|
||||
start: DateTime
|
||||
end: DateTime
|
||||
unit: 'hours' | 'minutes' | 'seconds'
|
||||
}) {
|
||||
if (start > end) {
|
||||
throw new Error('start date is greater than end date');
|
||||
}
|
||||
|
||||
const interval = {
|
||||
start: this._moveDateInBusinessTime({ datetime: start }),
|
||||
end: this._moveDateInBusinessTime({ datetime: end }),
|
||||
};
|
||||
|
||||
let datetime = interval.start;
|
||||
let businessTime = 0;
|
||||
|
||||
while (datetime < interval.end) {
|
||||
if (!this.isBusinessDay(datetime)) {
|
||||
datetime = datetime.plus({ days: 1 }).set(this.startOfDayTime);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (datetime.toISODate() === interval.end.toISODate()) {
|
||||
businessTime += interval.end.diff(datetime).as(unit);
|
||||
datetime = interval.end;
|
||||
}
|
||||
else {
|
||||
const endOfBusinessDay = datetime.set(this.endOfDayTime);
|
||||
businessTime += endOfBusinessDay.diff(datetime).as(unit);
|
||||
datetime = datetime.plus({ days: 1 }).set(this.startOfDayTime);
|
||||
}
|
||||
}
|
||||
|
||||
return businessTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the date in a business time (moveBehind = false)
|
||||
* e.g. 06:00 => 10:00 of the current day
|
||||
* e.g. 22:00 => 10:00 of the next day
|
||||
*
|
||||
* Move the date in a business time (moveBehind = true)
|
||||
* e.g. 06:00 => 19:00 of the previous day
|
||||
* e.g. 22:00 => 19:00 of the current day
|
||||
*
|
||||
* Warning ⚠️ _moveDateInBusinessTime doesn't retain the original timezone of the datetime in input, but it returns a datetime with the same timezone used to compute business times.
|
||||
* It follows that behaviour because this method should be private and used only as helper. It is public only for testing purpose.
|
||||
*/
|
||||
_moveDateInBusinessTime({
|
||||
datetime,
|
||||
moveBehind = false,
|
||||
}: {
|
||||
datetime: DateTime
|
||||
moveBehind?: boolean
|
||||
}) {
|
||||
let date = datetime.setZone(this.businessTimezone);
|
||||
const start = date.set(this.startOfDayTime);
|
||||
const end = date.set(this.endOfDayTime);
|
||||
|
||||
if (date < start) {
|
||||
// Move datetime to the start / end of the business day
|
||||
date = moveBehind
|
||||
? date.minus({ days: 1 }).set(this.endOfDayTime)
|
||||
: start;
|
||||
}
|
||||
if (date > end) {
|
||||
// Move datetime to the start of the next / previous day
|
||||
date = moveBehind
|
||||
? date.set(this.endOfDayTime)
|
||||
: date.plus({ days: 1 }).set(this.startOfDayTime);
|
||||
}
|
||||
while (this.businessDays.length && !this.isBusinessDay(date)) {
|
||||
// Move datetime to the start of the next / previous business day
|
||||
date = moveBehind
|
||||
? date.minus({ days: 1 }).set(this.endOfDayTime)
|
||||
: date.plus({ days: 1 }).set(this.startOfDayTime);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
addBusinessHoursToDate({
|
||||
datetime,
|
||||
hours,
|
||||
}: {
|
||||
datetime: DateTime
|
||||
hours: number
|
||||
}) {
|
||||
return this.addBusinessSecondsToDate({ datetime, seconds: 3600 * hours });
|
||||
}
|
||||
|
||||
addBusinessSecondsToDate({
|
||||
datetime,
|
||||
seconds,
|
||||
}: {
|
||||
datetime: DateTime
|
||||
seconds: number
|
||||
}) {
|
||||
if (seconds === 0) {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
let date = this._moveDateInBusinessTime({ datetime });
|
||||
let remainingSeconds = seconds;
|
||||
while (remainingSeconds > 0) {
|
||||
if (!this.isBusinessDay(date)) {
|
||||
date = date.plus({ days: 1 });
|
||||
continue;
|
||||
}
|
||||
|
||||
const endOfBusinessDay = date.set(this.endOfDayTime);
|
||||
const secondsUntilEndOfBusinessDay = endOfBusinessDay
|
||||
.diff(date)
|
||||
.as('seconds');
|
||||
|
||||
if (remainingSeconds <= secondsUntilEndOfBusinessDay) {
|
||||
// remaining seconds are less than 1 business day
|
||||
date = date.plus({ seconds: remainingSeconds });
|
||||
remainingSeconds = 0;
|
||||
}
|
||||
else {
|
||||
// Move to the start of the next day
|
||||
date = date.plus({ days: 1 }).set(this.startOfDayTime);
|
||||
remainingSeconds -= secondsUntilEndOfBusinessDay;
|
||||
}
|
||||
}
|
||||
|
||||
return date.set({ second: 0, millisecond: 0 }).setZone(datetime.zone);
|
||||
}
|
||||
|
||||
removeBusinessHoursFromDate({
|
||||
datetime,
|
||||
hours,
|
||||
}: {
|
||||
datetime: DateTime
|
||||
hours: number
|
||||
}) {
|
||||
return this.removeBusinessSecondsFromDate({
|
||||
datetime,
|
||||
seconds: 3600 * hours,
|
||||
});
|
||||
}
|
||||
|
||||
removeBusinessSecondsFromDate({
|
||||
datetime,
|
||||
seconds,
|
||||
}: {
|
||||
datetime: DateTime
|
||||
seconds: number
|
||||
}) {
|
||||
if (seconds === 0) {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
let date = this._moveDateInBusinessTime({ datetime, moveBehind: true });
|
||||
let remainingSeconds = seconds;
|
||||
while (remainingSeconds > 0) {
|
||||
if (!this.isBusinessDay(date)) {
|
||||
date = date.minus({ days: 1 });
|
||||
continue;
|
||||
}
|
||||
|
||||
const startOfBusinessDay
|
||||
= date.hour === 0 && date.minute === 0
|
||||
? date.minus({ days: 1 }).set(this.startOfDayTime)
|
||||
: date.set(this.startOfDayTime);
|
||||
const secondsFromStartOfBusinessDay = date
|
||||
.diff(startOfBusinessDay)
|
||||
.as('seconds');
|
||||
|
||||
if (remainingSeconds <= secondsFromStartOfBusinessDay) {
|
||||
// remaining seconds are less than 1 business day
|
||||
date = date.minus({ seconds: remainingSeconds });
|
||||
remainingSeconds = 0;
|
||||
}
|
||||
else {
|
||||
// Move to the end of the previous day
|
||||
date = date.minus({ days: 1 });
|
||||
|
||||
// handle special case 24h business days. If it is midnight and endOfDayTime is midnight, we must not set the date to the end of the day, otherwise we lose the effect of removing 1 day
|
||||
if (
|
||||
!(
|
||||
date.hour === 0
|
||||
&& date.minute === 0
|
||||
&& this.endOfDayTime.hour === 24
|
||||
)
|
||||
) {
|
||||
date = date.set(this.endOfDayTime);
|
||||
}
|
||||
remainingSeconds -= secondsFromStartOfBusinessDay;
|
||||
}
|
||||
}
|
||||
|
||||
return date.set({ second: 0, millisecond: 0 }).setZone(datetime.zone);
|
||||
}
|
||||
|
||||
hoursToDays(hours: number) {
|
||||
const days = hours / this.computeWorkingHours();
|
||||
return days;
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { DateTime } from 'luxon';
|
||||
import { countCertainDays, datesByDays, diffDateTimes } from './days-calculator.service';
|
||||
|
||||
describe('days-calculator', () => {
|
||||
describe('diffDateTimes', () => {
|
||||
it('compute right values', () => {
|
||||
const daysInfos = {
|
||||
saturdays: [
|
||||
'2024-08-03',
|
||||
'2024-08-10',
|
||||
'2024-08-17',
|
||||
'2024-08-24',
|
||||
'2024-08-31',
|
||||
],
|
||||
tuesdays: [
|
||||
'2024-08-06',
|
||||
'2024-08-13',
|
||||
'2024-08-20',
|
||||
'2024-08-27',
|
||||
],
|
||||
sundays: [
|
||||
'2024-08-04',
|
||||
'2024-08-11',
|
||||
'2024-08-18',
|
||||
'2024-08-25',
|
||||
],
|
||||
mondays: [
|
||||
'2024-08-05',
|
||||
'2024-08-12',
|
||||
'2024-08-19',
|
||||
'2024-08-26',
|
||||
],
|
||||
fridays: [
|
||||
'2024-08-02',
|
||||
'2024-08-09',
|
||||
'2024-08-16',
|
||||
'2024-08-23',
|
||||
'2024-08-30',
|
||||
],
|
||||
|
||||
wednesdays: [
|
||||
'2024-08-07',
|
||||
'2024-08-14',
|
||||
'2024-08-21',
|
||||
'2024-08-28',
|
||||
],
|
||||
thursdays: [
|
||||
'2024-08-01',
|
||||
'2024-08-08',
|
||||
'2024-08-15',
|
||||
'2024-08-22',
|
||||
'2024-08-29',
|
||||
],
|
||||
weekendDays: 9,
|
||||
weekends: 4,
|
||||
};
|
||||
const holidays = [
|
||||
{
|
||||
date: '2024-08-15 00:00:00',
|
||||
end: new Date('2024-08-15T22:00:00.000Z'),
|
||||
name: 'Assomption',
|
||||
rule: '08-15',
|
||||
start: new Date('2024-08-14T22:00:00.000Z'),
|
||||
type: 'public',
|
||||
},
|
||||
];
|
||||
const totalDiff1 = {
|
||||
totalDifference: {
|
||||
days: 30.416666666666668,
|
||||
hours: 730,
|
||||
minutes: 43800,
|
||||
months: 0.9811827956989247,
|
||||
seconds: 2628000,
|
||||
weeks: 4.345238095238095,
|
||||
years: 0.08333333333333333,
|
||||
},
|
||||
};
|
||||
|
||||
const date1 = new Date('2024-08-01T07:21:46Z');
|
||||
const date2 = new Date('2024-08-31T17:21:46Z');
|
||||
|
||||
expect(diffDateTimes({
|
||||
date1,
|
||||
date2,
|
||||
country: 'FR',
|
||||
businessTimezone: 'Europe/Paris',
|
||||
includeWeekDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
|
||||
includeEndDate: true,
|
||||
includeHolidays: true,
|
||||
businessStartHour: 9,
|
||||
businessEndHour: 18,
|
||||
})).to.deep.eq({
|
||||
startDate: date1,
|
||||
endDate: date2,
|
||||
businessDays: 29.959691358024696,
|
||||
businessHours: 269.63722222222225,
|
||||
businessSeconds: 970694,
|
||||
businessSecondsFormatted: '11d 5h 38m 14s',
|
||||
differenceFormatted: '29d 10h',
|
||||
differenceSeconds: 2541600,
|
||||
...totalDiff1,
|
||||
totalDifferenceFormatted: '30d 10h',
|
||||
holidays,
|
||||
...daysInfos,
|
||||
});
|
||||
expect(diffDateTimes({
|
||||
date1,
|
||||
date2,
|
||||
country: 'FR',
|
||||
businessTimezone: 'Europe/Paris',
|
||||
includeEndDate: false,
|
||||
includeWeekDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
|
||||
includeHolidays: true,
|
||||
businessStartHour: 9,
|
||||
businessEndHour: 18,
|
||||
})).to.deep.eq({
|
||||
startDate: date1,
|
||||
endDate: new Date('2024-08-30T23:59:59.999Z'),
|
||||
businessDays: 28.959722191358026,
|
||||
businessHours: 260.63749972222223,
|
||||
businessSeconds: 938294.999,
|
||||
businessSecondsFormatted: '10d 20h 38m 14.9s',
|
||||
differenceFormatted: '28d 16h 38m 13.9s',
|
||||
differenceSeconds: 2479093.999,
|
||||
totalDifference: {
|
||||
days: 29.69321758101852,
|
||||
hours: 712.6372219444445,
|
||||
minutes: 42758.233316666665,
|
||||
months: 0.9578457284199522,
|
||||
seconds: 2565493.999,
|
||||
weeks: 4.241888225859788,
|
||||
years: 0.08135128104388635,
|
||||
},
|
||||
totalDifferenceFormatted: '29d 16h 38m 13.9s',
|
||||
holidays,
|
||||
...daysInfos,
|
||||
saturdays: [
|
||||
'2024-08-03',
|
||||
'2024-08-10',
|
||||
'2024-08-17',
|
||||
'2024-08-24',
|
||||
],
|
||||
});
|
||||
expect(diffDateTimes({
|
||||
date1,
|
||||
date2,
|
||||
country: 'FR',
|
||||
businessTimezone: 'Europe/Paris',
|
||||
includeEndDate: true,
|
||||
includeWeekDays: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
|
||||
includeHolidays: false,
|
||||
businessStartHour: 9,
|
||||
businessEndHour: 18,
|
||||
})).to.deep.eq({
|
||||
startDate: date1,
|
||||
endDate: date2,
|
||||
businessDays: 21.959691358024692,
|
||||
businessHours: 197.63722222222222,
|
||||
businessSeconds: 711494,
|
||||
businessSecondsFormatted: '8d 5h 38m 14s',
|
||||
differenceFormatted: '21d 14h 38m 14s',
|
||||
differenceSeconds: 1867094,
|
||||
...totalDiff1,
|
||||
totalDifferenceFormatted: '30d 10h',
|
||||
holidays,
|
||||
...daysInfos,
|
||||
});
|
||||
expect(diffDateTimes({
|
||||
date1,
|
||||
date2,
|
||||
country: 'FR',
|
||||
businessTimezone: 'Europe/Paris',
|
||||
includeEndDate: true,
|
||||
includeWeekDays: ['monday'],
|
||||
includeHolidays: false,
|
||||
businessStartHour: 9,
|
||||
businessEndHour: 18,
|
||||
})).to.deep.eq({
|
||||
startDate: date1,
|
||||
endDate: date2,
|
||||
businessDays: 4,
|
||||
businessHours: 36,
|
||||
businessSeconds: 129600,
|
||||
businessSecondsFormatted: '1d 12h',
|
||||
differenceFormatted: '4d',
|
||||
differenceSeconds: 345600,
|
||||
totalDifferenceFormatted: '30d 10h',
|
||||
...totalDiff1,
|
||||
holidays,
|
||||
...daysInfos,
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('countCertainDays', () => {
|
||||
it('compute right number of days', () => {
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 1))).toBe(1);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 2))).toBe(1);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 3))).toBe(2);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 4))).toBe(2);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 5))).toBe(3);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 6))).toBe(3);
|
||||
expect(countCertainDays([1, 3, 5], new Date(2014, 8, 1), new Date(2014, 8, 7))).toBe(3);
|
||||
});
|
||||
});
|
||||
describe('datesByDays', () => {
|
||||
it('compute week days dates', () => {
|
||||
expect(datesByDays(DateTime.utc(2014, 8, 1), DateTime.utc(2014, 8, 31))).to.deep.eq({
|
||||
1: [
|
||||
'2014-08-04',
|
||||
'2014-08-11',
|
||||
'2014-08-18',
|
||||
'2014-08-25',
|
||||
],
|
||||
2: [
|
||||
'2014-08-05',
|
||||
'2014-08-12',
|
||||
'2014-08-19',
|
||||
'2014-08-26',
|
||||
],
|
||||
3: [
|
||||
'2014-08-06',
|
||||
'2014-08-13',
|
||||
'2014-08-20',
|
||||
'2014-08-27',
|
||||
],
|
||||
4: [
|
||||
'2014-08-07',
|
||||
'2014-08-14',
|
||||
'2014-08-21',
|
||||
'2014-08-28',
|
||||
],
|
||||
5: [
|
||||
'2014-08-01',
|
||||
'2014-08-08',
|
||||
'2014-08-15',
|
||||
'2014-08-22',
|
||||
'2014-08-29',
|
||||
],
|
||||
6: [
|
||||
'2014-08-02',
|
||||
'2014-08-09',
|
||||
'2014-08-16',
|
||||
'2014-08-23',
|
||||
'2014-08-30',
|
||||
],
|
||||
7: [
|
||||
'2014-08-03',
|
||||
'2014-08-10',
|
||||
'2014-08-17',
|
||||
'2014-08-24',
|
||||
'2014-08-31',
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,183 +0,0 @@
|
||||
import { DateTime, Interval } from 'luxon';
|
||||
import prettyMilliseconds from 'pretty-ms';
|
||||
import Holidays, { type HolidaysTypes } from 'date-holidays';
|
||||
import _ from 'lodash';
|
||||
import { BusinessTime, type Holiday } from './business-time-calculator';
|
||||
|
||||
interface DateTimeRange {
|
||||
startDate: Date
|
||||
endDate: Date
|
||||
totalDifference: {
|
||||
years: number
|
||||
months: number
|
||||
weeks: number
|
||||
days: number
|
||||
hours: number
|
||||
minutes: number
|
||||
seconds: number
|
||||
}
|
||||
totalDifferenceFormatted: string
|
||||
differenceSeconds: number
|
||||
differenceFormatted: string
|
||||
businessSeconds: number
|
||||
businessSecondsFormatted: string
|
||||
businessHours: number
|
||||
businessDays: number
|
||||
mondays: string[]
|
||||
tuesdays: string[]
|
||||
wednesdays: string[]
|
||||
thursdays: string[]
|
||||
fridays: string[]
|
||||
saturdays: string[]
|
||||
sundays: string[]
|
||||
weekendDays: number
|
||||
weekends: number
|
||||
holidays: HolidaysTypes.Holiday[]
|
||||
}
|
||||
|
||||
export type Weekdays = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
|
||||
export const allDays: Weekdays[] = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
||||
export const allWeekDays: Weekdays[] = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
|
||||
|
||||
export function diffDateTimes({
|
||||
date1,
|
||||
date2,
|
||||
country, state = undefined, region = undefined,
|
||||
businessTimezone,
|
||||
includeEndDate = true,
|
||||
includeWeekDays = allWeekDays,
|
||||
includeHolidays = true,
|
||||
businessStartHour = 9,
|
||||
businessEndHour = 18,
|
||||
|
||||
}: {
|
||||
date1: Date
|
||||
date2: Date
|
||||
country: string
|
||||
state?: string
|
||||
region?: string
|
||||
includeEndDate?: boolean
|
||||
includeWeekDays?: Array<Weekdays>
|
||||
includeHolidays?: boolean
|
||||
businessStartHour: number
|
||||
businessEndHour: number
|
||||
businessTimezone: string
|
||||
}): DateTimeRange {
|
||||
function getHolidaysBetween(date1: DateTime, date2: DateTime) {
|
||||
const startDateTime = date1.startOf('day');
|
||||
const endDateTime = date2.endOf('day');
|
||||
const hd = new Holidays(country, state || '', region || '');
|
||||
let holidays: Array<HolidaysTypes.Holiday> = [];
|
||||
for (let year = startDateTime.year; year <= endDateTime.year; year += 1) {
|
||||
holidays = [...holidays, ...hd.getHolidays(year)];
|
||||
}
|
||||
|
||||
const range = Interval.fromDateTimes(startDateTime, endDateTime);
|
||||
return holidays.filter(h => range.contains(DateTime.fromJSDate(h.start)));
|
||||
}
|
||||
|
||||
const startDateTime = DateTime.fromJSDate(date1);
|
||||
let endDateTime = DateTime.fromJSDate(date2);
|
||||
if (!includeEndDate) {
|
||||
endDateTime = endDateTime.minus({ days: 1 }).endOf('day');
|
||||
}
|
||||
if (endDateTime < startDateTime) {
|
||||
endDateTime = startDateTime;
|
||||
}
|
||||
|
||||
const holidays = getHolidaysBetween(startDateTime, endDateTime);
|
||||
const holidaysDates = holidays.map(h => DateTime.fromJSDate(h.start).toFormat('dd/MM/yyyy') as Holiday);
|
||||
|
||||
const differenceTimeComputer = new BusinessTime({
|
||||
businessDays: includeWeekDays,
|
||||
businessTimezone,
|
||||
holidays: includeHolidays ? holidaysDates : [],
|
||||
businessHours: [0, 24],
|
||||
});
|
||||
const businessTimeComputer = new BusinessTime({
|
||||
businessDays: includeWeekDays,
|
||||
businessTimezone,
|
||||
holidays: includeHolidays ? holidaysDates : [],
|
||||
businessHours: [businessStartHour, businessEndHour],
|
||||
});
|
||||
|
||||
const startEnd = { start: startDateTime, end: endDateTime };
|
||||
|
||||
const totalDifferenceSeconds = endDateTime.diff(startDateTime, 'seconds').toObject().seconds || 0;
|
||||
const totalDifferenceMinutes = endDateTime.diff(startDateTime, 'minutes').toObject().minutes || 0;
|
||||
const totalDifferenceHours = endDateTime.diff(startDateTime, 'hours').toObject().hours || 0;
|
||||
const totalDifferenceDays = endDateTime.diff(startDateTime, 'days').toObject().days || 0;
|
||||
const totalDifferenceWeeks = endDateTime.diff(startDateTime, 'weeks').toObject().weeks || 0;
|
||||
const totalDifferenceMonths = endDateTime.diff(startDateTime, 'months').toObject().months || 0;
|
||||
const totalDifferenceYears = endDateTime.diff(startDateTime, 'years').toObject().years || 0;
|
||||
const differenceSeconds = differenceTimeComputer.computeBusinessSecondsInInterval(startEnd);
|
||||
const businessSeconds = businessTimeComputer.computeBusinessSecondsInInterval(startEnd);
|
||||
const weekDaysDates = datesByDays(startDateTime, endDateTime);
|
||||
const weekendDays = countCertainDays([6, 0], date1, date2);
|
||||
return {
|
||||
startDate: startDateTime.toJSDate(),
|
||||
endDate: endDateTime.toJSDate(),
|
||||
totalDifference: {
|
||||
years: totalDifferenceYears,
|
||||
months: totalDifferenceMonths,
|
||||
weeks: totalDifferenceWeeks,
|
||||
days: totalDifferenceDays,
|
||||
hours: totalDifferenceHours,
|
||||
minutes: totalDifferenceMinutes,
|
||||
seconds: totalDifferenceSeconds,
|
||||
},
|
||||
totalDifferenceFormatted: prettyMilliseconds(totalDifferenceSeconds * 1000),
|
||||
differenceSeconds,
|
||||
differenceFormatted: prettyMilliseconds(differenceSeconds * 1000),
|
||||
businessSeconds,
|
||||
businessSecondsFormatted: prettyMilliseconds(businessSeconds * 1000),
|
||||
businessHours: businessTimeComputer.computeBusinessHoursInInterval(startEnd),
|
||||
businessDays: businessTimeComputer.computeBusinessDaysInInterval(startEnd),
|
||||
mondays: weekDaysDates['1'] || [],
|
||||
tuesdays: weekDaysDates['2'] || [],
|
||||
wednesdays: weekDaysDates['3'] || [],
|
||||
thursdays: weekDaysDates['4'] || [],
|
||||
fridays: weekDaysDates['5'] || [],
|
||||
saturdays: weekDaysDates['6'] || [],
|
||||
sundays: weekDaysDates['7'] || [],
|
||||
weekendDays,
|
||||
weekends: Math.floor(weekendDays / 2),
|
||||
holidays,
|
||||
};
|
||||
}
|
||||
|
||||
// days is an array of weekdays: 0 is Sunday, ..., 6 is Saturday
|
||||
export function countCertainDays(days: Array<0 | 1 | 2 | 3 | 4 | 5 | 6>, d0: Date, d1: Date) {
|
||||
const ndays = 1 + Math.round((d1.getTime() - d0.getTime()) / (24 * 3600 * 1000));
|
||||
const sum = function (a: number, b: number) {
|
||||
return a + Math.floor((ndays + (d0.getDay() + 6 - b) % 7) / 7);
|
||||
};
|
||||
return days.reduce(sum, 0);
|
||||
}
|
||||
|
||||
export function datesByDays(startDateTime: DateTime, endDateTime: DateTime) {
|
||||
const dates = Interval.fromDateTimes(startDateTime.startOf('day'), endDateTime.endOf('day')).splitBy({ day: 1 }).map(d => d.start);
|
||||
return _.chain(dates)
|
||||
.groupBy(d => d?.weekday)
|
||||
.map((dates, weekday) => ({ weekday, dates }))
|
||||
.reduce((prev, curr) => ({ ...prev, [curr.weekday]: mapToJSDate(curr.dates) }), {} as { [weekday: string]: string[] })
|
||||
.value();
|
||||
}
|
||||
function mapToJSDate(dates: (DateTime | null)[]): string[] {
|
||||
return dates.map(d => d?.toISODate() || '').filter(d => d);
|
||||
}
|
||||
|
||||
export function getSupportedCountries() {
|
||||
const hd = new Holidays();
|
||||
return Object.entries(hd.getCountries()).map(([code, name]) => ({ value: code, label: name }));
|
||||
}
|
||||
|
||||
export function getSupportedStates(country: string) {
|
||||
const hd = new Holidays();
|
||||
return Object.entries(hd.getStates(country) || []).map(([code, name]) => ({ value: code, label: name }));
|
||||
}
|
||||
|
||||
export function getSupportedRegions(country: string, state: string) {
|
||||
const hd = new Holidays();
|
||||
return Object.entries(hd.getRegions(country, state) || []).map(([code, name]) => ({ value: code, label: name }));
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import ctz from 'countries-and-timezones';
|
||||
import { type Weekdays, allWeekDays, diffDateTimes, getSupportedCountries, getSupportedRegions, getSupportedStates } from './days-calculator.service';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
const inputDateRange = ref<[number, number]>([now, now + 86400]);
|
||||
|
||||
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const allTimezones = Object.values(ctz.getAllTimezones()).map(tz => ({
|
||||
value: tz.name,
|
||||
label: `${tz.name === browserTimezone ? 'Browser TZ - ' : ''}${tz.name} (${tz.utcOffset === tz.dstOffset ? tz.utcOffsetStr : `${tz.utcOffsetStr}/${tz.dstOffsetStr}`})`,
|
||||
}));
|
||||
const allCountries = ref(getSupportedCountries());
|
||||
const country = useQueryParamOrStorage({ name: 'country', storageName: 'days-calc:ctr', defaultValue: 'FR' });
|
||||
const possibleStates = computed(() => getSupportedStates(country.value));
|
||||
const state = useQueryParamOrStorage({ name: 'state', storageName: 'days-calc:st', defaultValue: '' });
|
||||
const possibleRegions = computed(() => getSupportedRegions(country.value, state.value));
|
||||
const region = useQueryParamOrStorage({ name: 'region', storageName: 'days-calc:reg', defaultValue: '' });
|
||||
const includeEndDate = useQueryParamOrStorage({ name: 'includeend', storageName: 'days-calc:end', defaultValue: false });
|
||||
const includeWeekDays = useQueryParamOrStorage<Weekdays[]>({ name: 'days', storageName: 'days-calc:days', defaultValue: allWeekDays });
|
||||
const includeHolidays = useQueryParamOrStorage({ name: 'includehol', storageName: 'days-calc:hol', defaultValue: true });
|
||||
const businessStartHour = useQueryParamOrStorage({ name: 'businessstart', storageName: 'days-calc:bss', defaultValue: 9 });
|
||||
const businessEndHour = useQueryParamOrStorage({ name: 'businessstend', storageName: 'days-calc:bse', defaultValue: 18 });
|
||||
const businessTimezone = useQueryParamOrStorage({ name: 'tz', storageName: 'days-calc:tz', defaultValue: browserTimezone });
|
||||
const error = ref('');
|
||||
const resultDaysDiff = computed(() => {
|
||||
try {
|
||||
return diffDateTimes({
|
||||
date1: new Date(inputDateRange.value[0] / 1000 * 1000),
|
||||
date2: new Date(inputDateRange.value[1] / 1000 * 1000),
|
||||
country: country.value,
|
||||
state: state.value,
|
||||
region: region.value,
|
||||
businessTimezone: businessTimezone.value,
|
||||
includeEndDate: includeEndDate.value,
|
||||
includeWeekDays: includeWeekDays.value,
|
||||
includeHolidays: includeHolidays.value,
|
||||
businessStartHour: businessStartHour.value,
|
||||
businessEndHour: businessEndHour.value,
|
||||
});
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = e.toString();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const inputProps = {
|
||||
'labelPosition': 'left',
|
||||
'labelWidth': '170px',
|
||||
'readonly': true,
|
||||
'mb-2': '',
|
||||
} as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-card title="Dates Interval" mb-2>
|
||||
<n-form-item label="Date Range:" label-placement="left" label-width="100px" label-align="left" mb-1>
|
||||
<n-date-picker v-model:value="inputDateRange" type="datetimerange" />
|
||||
</n-form-item>
|
||||
|
||||
<c-select
|
||||
v-model:value="country"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
searchable
|
||||
label="Country:"
|
||||
:options="allCountries"
|
||||
mb-1
|
||||
/>
|
||||
<c-select
|
||||
v-if="possibleStates?.length > 0"
|
||||
v-model:value="state"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
searchable
|
||||
label="State:"
|
||||
:options="possibleStates"
|
||||
placeholder="Select a specific state or let empty for general info"
|
||||
mb-1
|
||||
/>
|
||||
<c-select
|
||||
v-if="possibleRegions?.length > 0"
|
||||
v-model:value="region"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
searchable
|
||||
label="Region:"
|
||||
:options="possibleRegions"
|
||||
mb-1
|
||||
/>
|
||||
<c-select
|
||||
v-model:value="businessTimezone"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
searchable
|
||||
label="Timezone:"
|
||||
:options="allTimezones"
|
||||
mb-2
|
||||
/>
|
||||
|
||||
<div mb-2 flex items-baseline gap-2>
|
||||
<n-form-item label="Business Start Hour:" label-placement="left" flex-1>
|
||||
<n-input-number v-model:value="businessStartHour" :min="0" :max="24" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Business End Hour:" label-placement="left" flex-1>
|
||||
<n-input-number v-model:value="businessEndHour" :min="0" :max="24" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<div mb-2 flex items-baseline justify-center gap-2>
|
||||
<n-checkbox v-model:checked="includeHolidays">
|
||||
Include Holidays
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="includeEndDate">
|
||||
Include End Date
|
||||
</n-checkbox>
|
||||
</div>
|
||||
|
||||
<c-card title="Weekdays">
|
||||
<n-checkbox-group v-model:value="includeWeekDays">
|
||||
<n-space justify="center">
|
||||
<n-checkbox value="monday" label="Monday" />
|
||||
<n-checkbox value="tuesday" label="Tuesday" />
|
||||
<n-checkbox value="wednesday" label="Wednesday" />
|
||||
<n-checkbox value="thursday" label="Thursday" />
|
||||
<n-checkbox value="friday" label="Friday" />
|
||||
<n-checkbox value="saturday" label="Saturday" />
|
||||
<n-checkbox value="sunday" label="Sunday" />
|
||||
</n-space>
|
||||
</n-checkbox-group>
|
||||
</c-card>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-alert v-if="error">
|
||||
{{ error }}
|
||||
</c-alert>
|
||||
|
||||
<c-card v-if="resultDaysDiff" title="Result">
|
||||
<input-copyable v-bind="inputProps" label="Start Date" :value="resultDaysDiff.startDate" />
|
||||
<input-copyable v-bind="inputProps" label="Start Date (ISO)" :value="resultDaysDiff.startDate.toISOString()" />
|
||||
<input-copyable v-bind="inputProps" label="End Date" :value="resultDaysDiff.endDate" />
|
||||
<input-copyable v-bind="inputProps" label="End Date (ISO)" :value="resultDaysDiff.endDate.toISOString()" />
|
||||
<n-divider />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Seconds" :value="resultDaysDiff.totalDifference.seconds" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Minutes" :value="resultDaysDiff.totalDifference.minutes" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Hours" :value="resultDaysDiff.totalDifference.hours" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Days" :value="resultDaysDiff.totalDifference.days" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Weeks" :value="resultDaysDiff.totalDifference.weeks" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Months" :value="resultDaysDiff.totalDifference.months" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference Years" :value="resultDaysDiff.totalDifference.years" />
|
||||
<input-copyable v-bind="inputProps" label="Total Difference" :value="resultDaysDiff.totalDifferenceFormatted" />
|
||||
<n-divider />
|
||||
<input-copyable v-bind="inputProps" label="Difference Seconds" :value="resultDaysDiff.differenceSeconds" />
|
||||
<input-copyable v-bind="inputProps" label="Difference " :value="resultDaysDiff.differenceFormatted" />
|
||||
<n-divider />
|
||||
<input-copyable v-bind="inputProps" label="Business Seconds" :value="resultDaysDiff.businessSeconds" />
|
||||
<input-copyable v-bind="inputProps" label="Business Time" :value="resultDaysDiff.businessSecondsFormatted" />
|
||||
<input-copyable v-bind="inputProps" label="Business Hours" :value="resultDaysDiff.businessHours" />
|
||||
<input-copyable v-bind="inputProps" label="Business Days" :value="resultDaysDiff.businessDays" />
|
||||
<n-divider />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Mondays" :value="resultDaysDiff.mondays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Tuesdays" :value="resultDaysDiff.tuesdays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Wednesdays" :value="resultDaysDiff.wednesdays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Thursdays" :value="resultDaysDiff.thursdays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Fridays" :value="resultDaysDiff.fridays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Saturdays" :value="resultDaysDiff.saturdays" />
|
||||
<input-copyable v-bind="inputProps" placeholder="None" label="Sundays" :value="resultDaysDiff.sundays" />
|
||||
<n-divider />
|
||||
<input-copyable v-bind="inputProps" label="Weekend Days" :value="resultDaysDiff.weekendDays" />
|
||||
<input-copyable v-bind="inputProps" label="Full Weekends" :value="resultDaysDiff.weekends" />
|
||||
<c-card v-if="resultDaysDiff.holidays?.length" title="Holidays in period">
|
||||
<ul>
|
||||
<li v-for="(holiday, index) in resultDaysDiff.holidays" :key="index">
|
||||
{{ holiday.date }}: {{ holiday.name }} ({{ holiday.type }})
|
||||
</li>
|
||||
</ul>
|
||||
</c-card>
|
||||
</c-card>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Calendar } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Days Calculator',
|
||||
path: '/days-calculator',
|
||||
description: 'Calculate days interval, holidays, difference, business times',
|
||||
keywords: ['days', 'interval', 'month', 'year', 'difference', 'holidays', 'calculator'],
|
||||
component: () => import('./days-calculator.vue'),
|
||||
icon: Calendar,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -1,371 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { computeDuration } from './duration-calculator.service';
|
||||
|
||||
const zeroResult = {
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0,
|
||||
hours: 0,
|
||||
iso8601Duration: 'P0Y0M0DT0H0M0S',
|
||||
milliseconds: 0,
|
||||
minutes: 0,
|
||||
prettified: '0ms',
|
||||
prettifiedColonNotation: '0:00',
|
||||
prettifiedDaysColon: '00:00:00',
|
||||
prettifiedHoursColon: '00:00:00',
|
||||
prettifiedVerbose: '0 milliseconds',
|
||||
seconds: 0,
|
||||
weeks: 0,
|
||||
years: 0,
|
||||
},
|
||||
};
|
||||
|
||||
describe('duration-calculator', () => {
|
||||
describe('computeDuration', () => {
|
||||
it('should compute correct sum/values', () => {
|
||||
expect(computeDuration('')).to.deep.eq(zeroResult);
|
||||
expect(computeDuration('00:00:00')).to.deep.eq(zeroResult);
|
||||
expect(computeDuration('0h')).to.deep.eq(zeroResult);
|
||||
expect(computeDuration('0s')).to.deep.eq(zeroResult);
|
||||
expect(computeDuration('3600s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.041666666666666664,
|
||||
hours: 1,
|
||||
iso8601Duration: 'P0Y0M0DT1H0M0S',
|
||||
milliseconds: 3600000,
|
||||
minutes: 60,
|
||||
prettified: '1h',
|
||||
prettifiedColonNotation: '1:00:00',
|
||||
prettifiedDaysColon: '01:00:00',
|
||||
prettifiedHoursColon: '01:00:00',
|
||||
prettifiedVerbose: '1 hour',
|
||||
seconds: 3600,
|
||||
weeks: 0.005952380952380952,
|
||||
years: 0.00011415525114155251,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('1h 20m')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.05555555555555555,
|
||||
hours: 1.3333333333333333,
|
||||
iso8601Duration: 'P0Y0M0DT1H20M0S',
|
||||
milliseconds: 4800000,
|
||||
minutes: 80,
|
||||
prettified: '1h 20m',
|
||||
prettifiedColonNotation: '1:20:00',
|
||||
prettifiedDaysColon: '01:20:00',
|
||||
prettifiedHoursColon: '01:20:00',
|
||||
prettifiedVerbose: '1 hour 20 minutes',
|
||||
seconds: 4800,
|
||||
weeks: 0.007936507936507936,
|
||||
years: 0.00015220700152207003,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('01:02:03')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.043090277777777776,
|
||||
hours: 1.0341666666666667,
|
||||
iso8601Duration: 'P0Y0M0DT1H2M3S',
|
||||
milliseconds: 3723000,
|
||||
minutes: 62.05,
|
||||
prettified: '1h 2m 3s',
|
||||
prettifiedColonNotation: '1:02:03',
|
||||
prettifiedDaysColon: '01:02:03',
|
||||
prettifiedHoursColon: '01:02:03',
|
||||
prettifiedVerbose: '1 hour 2 minutes 3 seconds',
|
||||
seconds: 3723,
|
||||
weeks: 0.006155753968253968,
|
||||
years: 0.00011805555555555556,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('-01:02:03')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: -0.043090277777777776,
|
||||
hours: -1.0341666666666667,
|
||||
iso8601Duration: 'P0Y0M0DT1H2M3S',
|
||||
milliseconds: -3723000,
|
||||
minutes: -62.05,
|
||||
prettified: '-1h 2m 3s',
|
||||
prettifiedColonNotation: '-1:02:03',
|
||||
prettifiedDaysColon: '-2:-3:-3',
|
||||
prettifiedHoursColon: '-2:-3:-3',
|
||||
prettifiedVerbose: '-1 hour 2 minutes 3 seconds',
|
||||
seconds: -3723,
|
||||
weeks: -0.006155753968253968,
|
||||
years: -0.00011805555555555556,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('+01:02:05')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.04311342592592592,
|
||||
hours: 1.0347222222222223,
|
||||
iso8601Duration: 'P0Y0M0DT1H2M5S',
|
||||
milliseconds: 3725000,
|
||||
minutes: 62.083333333333336,
|
||||
prettified: '1h 2m 5s',
|
||||
prettifiedColonNotation: '1:02:05',
|
||||
prettifiedDaysColon: '01:02:05',
|
||||
prettifiedHoursColon: '01:02:05',
|
||||
prettifiedVerbose: '1 hour 2 minutes 5 seconds',
|
||||
seconds: 3725,
|
||||
weeks: 0.006159060846560847,
|
||||
years: 0.00011811897513952308,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('25s\n+02:40:00.125\n-10s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.11128616898148148,
|
||||
hours: 2.6708680555555557,
|
||||
iso8601Duration: 'P0Y0M0DT2H40M15.125S',
|
||||
milliseconds: 9615125,
|
||||
minutes: 160.25208333333333,
|
||||
prettified: '2h 40m 15s 125ms',
|
||||
prettifiedColonNotation: '2:40:15.1',
|
||||
prettifiedDaysColon: '02:40:15.125',
|
||||
prettifiedHoursColon: '02:40:15.125',
|
||||
prettifiedVerbose: '2 hours 40 minutes 15 seconds 125 milliseconds',
|
||||
seconds: 9615.125,
|
||||
weeks: 0.01589802414021164,
|
||||
years: 0.00030489361364789447,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('3d 25s\n+00:40:00\n-10s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 3.027951388888889,
|
||||
hours: 72.67083333333333,
|
||||
iso8601Duration: 'P0Y0M3DT0H40M15S',
|
||||
milliseconds: 261615000,
|
||||
minutes: 4360.25,
|
||||
prettified: '3d 40m 15s',
|
||||
prettifiedColonNotation: '3:00:40:15',
|
||||
prettifiedDaysColon: '3d 00:40:15',
|
||||
prettifiedHoursColon: '72:40:15',
|
||||
prettifiedVerbose: '3 days 40 minutes 15 seconds',
|
||||
seconds: 261615,
|
||||
weeks: 0.4325644841269841,
|
||||
years: 0.008295757229832572,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('25s\n+12:40\n-10s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.5279513888888889,
|
||||
hours: 12.670833333333333,
|
||||
iso8601Duration: 'P0Y0M0DT12H40M15S',
|
||||
milliseconds: 45615000,
|
||||
minutes: 760.25,
|
||||
prettified: '12h 40m 15s',
|
||||
prettifiedColonNotation: '12:40:15',
|
||||
prettifiedDaysColon: '12:40:15',
|
||||
prettifiedHoursColon: '12:40:15',
|
||||
prettifiedVerbose: '12 hours 40 minutes 15 seconds',
|
||||
seconds: 45615,
|
||||
weeks: 0.07542162698412698,
|
||||
years: 0.0014464421613394217,
|
||||
},
|
||||
});
|
||||
|
||||
expect(computeDuration('P4DT12H20M20.3S')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 4.514123842592593,
|
||||
hours: 108.33897222222222,
|
||||
iso8601Duration: 'P0Y0M4DT12H20M20.3S',
|
||||
milliseconds: 390020300,
|
||||
minutes: 6500.338333333333,
|
||||
prettified: '4d 12h 20m 20s 300ms',
|
||||
prettifiedColonNotation: '4:12:20:20.3',
|
||||
prettifiedDaysColon: '4d 12:20:20.300',
|
||||
prettifiedHoursColon: '108:20:20.300',
|
||||
prettifiedVerbose: '4 days 12 hours 20 minutes 20 seconds 300 milliseconds',
|
||||
seconds: 390020.3,
|
||||
weeks: 0.6448748346560846,
|
||||
years: 0.012367462582445459,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('25s\n+PT20H\n-10s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.8335069444444444,
|
||||
hours: 20.004166666666666,
|
||||
iso8601Duration: 'P0Y0M0DT20H0M15S',
|
||||
milliseconds: 72015000,
|
||||
minutes: 1200.25,
|
||||
prettified: '20h 15s',
|
||||
prettifiedColonNotation: '20:00:15',
|
||||
prettifiedDaysColon: '20:00:15',
|
||||
prettifiedHoursColon: '20:00:15',
|
||||
prettifiedVerbose: '20 hours 15 seconds',
|
||||
seconds: 72015,
|
||||
weeks: 0.11907242063492063,
|
||||
years: 0.0022835806697108067,
|
||||
},
|
||||
});
|
||||
});
|
||||
it('should report invalid lines', () => {
|
||||
expect(computeDuration('azerr')).to.deep.eq({
|
||||
errors: [
|
||||
'azerr',
|
||||
],
|
||||
total: {
|
||||
days: 0,
|
||||
hours: 0,
|
||||
iso8601Duration: 'P0Y0M0DT0H0M0S',
|
||||
milliseconds: 0,
|
||||
minutes: 0,
|
||||
prettified: '0ms',
|
||||
prettifiedColonNotation: '0:00',
|
||||
prettifiedDaysColon: '00:00:00',
|
||||
prettifiedHoursColon: '00:00:00',
|
||||
prettifiedVerbose: '0 milliseconds',
|
||||
seconds: 0,
|
||||
weeks: 0,
|
||||
years: 0,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('25s\ner\n-10s')).to.deep.eq({
|
||||
errors: [
|
||||
'er',
|
||||
],
|
||||
total: {
|
||||
days: 0.00017361111111111112,
|
||||
hours: 0.004166666666666667,
|
||||
iso8601Duration: 'P0Y0M0DT0H0M15S',
|
||||
milliseconds: 15000,
|
||||
minutes: 0.25,
|
||||
prettified: '15s',
|
||||
prettifiedColonNotation: '0:15',
|
||||
prettifiedDaysColon: '00:00:15',
|
||||
prettifiedHoursColon: '00:00:15',
|
||||
prettifiedVerbose: '15 seconds',
|
||||
seconds: 15,
|
||||
weeks: 0.0000248015873015873,
|
||||
years: 4.756468797564688e-7,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('25s\n+00:40:00\ner')).to.deep.eq({
|
||||
errors: [
|
||||
'er',
|
||||
],
|
||||
total: {
|
||||
days: 0.02806712962962963,
|
||||
hours: 0.6736111111111112,
|
||||
iso8601Duration: 'P0Y0M0DT0H40M25S',
|
||||
milliseconds: 2425000,
|
||||
minutes: 40.416666666666664,
|
||||
prettified: '40m 25s',
|
||||
prettifiedColonNotation: '40:25',
|
||||
prettifiedDaysColon: '00:40:25',
|
||||
prettifiedHoursColon: '00:40:25',
|
||||
prettifiedVerbose: '40 minutes 25 seconds',
|
||||
seconds: 2425,
|
||||
weeks: 0.004009589947089947,
|
||||
years: 0.00007689624556062913,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('ty\n+12:40\n-10s')).to.deep.eq({
|
||||
errors: [
|
||||
'ty',
|
||||
],
|
||||
total: {
|
||||
days: 0.5276620370370371,
|
||||
hours: 12.66388888888889,
|
||||
iso8601Duration: 'P0Y0M0DT12H39M50S',
|
||||
milliseconds: 45590000,
|
||||
minutes: 759.8333333333334,
|
||||
prettified: '12h 39m 50s',
|
||||
prettifiedColonNotation: '12:39:50',
|
||||
prettifiedDaysColon: '12:39:50',
|
||||
prettifiedHoursColon: '12:39:50',
|
||||
prettifiedVerbose: '12 hours 39 minutes 50 seconds',
|
||||
seconds: 45590,
|
||||
weeks: 0.075380291005291,
|
||||
years: 0.0014456494165398274,
|
||||
},
|
||||
});
|
||||
});
|
||||
it('support comment lines (#)', () => {
|
||||
expect(computeDuration('25s\n # comment\n-10s')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.00017361111111111112,
|
||||
hours: 0.004166666666666667,
|
||||
iso8601Duration: 'P0Y0M0DT0H0M15S',
|
||||
milliseconds: 15000,
|
||||
minutes: 0.25,
|
||||
prettified: '15s',
|
||||
prettifiedColonNotation: '0:15',
|
||||
prettifiedDaysColon: '00:00:15',
|
||||
prettifiedHoursColon: '00:00:15',
|
||||
prettifiedVerbose: '15 seconds',
|
||||
seconds: 15,
|
||||
weeks: 0.0000248015873015873,
|
||||
years: 4.756468797564688e-7,
|
||||
},
|
||||
});
|
||||
});
|
||||
it('support timespan format d.hh:mm:ss.fff', () => {
|
||||
expect(computeDuration('3.12:12:12\n-1.12:12:12\n+0:0:0.125')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 2.000001446759259,
|
||||
hours: 48.000034722222225,
|
||||
iso8601Duration: 'P0Y0M2DT0H0M0.125S',
|
||||
milliseconds: 172800125,
|
||||
minutes: 2880.0020833333333,
|
||||
prettified: '2d 125ms',
|
||||
prettifiedColonNotation: '2:00:00:00.1',
|
||||
prettifiedDaysColon: '2d 00:00:00.125',
|
||||
prettifiedHoursColon: '48:00:00.125',
|
||||
prettifiedVerbose: '2 days 125 milliseconds',
|
||||
seconds: 172800.125,
|
||||
weeks: 0.2857144923941799,
|
||||
years: 0.005479456018518519,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('12:12:12.1')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.5084733796296297,
|
||||
hours: 12.20336111111111,
|
||||
iso8601Duration: 'P0Y0M0DT12H12M12.1S',
|
||||
milliseconds: 43932100,
|
||||
minutes: 732.2016666666667,
|
||||
prettified: '12h 12m 12s 100ms',
|
||||
prettifiedColonNotation: '12:12:12.1',
|
||||
prettifiedDaysColon: '12:12:12.100',
|
||||
prettifiedHoursColon: '12:12:12.100',
|
||||
prettifiedVerbose: '12 hours 12 minutes 12 seconds 100 milliseconds',
|
||||
seconds: 43932.1,
|
||||
weeks: 0.07263905423280423,
|
||||
years: 0.0013930777524099442,
|
||||
},
|
||||
});
|
||||
expect(computeDuration('12:12:12.12')).to.deep.eq({
|
||||
errors: [],
|
||||
total: {
|
||||
days: 0.5084736111111111,
|
||||
hours: 12.203366666666666,
|
||||
iso8601Duration: 'P0Y0M0DT12H12M12.12S',
|
||||
milliseconds: 43932120,
|
||||
minutes: 732.202,
|
||||
prettified: '12h 12m 12s 120ms',
|
||||
prettifiedColonNotation: '12:12:12.1',
|
||||
prettifiedDaysColon: '12:12:12.120',
|
||||
prettifiedHoursColon: '12:12:12.120',
|
||||
prettifiedVerbose: '12 hours 12 minutes 12 seconds 120 milliseconds',
|
||||
seconds: 43932.12,
|
||||
weeks: 0.0726390873015873,
|
||||
years: 0.001393078386605784,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,132 +0,0 @@
|
||||
import parse from 'parse-duration';
|
||||
import prettyMilliseconds from 'pretty-ms';
|
||||
import { formatISODuration, intervalToDuration } from 'date-fns';
|
||||
import * as iso8601Duration from 'duration-fns';
|
||||
|
||||
interface ConvertedDuration {
|
||||
prettified: string
|
||||
prettifiedVerbose: string
|
||||
prettifiedColonNotation: string
|
||||
prettifiedDaysColon: string
|
||||
prettifiedHoursColon: string
|
||||
iso8601Duration: string
|
||||
milliseconds: number
|
||||
seconds: number
|
||||
minutes: number
|
||||
hours: number
|
||||
days: number
|
||||
weeks: number
|
||||
years: number
|
||||
}
|
||||
|
||||
interface DurationLine {
|
||||
rawLine: string
|
||||
cleanedDuration: string
|
||||
sign: number
|
||||
durationMS: number | null
|
||||
isValid: boolean
|
||||
}
|
||||
|
||||
export function computeDuration(s: string): {
|
||||
total: ConvertedDuration
|
||||
errors: string[]
|
||||
} {
|
||||
const lines: DurationLine[] = s.split('\n').filter(l => l && !/^\s*#/.test(l)).map((l) => {
|
||||
const isNeg = /^\s*-/.test(l);
|
||||
const cleanedDuration = l.replace(/^\s*[+-]\s*/, '').replace(/\s*#.*$/, ''); // NOSONAR
|
||||
const durationMS = convertDurationMS(cleanedDuration);
|
||||
return {
|
||||
rawLine: l,
|
||||
cleanedDuration,
|
||||
sign: isNeg ? -1 : 1,
|
||||
durationMS,
|
||||
isValid: durationMS !== null,
|
||||
};
|
||||
});
|
||||
|
||||
const sumMS = lines.map(l => ({ durationMS: l.durationMS || 0, sign: l.sign })).reduce(
|
||||
(prev, curr) => ({
|
||||
durationMS: prev.durationMS + curr.durationMS * curr.sign,
|
||||
sign: 1,
|
||||
}),
|
||||
{
|
||||
sign: 1,
|
||||
durationMS: 0,
|
||||
});
|
||||
|
||||
return {
|
||||
total: prepareDurationResult(sumMS.durationMS),
|
||||
errors: lines.filter(l => !l.isValid).map(l => l.rawLine),
|
||||
};
|
||||
}
|
||||
|
||||
function convertDurationMS(s: string): number | null {
|
||||
const hoursHandled = s.trim().replace(/^(?:(\d+)\.)?(\d+):(\d+)(?::(\d+)(?:\.(\d+))?)?$/g,
|
||||
(_, d, h, m, s, ms) => {
|
||||
const timeArr: string[] = [];
|
||||
const addPart = (part: string, unit: string) => {
|
||||
const num = Number.parseInt(part, 10);
|
||||
if (Number.isNaN(num)) {
|
||||
return;
|
||||
}
|
||||
|
||||
timeArr.push(`${num}${unit}`);
|
||||
};
|
||||
addPart(d, 'd');
|
||||
addPart(h, 'h');
|
||||
addPart(m, 'm');
|
||||
addPart(s, 's');
|
||||
addPart(ms?.padEnd(3, '0'), 'ms');
|
||||
return timeArr.join(' ');
|
||||
});
|
||||
if (!hoursHandled) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
return iso8601Duration.toMilliseconds(iso8601Duration.parse(hoursHandled));
|
||||
}
|
||||
catch (_) {
|
||||
const result = parse(hoursHandled);
|
||||
if (typeof result === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
function prepareDurationResult(durationMS: number): ConvertedDuration {
|
||||
const dateFnsDuration = intervalToDuration({ start: 0, end: durationMS });
|
||||
dateFnsDuration.seconds = (dateFnsDuration.seconds || 0) + (durationMS % 1000) / 1000;
|
||||
return {
|
||||
prettified: prettyMilliseconds(durationMS, { formatSubMilliseconds: true }),
|
||||
prettifiedVerbose: prettyMilliseconds(durationMS, { verbose: true, formatSubMilliseconds: true }),
|
||||
prettifiedColonNotation: prettyMilliseconds(durationMS, { colonNotation: true, formatSubMilliseconds: true }),
|
||||
prettifiedDaysColon: hhmmss(durationMS, true),
|
||||
prettifiedHoursColon: hhmmss(durationMS, false),
|
||||
iso8601Duration: formatISODuration(dateFnsDuration),
|
||||
milliseconds: durationMS,
|
||||
seconds: durationMS / 1000,
|
||||
minutes: durationMS / (1000 * 60),
|
||||
hours: durationMS / (1000 * 3600),
|
||||
days: durationMS / (1000 * 86400),
|
||||
weeks: durationMS / (1000 * 86400 * 7),
|
||||
years: durationMS / (1000 * 86400 * 365),
|
||||
};
|
||||
}
|
||||
|
||||
function hhmmss(milliseconds: number, days: boolean) {
|
||||
const padNumber = (n: number) => n.toString().padStart(2, '0');
|
||||
const ms = milliseconds % 1000;
|
||||
const seconds = milliseconds / 1000;
|
||||
let h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor(seconds % 3600 / 60);
|
||||
const s = Math.floor(seconds % 3600 % 60);
|
||||
let d = 0;
|
||||
if (days) {
|
||||
d = Math.floor(h / 24);
|
||||
h = h % 24;
|
||||
}
|
||||
const formatted_d = d > 0 ? `${d}d ` : '';
|
||||
const formatted_ms = ms > 0 ? `.${ms}` : '';
|
||||
return `${formatted_d}${padNumber(h)}:${padNumber(m)}:${padNumber(s)}${formatted_ms}`;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computeDuration } from './duration-calculator.service';
|
||||
|
||||
const inputDurations = ref('');
|
||||
const result = computed(() => computeDuration(inputDurations.value));
|
||||
const errors = computed(() => result.value.errors.join('\n'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="inputDurations"
|
||||
multiline
|
||||
rows="5"
|
||||
label="Duration(s)"
|
||||
placeholder="Please enter duration, one per line with optional sign"
|
||||
mb-2
|
||||
/>
|
||||
<n-p>Supports: comment (# line), HH:MM:SS.FFF, 3d 1h 3s..., P4DT12H20M20.3S..</n-p>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-card title="Total">
|
||||
<input-copyable label="Prettified" :value="result.total.prettified" />
|
||||
<input-copyable label="Prettified (full)" :value="result.total.prettifiedVerbose" />
|
||||
<input-copyable label="Prettified (colon)" :value="result.total.prettifiedColonNotation" />
|
||||
<input-copyable label="Prettified (days)" :value="result.total.prettifiedDaysColon" />
|
||||
<input-copyable label="Prettified (hours)" :value="result.total.prettifiedHoursColon" />
|
||||
<input-copyable label="Prettified (ISO8601)" :value="result.total.iso8601Duration" />
|
||||
<input-copyable label="Milliseconds" :value="result.total.milliseconds" />
|
||||
<input-copyable label="Seconds" :value="result.total.seconds" />
|
||||
<input-copyable label="Minutes" :value="result.total.minutes" />
|
||||
<input-copyable label="Hours" :value="result.total.hours" />
|
||||
<input-copyable label="Days" :value="result.total.days" />
|
||||
<input-copyable label="Weeks" :value="result.total.weeks" />
|
||||
<input-copyable label="Years" :value="result.total.years" />
|
||||
</c-card>
|
||||
|
||||
<c-card title="Lines errors" mb-2>
|
||||
<textarea-copyable :value="errors" />
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { CalendarTime } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Duration Calculator',
|
||||
path: '/duration-calculator',
|
||||
description: 'Calculate/parse durations',
|
||||
keywords: ['duration', 'iso', '8601', 'time', 'calculator'],
|
||||
component: () => import('./duration-calculator.vue'),
|
||||
icon: CalendarTime,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
+13
-12
@@ -2,9 +2,9 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
import { tool as daysCalculator } from './days-calculator';
|
||||
import { tool as dateDurationCalculator } from './date-duration-calculator';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||
import { tool as xmlToJson } from './xml-to-json';
|
||||
@@ -12,7 +12,6 @@ import { tool as jsonToXml } from './json-to-xml';
|
||||
import { tool as regexTester } from './regex-tester';
|
||||
import { tool as regexMemo } from './regex-memo';
|
||||
import { tool as markdownToHtml } from './markdown-to-html';
|
||||
import { tool as durationCalculator } from './duration-calculator';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||
@@ -87,6 +86,7 @@ import { tool as urlParser } from './url-parser';
|
||||
import { tool as uuidGenerator } from './uuid-generator';
|
||||
import { tool as macAddressLookup } from './mac-address-lookup';
|
||||
import { tool as xmlFormatter } from './xml-formatter';
|
||||
import { tool as cidrInCidr } from './cidr-in-cidr';
|
||||
import { tool as yamlViewer } from './yaml-viewer';
|
||||
|
||||
export const toolsByCategory: ToolCategory[] = [
|
||||
@@ -165,7 +165,15 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Network',
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
|
||||
components: [
|
||||
ipv4SubnetCalculator,
|
||||
ipv4AddressConverter,
|
||||
cidrInCidr,
|
||||
ipv4RangeExpander,
|
||||
macAddressLookup,
|
||||
macAddressGenerator,
|
||||
ipv6UlaGenerator,
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
@@ -173,14 +181,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Measurement',
|
||||
components: [
|
||||
chronometer,
|
||||
temperatureConverter,
|
||||
daysCalculator,
|
||||
durationCalculator,
|
||||
dateDurationCalculator,
|
||||
benchmarkBuilder,
|
||||
],
|
||||
components: [chronometer, temperatureConverter, benchmarkBuilder],
|
||||
},
|
||||
{
|
||||
name: 'Text',
|
||||
|
||||
@@ -151,7 +151,7 @@ function onSearchInput() {
|
||||
>
|
||||
<div flex-1 truncate>
|
||||
<slot name="displayed-value">
|
||||
<input v-if="searchable && isOpen" ref="searchInputRef" v-model="searchQuery" type="text" placeholder="Search..." class="search-input" w-full color-current lh-normal @input="onSearchInput">
|
||||
<input v-if="searchable && isOpen" ref="searchInputRef" v-model="searchQuery" type="text" placeholder="Search..." class="search-input" w-full lh-normal color-current @input="onSearchInput">
|
||||
<span v-else-if="selectedOption" lh-normal>
|
||||
{{ selectedOption.label }}
|
||||
</span>
|
||||
|
||||
@@ -39,7 +39,7 @@ const headers = computed(() => {
|
||||
<template>
|
||||
<div class="relative overflow-x-auto rounded">
|
||||
<table class="w-full border-collapse text-left text-sm text-gray-500 dark:text-gray-400" role="table" :aria-label="description">
|
||||
<thead v-if="!hideHeaders" class="bg-#ffffff text-gray-700 uppercase dark:bg-#333333 dark:text-gray-400" border-b="1px solid dark:transparent #efeff5">
|
||||
<thead v-if="!hideHeaders" class="bg-#ffffff uppercase text-gray-700 dark:bg-#333333 dark:text-gray-400" border-b="1px solid dark:transparent #efeff5">
|
||||
<tr>
|
||||
<th v-for="header in headers" :key="header.key" scope="col" class="px-6 py-3 text-xs">
|
||||
{{ header.label }}
|
||||
|
||||
Reference in new issue
Block a user