@fedify/vocab-runtime 2.0.36-dev.2530 → 2.0.36-dev.2551
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/mod.cjs +1 -1
- package/dist/mod.js +1 -1
- package/dist/temporal.cjs +2 -1
- package/dist/temporal.d.cts +2 -1
- package/dist/temporal.d.ts +2 -1
- package/dist/temporal.js +2 -1
- package/dist/tests/{body-KJu7BVrD.cjs → body-5wwZdMK0.cjs} +1 -1
- package/dist/tests/{body-aEN-Jw2f.mjs → body-DqkK9XBY.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/docloader.test.cjs +2 -2
- package/dist/tests/docloader.test.mjs +2 -2
- package/dist/tests/{request-C1QT7ro7.cjs → request-BNAT7gZ3.cjs} +1 -1
- package/dist/tests/{request-DMfShbXT.mjs → request-BiuryHCs.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/temporal.test.cjs +50 -26
- package/dist/tests/temporal.test.mjs +50 -26
- package/package.json +1 -1
- package/src/temporal.test.ts +57 -28
- package/src/temporal.ts +2 -1
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -4502,7 +4502,7 @@ const preloadedContexts = {
|
|
|
4502
4502
|
//#endregion
|
|
4503
4503
|
//#region deno.json
|
|
4504
4504
|
var name = "@fedify/vocab-runtime";
|
|
4505
|
-
var version = "2.0.36-dev.
|
|
4505
|
+
var version = "2.0.36-dev.2551+8b012df4";
|
|
4506
4506
|
//#endregion
|
|
4507
4507
|
//#region src/request.ts
|
|
4508
4508
|
/**
|
package/dist/mod.js
CHANGED
|
@@ -4498,7 +4498,7 @@ const preloadedContexts = {
|
|
|
4498
4498
|
//#endregion
|
|
4499
4499
|
//#region deno.json
|
|
4500
4500
|
var name = "@fedify/vocab-runtime";
|
|
4501
|
-
var version = "2.0.36-dev.
|
|
4501
|
+
var version = "2.0.36-dev.2551+8b012df4";
|
|
4502
4502
|
//#endregion
|
|
4503
4503
|
//#region src/request.ts
|
|
4504
4504
|
/**
|
package/dist/temporal.cjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
//#region src/temporal.ts
|
|
4
4
|
/**
|
|
5
|
-
* Type guards for `Temporal` namespace objects
|
|
5
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
6
|
+
* `xsd:dateTime` literals.
|
|
6
7
|
*
|
|
7
8
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
8
9
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
package/dist/temporal.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
2
|
//#region src/temporal.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Type guards for `Temporal` namespace objects
|
|
4
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
5
|
+
* `xsd:dateTime` literals.
|
|
5
6
|
*
|
|
6
7
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
7
8
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
package/dist/temporal.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
2
|
//#region src/temporal.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Type guards for `Temporal` namespace objects
|
|
4
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
5
|
+
* `xsd:dateTime` literals.
|
|
5
6
|
*
|
|
6
7
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
7
8
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
package/dist/temporal.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/temporal.ts
|
|
3
3
|
/**
|
|
4
|
-
* Type guards for `Temporal` namespace objects
|
|
4
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
5
|
+
* `xsd:dateTime` literals.
|
|
5
6
|
*
|
|
6
7
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
7
8
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BNAT7gZ3.cjs");
|
|
3
3
|
let _logtape_logtape = require("@logtape/logtape");
|
|
4
4
|
//#region src/body.ts
|
|
5
5
|
/** Decoded JSON body limit: 16 MiB. @internal */
|
package/dist/tests/body.test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_body = require("./body-
|
|
2
|
+
const require_body = require("./body-5wwZdMK0.cjs");
|
|
3
3
|
let node_assert_strict = require("node:assert/strict");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let node_zlib = require("node:zlib");
|
package/dist/tests/body.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as readBoundedText, t as BodyTooLargeError } from "./body-
|
|
1
|
+
import { r as readBoundedText, t as BodyTooLargeError } from "./body-DqkK9XBY.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_body = require("./body-
|
|
2
|
+
const require_request = require("./request-BNAT7gZ3.cjs");
|
|
3
|
+
const require_body = require("./body-5wwZdMK0.cjs");
|
|
4
4
|
const require_esm = require("./esm-4DuocLvD.cjs");
|
|
5
5
|
const require_link = require("./link-qDTmjPw_.cjs");
|
|
6
6
|
const require_url = require("./url-DLuSj57U.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as esm_default } from "./esm-CnLt0wAF.mjs";
|
|
2
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
3
|
-
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-
|
|
2
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-BiuryHCs.mjs";
|
|
3
|
+
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-DqkK9XBY.mjs";
|
|
4
4
|
import { t as HttpHeaderLink } from "./link-CYszIegt.mjs";
|
|
5
5
|
import { t as UrlError } from "./url-DjsVF44Q.mjs";
|
|
6
6
|
import { n as openDirectFetch, r as openPublicFetch, t as createPublicFetch } from "./public-fetch-BUSPlh1C.mjs";
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_chunk.__toESM(node_process);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.0.36-dev.
|
|
6
|
+
var version = "2.0.36-dev.2551+8b012df4";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BNAT7gZ3.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as version, r as getUserAgent } from "./request-
|
|
1
|
+
import { o as version, r as getUserAgent } from "./request-BiuryHCs.mjs";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { deepStrictEqual } from "node:assert";
|
|
@@ -4,7 +4,8 @@ let node_assert = require("node:assert");
|
|
|
4
4
|
let _js_temporal_polyfill = require("@js-temporal/polyfill");
|
|
5
5
|
//#region src/temporal.ts
|
|
6
6
|
/**
|
|
7
|
-
* Type guards for `Temporal` namespace objects
|
|
7
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
8
|
+
* `xsd:dateTime` literals.
|
|
8
9
|
*
|
|
9
10
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
10
11
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
|
@@ -147,30 +148,40 @@ function normalizeDateTimeLiteral(value) {
|
|
|
147
148
|
sign: 0
|
|
148
149
|
}), false);
|
|
149
150
|
});
|
|
151
|
+
const literalsWithOffset = [
|
|
152
|
+
"2024-01-01T10:00Z",
|
|
153
|
+
"2024-01-01T10:00+09:00",
|
|
154
|
+
"2024-01-01T10:00-05:00",
|
|
155
|
+
"2024-01-01T10:00:00Z",
|
|
156
|
+
"2024-01-01T10:00:00+09:00",
|
|
157
|
+
"2024-01-01T10:00:00-05:00",
|
|
158
|
+
"2024-01-01T10:00:00+0900",
|
|
159
|
+
"2024-01-01T10:00:00.123456789Z",
|
|
160
|
+
"2024-01-01t10:00z",
|
|
161
|
+
"2024-01-01 10:00:00Z"
|
|
162
|
+
];
|
|
163
|
+
const literalsWithoutOffset = [
|
|
164
|
+
"2024-01-01T10:00",
|
|
165
|
+
"2024-01-01T10:00:00",
|
|
166
|
+
"2024-01-01T10:00:00.123",
|
|
167
|
+
"2025-01-01 12:34:56"
|
|
168
|
+
];
|
|
169
|
+
const literalsWithoutSeconds = [
|
|
170
|
+
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
171
|
+
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
172
|
+
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
173
|
+
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
174
|
+
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"]
|
|
175
|
+
];
|
|
176
|
+
const literalsWithExpandedYear = [["+002024-01-01T10:00", "+002024-01-01T10:00Z"], ["-000001-01-01T10:00.5Z", "-000001-01-01T10:00:00.5Z"]];
|
|
150
177
|
(0, node_test.test)("normalizeDateTimeLiteral() keeps literals with a UTC offset", () => {
|
|
151
|
-
for (const literal of
|
|
152
|
-
"2024-01-01T10:00Z",
|
|
153
|
-
"2024-01-01T10:00+09:00",
|
|
154
|
-
"2024-01-01T10:00-05:00",
|
|
155
|
-
"2024-01-01T10:00:00Z",
|
|
156
|
-
"2024-01-01T10:00:00+09:00",
|
|
157
|
-
"2024-01-01T10:00:00-05:00",
|
|
158
|
-
"2024-01-01T10:00:00+0900",
|
|
159
|
-
"2024-01-01T10:00:00.123456789Z",
|
|
160
|
-
"2024-01-01t10:00z",
|
|
161
|
-
"2024-01-01 10:00:00Z"
|
|
162
|
-
]) {
|
|
178
|
+
for (const literal of literalsWithOffset) {
|
|
163
179
|
(0, node_assert.strictEqual)(normalizeDateTimeLiteral(literal), literal);
|
|
164
180
|
(0, node_assert.strictEqual)(typeof _js_temporal_polyfill.Temporal.Instant.from(literal), "object");
|
|
165
181
|
}
|
|
166
182
|
});
|
|
167
183
|
(0, node_test.test)("normalizeDateTimeLiteral() treats literals without an offset as UTC", () => {
|
|
168
|
-
for (const literal of
|
|
169
|
-
"2024-01-01T10:00",
|
|
170
|
-
"2024-01-01T10:00:00",
|
|
171
|
-
"2024-01-01T10:00:00.123",
|
|
172
|
-
"2025-01-01 12:34:56"
|
|
173
|
-
]) {
|
|
184
|
+
for (const literal of literalsWithoutOffset) {
|
|
174
185
|
(0, node_assert.strictEqual)(normalizeDateTimeLiteral(literal), `${literal}Z`);
|
|
175
186
|
(0, node_assert.strictEqual)(typeof _js_temporal_polyfill.Temporal.Instant.from(normalizeDateTimeLiteral(literal)), "object");
|
|
176
187
|
}
|
|
@@ -179,16 +190,29 @@ function normalizeDateTimeLiteral(value) {
|
|
|
179
190
|
(0, node_assert.strictEqual)(normalizeDateTimeLiteral("2024-01-01"), "2024-01-01");
|
|
180
191
|
});
|
|
181
192
|
(0, node_test.test)("normalizeDateTimeLiteral() inserts omitted seconds before a fraction", () => {
|
|
182
|
-
for (const [literal, normalized] of
|
|
183
|
-
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
184
|
-
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
185
|
-
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
186
|
-
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
187
|
-
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"]
|
|
188
|
-
]) {
|
|
193
|
+
for (const [literal, normalized] of literalsWithoutSeconds) {
|
|
189
194
|
(0, node_assert.strictEqual)(normalizeDateTimeLiteral(literal), normalized);
|
|
190
195
|
(0, node_assert.strictEqual)(typeof _js_temporal_polyfill.Temporal.Instant.from(normalized), "object");
|
|
191
196
|
}
|
|
192
197
|
(0, node_assert.strictEqual)(normalizeDateTimeLiteral("2024-01-01T10:00:00.5Z"), "2024-01-01T10:00:00.5Z");
|
|
193
198
|
});
|
|
199
|
+
(0, node_test.test)("normalizeDateTimeLiteral() handles expanded years", () => {
|
|
200
|
+
for (const [literal, normalized] of literalsWithExpandedYear) {
|
|
201
|
+
(0, node_assert.strictEqual)(normalizeDateTimeLiteral(literal), normalized);
|
|
202
|
+
(0, node_assert.strictEqual)(typeof _js_temporal_polyfill.Temporal.Instant.from(normalized), "object");
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
(0, node_test.test)("normalizeDateTimeLiteral() is idempotent", () => {
|
|
206
|
+
const literals = [
|
|
207
|
+
...literalsWithOffset,
|
|
208
|
+
...literalsWithoutOffset,
|
|
209
|
+
...literalsWithoutSeconds.map(([literal]) => literal),
|
|
210
|
+
...literalsWithExpandedYear.map(([literal]) => literal),
|
|
211
|
+
"2024-01-01"
|
|
212
|
+
];
|
|
213
|
+
for (const literal of literals) {
|
|
214
|
+
const normalized = normalizeDateTimeLiteral(literal);
|
|
215
|
+
(0, node_assert.strictEqual)(normalizeDateTimeLiteral(normalized), normalized);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
194
218
|
//#endregion
|
|
@@ -3,7 +3,8 @@ import { strictEqual } from "node:assert";
|
|
|
3
3
|
import { Temporal } from "@js-temporal/polyfill";
|
|
4
4
|
//#region src/temporal.ts
|
|
5
5
|
/**
|
|
6
|
-
* Type guards for `Temporal` namespace objects
|
|
6
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
7
|
+
* `xsd:dateTime` literals.
|
|
7
8
|
*
|
|
8
9
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
9
10
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
|
@@ -146,30 +147,40 @@ test("isTemporalDuration() rejects default Object.prototype.toString", () => {
|
|
|
146
147
|
sign: 0
|
|
147
148
|
}), false);
|
|
148
149
|
});
|
|
150
|
+
const literalsWithOffset = [
|
|
151
|
+
"2024-01-01T10:00Z",
|
|
152
|
+
"2024-01-01T10:00+09:00",
|
|
153
|
+
"2024-01-01T10:00-05:00",
|
|
154
|
+
"2024-01-01T10:00:00Z",
|
|
155
|
+
"2024-01-01T10:00:00+09:00",
|
|
156
|
+
"2024-01-01T10:00:00-05:00",
|
|
157
|
+
"2024-01-01T10:00:00+0900",
|
|
158
|
+
"2024-01-01T10:00:00.123456789Z",
|
|
159
|
+
"2024-01-01t10:00z",
|
|
160
|
+
"2024-01-01 10:00:00Z"
|
|
161
|
+
];
|
|
162
|
+
const literalsWithoutOffset = [
|
|
163
|
+
"2024-01-01T10:00",
|
|
164
|
+
"2024-01-01T10:00:00",
|
|
165
|
+
"2024-01-01T10:00:00.123",
|
|
166
|
+
"2025-01-01 12:34:56"
|
|
167
|
+
];
|
|
168
|
+
const literalsWithoutSeconds = [
|
|
169
|
+
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
170
|
+
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
171
|
+
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
172
|
+
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
173
|
+
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"]
|
|
174
|
+
];
|
|
175
|
+
const literalsWithExpandedYear = [["+002024-01-01T10:00", "+002024-01-01T10:00Z"], ["-000001-01-01T10:00.5Z", "-000001-01-01T10:00:00.5Z"]];
|
|
149
176
|
test("normalizeDateTimeLiteral() keeps literals with a UTC offset", () => {
|
|
150
|
-
for (const literal of
|
|
151
|
-
"2024-01-01T10:00Z",
|
|
152
|
-
"2024-01-01T10:00+09:00",
|
|
153
|
-
"2024-01-01T10:00-05:00",
|
|
154
|
-
"2024-01-01T10:00:00Z",
|
|
155
|
-
"2024-01-01T10:00:00+09:00",
|
|
156
|
-
"2024-01-01T10:00:00-05:00",
|
|
157
|
-
"2024-01-01T10:00:00+0900",
|
|
158
|
-
"2024-01-01T10:00:00.123456789Z",
|
|
159
|
-
"2024-01-01t10:00z",
|
|
160
|
-
"2024-01-01 10:00:00Z"
|
|
161
|
-
]) {
|
|
177
|
+
for (const literal of literalsWithOffset) {
|
|
162
178
|
strictEqual(normalizeDateTimeLiteral(literal), literal);
|
|
163
179
|
strictEqual(typeof Temporal.Instant.from(literal), "object");
|
|
164
180
|
}
|
|
165
181
|
});
|
|
166
182
|
test("normalizeDateTimeLiteral() treats literals without an offset as UTC", () => {
|
|
167
|
-
for (const literal of
|
|
168
|
-
"2024-01-01T10:00",
|
|
169
|
-
"2024-01-01T10:00:00",
|
|
170
|
-
"2024-01-01T10:00:00.123",
|
|
171
|
-
"2025-01-01 12:34:56"
|
|
172
|
-
]) {
|
|
183
|
+
for (const literal of literalsWithoutOffset) {
|
|
173
184
|
strictEqual(normalizeDateTimeLiteral(literal), `${literal}Z`);
|
|
174
185
|
strictEqual(typeof Temporal.Instant.from(normalizeDateTimeLiteral(literal)), "object");
|
|
175
186
|
}
|
|
@@ -178,17 +189,30 @@ test("normalizeDateTimeLiteral() keeps literals without a time part", () => {
|
|
|
178
189
|
strictEqual(normalizeDateTimeLiteral("2024-01-01"), "2024-01-01");
|
|
179
190
|
});
|
|
180
191
|
test("normalizeDateTimeLiteral() inserts omitted seconds before a fraction", () => {
|
|
181
|
-
for (const [literal, normalized] of
|
|
182
|
-
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
183
|
-
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
184
|
-
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
185
|
-
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
186
|
-
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"]
|
|
187
|
-
]) {
|
|
192
|
+
for (const [literal, normalized] of literalsWithoutSeconds) {
|
|
188
193
|
strictEqual(normalizeDateTimeLiteral(literal), normalized);
|
|
189
194
|
strictEqual(typeof Temporal.Instant.from(normalized), "object");
|
|
190
195
|
}
|
|
191
196
|
strictEqual(normalizeDateTimeLiteral("2024-01-01T10:00:00.5Z"), "2024-01-01T10:00:00.5Z");
|
|
192
197
|
});
|
|
198
|
+
test("normalizeDateTimeLiteral() handles expanded years", () => {
|
|
199
|
+
for (const [literal, normalized] of literalsWithExpandedYear) {
|
|
200
|
+
strictEqual(normalizeDateTimeLiteral(literal), normalized);
|
|
201
|
+
strictEqual(typeof Temporal.Instant.from(normalized), "object");
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
test("normalizeDateTimeLiteral() is idempotent", () => {
|
|
205
|
+
const literals = [
|
|
206
|
+
...literalsWithOffset,
|
|
207
|
+
...literalsWithoutOffset,
|
|
208
|
+
...literalsWithoutSeconds.map(([literal]) => literal),
|
|
209
|
+
...literalsWithExpandedYear.map(([literal]) => literal),
|
|
210
|
+
"2024-01-01"
|
|
211
|
+
];
|
|
212
|
+
for (const literal of literals) {
|
|
213
|
+
const normalized = normalizeDateTimeLiteral(literal);
|
|
214
|
+
strictEqual(normalizeDateTimeLiteral(normalized), normalized);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
193
217
|
//#endregion
|
|
194
218
|
export {};
|
package/package.json
CHANGED
package/src/temporal.test.ts
CHANGED
|
@@ -124,33 +124,48 @@ test("isTemporalDuration() rejects default Object.prototype.toString", () => {
|
|
|
124
124
|
strictEqual(isTemporalDuration(decoy), false);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
const literalsWithOffset = [
|
|
128
|
+
"2024-01-01T10:00Z",
|
|
129
|
+
"2024-01-01T10:00+09:00",
|
|
130
|
+
"2024-01-01T10:00-05:00",
|
|
131
|
+
"2024-01-01T10:00:00Z",
|
|
132
|
+
"2024-01-01T10:00:00+09:00",
|
|
133
|
+
"2024-01-01T10:00:00-05:00",
|
|
134
|
+
"2024-01-01T10:00:00+0900",
|
|
135
|
+
"2024-01-01T10:00:00.123456789Z",
|
|
136
|
+
"2024-01-01t10:00z",
|
|
137
|
+
"2024-01-01 10:00:00Z",
|
|
138
|
+
] as const;
|
|
139
|
+
|
|
140
|
+
const literalsWithoutOffset = [
|
|
141
|
+
"2024-01-01T10:00",
|
|
142
|
+
"2024-01-01T10:00:00",
|
|
143
|
+
"2024-01-01T10:00:00.123",
|
|
144
|
+
"2025-01-01 12:34:56",
|
|
145
|
+
] as const;
|
|
146
|
+
|
|
147
|
+
const literalsWithoutSeconds = [
|
|
148
|
+
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
149
|
+
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
150
|
+
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
151
|
+
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
152
|
+
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"],
|
|
153
|
+
] as const;
|
|
154
|
+
|
|
155
|
+
const literalsWithExpandedYear = [
|
|
156
|
+
["+002024-01-01T10:00", "+002024-01-01T10:00Z"],
|
|
157
|
+
["-000001-01-01T10:00.5Z", "-000001-01-01T10:00:00.5Z"],
|
|
158
|
+
] as const;
|
|
159
|
+
|
|
127
160
|
test("normalizeDateTimeLiteral() keeps literals with a UTC offset", () => {
|
|
128
|
-
const
|
|
129
|
-
"2024-01-01T10:00Z",
|
|
130
|
-
"2024-01-01T10:00+09:00",
|
|
131
|
-
"2024-01-01T10:00-05:00",
|
|
132
|
-
"2024-01-01T10:00:00Z",
|
|
133
|
-
"2024-01-01T10:00:00+09:00",
|
|
134
|
-
"2024-01-01T10:00:00-05:00",
|
|
135
|
-
"2024-01-01T10:00:00+0900",
|
|
136
|
-
"2024-01-01T10:00:00.123456789Z",
|
|
137
|
-
"2024-01-01t10:00z",
|
|
138
|
-
"2024-01-01 10:00:00Z",
|
|
139
|
-
];
|
|
140
|
-
for (const literal of literals) {
|
|
161
|
+
for (const literal of literalsWithOffset) {
|
|
141
162
|
strictEqual(normalizeDateTimeLiteral(literal), literal);
|
|
142
163
|
strictEqual(typeof Temporal.Instant.from(literal), "object");
|
|
143
164
|
}
|
|
144
165
|
});
|
|
145
166
|
|
|
146
167
|
test("normalizeDateTimeLiteral() treats literals without an offset as UTC", () => {
|
|
147
|
-
const
|
|
148
|
-
"2024-01-01T10:00",
|
|
149
|
-
"2024-01-01T10:00:00",
|
|
150
|
-
"2024-01-01T10:00:00.123",
|
|
151
|
-
"2025-01-01 12:34:56",
|
|
152
|
-
];
|
|
153
|
-
for (const literal of literals) {
|
|
168
|
+
for (const literal of literalsWithoutOffset) {
|
|
154
169
|
strictEqual(normalizeDateTimeLiteral(literal), `${literal}Z`);
|
|
155
170
|
strictEqual(
|
|
156
171
|
typeof Temporal.Instant.from(normalizeDateTimeLiteral(literal)),
|
|
@@ -164,14 +179,7 @@ test("normalizeDateTimeLiteral() keeps literals without a time part", () => {
|
|
|
164
179
|
});
|
|
165
180
|
|
|
166
181
|
test("normalizeDateTimeLiteral() inserts omitted seconds before a fraction", () => {
|
|
167
|
-
const
|
|
168
|
-
["2024-01-01T10:00.5Z", "2024-01-01T10:00:00.5Z"],
|
|
169
|
-
["2024-01-01T10:00.5+09:00", "2024-01-01T10:00:00.5+09:00"],
|
|
170
|
-
["2024-01-01T10:00.5-05:00", "2024-01-01T10:00:00.5-05:00"],
|
|
171
|
-
["2024-01-01T10:00.5", "2024-01-01T10:00:00.5Z"],
|
|
172
|
-
["2024-01-01T10:00.123456789Z", "2024-01-01T10:00:00.123456789Z"],
|
|
173
|
-
] as const;
|
|
174
|
-
for (const [literal, normalized] of literals) {
|
|
182
|
+
for (const [literal, normalized] of literalsWithoutSeconds) {
|
|
175
183
|
strictEqual(normalizeDateTimeLiteral(literal), normalized);
|
|
176
184
|
strictEqual(typeof Temporal.Instant.from(normalized), "object");
|
|
177
185
|
}
|
|
@@ -180,3 +188,24 @@ test("normalizeDateTimeLiteral() inserts omitted seconds before a fraction", ()
|
|
|
180
188
|
"2024-01-01T10:00:00.5Z",
|
|
181
189
|
);
|
|
182
190
|
});
|
|
191
|
+
|
|
192
|
+
test("normalizeDateTimeLiteral() handles expanded years", () => {
|
|
193
|
+
for (const [literal, normalized] of literalsWithExpandedYear) {
|
|
194
|
+
strictEqual(normalizeDateTimeLiteral(literal), normalized);
|
|
195
|
+
strictEqual(typeof Temporal.Instant.from(normalized), "object");
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("normalizeDateTimeLiteral() is idempotent", () => {
|
|
200
|
+
const literals = [
|
|
201
|
+
...literalsWithOffset,
|
|
202
|
+
...literalsWithoutOffset,
|
|
203
|
+
...literalsWithoutSeconds.map(([literal]) => literal),
|
|
204
|
+
...literalsWithExpandedYear.map(([literal]) => literal),
|
|
205
|
+
"2024-01-01",
|
|
206
|
+
];
|
|
207
|
+
for (const literal of literals) {
|
|
208
|
+
const normalized = normalizeDateTimeLiteral(literal);
|
|
209
|
+
strictEqual(normalizeDateTimeLiteral(normalized), normalized);
|
|
210
|
+
}
|
|
211
|
+
});
|
package/src/temporal.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type guards for `Temporal` namespace objects
|
|
2
|
+
* Type guards for `Temporal` namespace objects and normalization of
|
|
3
|
+
* `xsd:dateTime` literals.
|
|
3
4
|
*
|
|
4
5
|
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
5
6
|
* `temporal-polyfill`) and the host's native `Temporal` implementation
|