From a520b9148cf42b3aa2b2535d97dad6bcd0e8806f Mon Sep 17 00:00:00 2001 From: Mehdi M Date: Sat, 14 Oct 2023 00:19:49 +0200 Subject: [PATCH 01/39] Use Temporal API polyfill for development purpose --- package.json | 3 +++ pnpm-lock.yaml | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/package.json b/package.json index 22b081c..1b3548b 100644 --- a/package.json +++ b/package.json @@ -65,5 +65,8 @@ "overrides": { "has": "npm:@nolyfill/has@latest" } + }, + "dependencies": { + "@js-temporal/polyfill": "^0.4.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fd8983d..8787266 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,11 @@ settings: overrides: has: npm:@nolyfill/has@latest +dependencies: + '@js-temporal/polyfill': + specifier: ^0.4.4 + version: 0.4.4 + devDependencies: '@size-limit/preset-small-lib': specifier: ^9.0.0 @@ -568,6 +573,14 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true + /@js-temporal/polyfill@0.4.4: + resolution: {integrity: sha512-2X6bvghJ/JAoZO52lbgyAPFj8uCflhTo2g7nkFzEQdXd/D8rEeD4HtmTEpmtGCva260fcd66YNXBOYdnmHqSOg==} + engines: {node: '>=12'} + dependencies: + jsbi: 4.3.0 + tslib: 2.6.2 + dev: false + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1556,6 +1569,10 @@ packages: argparse: 2.0.1 dev: true + /jsbi@4.3.0: + resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} + dev: false + /json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} dev: true @@ -2242,6 +2259,10 @@ packages: read-pkg-up: 7.0.1 dev: true + /tslib@2.6.2: + resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + dev: false + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} From 45460b71b00e33961e6fafae57b2f05d18375005 Mon Sep 17 00:00:00 2001 From: Mehdi M Date: Sat, 14 Oct 2023 03:02:32 +0200 Subject: [PATCH 02/39] Start `duration` using the Temporal API --- src/temporal/duration.js | 84 ++++++++++ src/temporal/index.js | 1 + tests/temporal/index.test.js | 302 +++++++++++++++++++++++++++++++++++ 3 files changed, 387 insertions(+) create mode 100644 src/temporal/duration.js create mode 100644 src/temporal/index.js create mode 100644 tests/temporal/index.test.js diff --git a/src/temporal/duration.js b/src/temporal/duration.js new file mode 100644 index 0000000..c6abb72 --- /dev/null +++ b/src/temporal/duration.js @@ -0,0 +1,84 @@ +/** + * @todo + * Continue the work once the following issue is clarified: + * https://github.com/tc39/proposal-temporal/issues/2711: + * - check decimal parameters + * - check balancing (https://tc39.es/proposal-temporal/docs/balancing.html) + * - add support for sub-second units (ms, mis, ns) + */ + +import { Temporal, Intl, toTemporalInstant } from '@js-temporal/polyfill' + +// Date.prototype.toTemporalInstant = toTemporalInstant + +/** + * Create `datetime="P3DT2H8M32.541S"` duration attribute for `