Unverified Commit 0d84da16 authored by Hong Minhee's avatar Hong Minhee
Browse files

Add support for RFC 3339 date-time strings w/o tz

- Improves interoperability with implementations that don't include timezone
- Affects date-time property handling across the Activity Vocabulary API
- Updates test to verify compatibility with the new date format

Fix https://github.com/fedify-dev/fedify/issues/226
parent d48f7039
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -8,6 +8,14 @@ Version 1.0.24

To be released.

 -  Activity Vocabulary API became to accept [RFC 3339] date-time strings
    without a timezone offset.  This is not a bug fix, but improves
    interoperability with some implementations that do not include a timezone
    offset in their date-time strings including WordPress.  [[#226]]

[RFC 3339]: https://datatracker.ietf.org/doc/html/rfc3339
[#226]: https://github.com/fedify-dev/fedify/issues/226


Version 1.0.23
--------------
+38 −7
Original line number Diff line number Diff line
@@ -5278,7 +5278,11 @@ get urls(): ((URL | Link))[] {
        : _219RwDanjScTv5tYCjwGZVCM7KZ9_endTime__array
    ) {
      if (v == null) continue;
    _219RwDanjScTv5tYCjwGZVCM7KZ9_endTime.push(Temporal.Instant.from(v[\\"@value\\"]))
    _219RwDanjScTv5tYCjwGZVCM7KZ9_endTime.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime = _219RwDanjScTv5tYCjwGZVCM7KZ9_endTime;
    const _86xFhmgBapoMvYqjbjRuDPayTrS_generator: (Object | Link | URL)[] = [];
@@ -5493,7 +5497,11 @@ get urls(): ((URL | Link))[] {
        : _5e258TDXtuhaFRPZiGoDfEpjdMr_published__array
    ) {
      if (v == null) continue;
    _5e258TDXtuhaFRPZiGoDfEpjdMr_published.push(Temporal.Instant.from(v[\\"@value\\"]))
    _5e258TDXtuhaFRPZiGoDfEpjdMr_published.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_5e258TDXtuhaFRPZiGoDfEpjdMr_published = _5e258TDXtuhaFRPZiGoDfEpjdMr_published;
    const _7UpwM3JWcXhADcscukEehBorf6k_replies: (Collection | URL)[] = [];
@@ -5534,7 +5542,11 @@ get urls(): ((URL | Link))[] {
        : _2w3Jmue4up8iVDUA51WZqomEF438_startTime__array
    ) {
      if (v == null) continue;
    _2w3Jmue4up8iVDUA51WZqomEF438_startTime.push(Temporal.Instant.from(v[\\"@value\\"]))
    _2w3Jmue4up8iVDUA51WZqomEF438_startTime.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_2w3Jmue4up8iVDUA51WZqomEF438_startTime = _2w3Jmue4up8iVDUA51WZqomEF438_startTime;
    const _4LqirZspQbFWWQEbFcXAxm7tTDN1_summary: ((string | LanguageString))[] = [];
@@ -5610,7 +5622,11 @@ get urls(): ((URL | Link))[] {
        : _385aB7ySixcf5Un6z3VsWmThgCzQ_updated__array
    ) {
      if (v == null) continue;
    _385aB7ySixcf5Un6z3VsWmThgCzQ_updated.push(Temporal.Instant.from(v[\\"@value\\"]))
    _385aB7ySixcf5Un6z3VsWmThgCzQ_updated.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_385aB7ySixcf5Un6z3VsWmThgCzQ_updated = _385aB7ySixcf5Un6z3VsWmThgCzQ_updated;
    const _2oPEH9MQ3aj8JVwyYuWkqoVwV865_url: ((URL | Link))[] = [];
@@ -8350,7 +8366,11 @@ cryptosuite?: \\"eddsa-jcs-2022\\" | null;verificationMethod?: Multikey | URL |
        : _3qzP3ukEZoUziK5FEiA1RhU4aqac__array
    ) {
      if (v == null) continue;
    _3qzP3ukEZoUziK5FEiA1RhU4aqac.push(Temporal.Instant.from(v[\\"@value\\"]))
    _3qzP3ukEZoUziK5FEiA1RhU4aqac.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_3qzP3ukEZoUziK5FEiA1RhU4aqac = _3qzP3ukEZoUziK5FEiA1RhU4aqac;
    
@@ -41560,7 +41580,14 @@ instruments?: (Object | URL)[];exclusiveOptions?: (Object | URL)[];inclusiveOpti
      const decoded =
      typeof v === \\"object\\" && \\"@type\\" in v
        && \\"@value\\" in v && typeof v[\\"@value\\"] === \\"string\\"
        && v[\\"@type\\"] === \\"http://www.w3.org/2001/XMLSchema#dateTime\\" ? Temporal.Instant.from(v[\\"@value\\"]) : typeof v === \\"object\\" && \\"@value\\" in v
        && v[\\"@type\\"] === \\"http://www.w3.org/2001/XMLSchema#dateTime\\"
        // Check if the value is a valid RFC 3339 date-time string
        && new Date(v[\\"@value\\"]).toString() !== \\"Invalid Date\\"
         ? Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ) : typeof v === \\"object\\" && \\"@value\\" in v
        && typeof v[\\"@value\\"] === \\"boolean\\" ? v[\\"@value\\"] : undefined
      ;
      if (typeof decoded === \\"undefined\\") continue;
@@ -48579,7 +48606,11 @@ proofs?: (DataIntegrityProof | URL)[];deleted?: Temporal.Instant | null;}
        : _8g8g4LiVMhFTXskuDEqx4ascxUr_deleted__array
    ) {
      if (v == null) continue;
    _8g8g4LiVMhFTXskuDEqx4ascxUr_deleted.push(Temporal.Instant.from(v[\\"@value\\"]))
    _8g8g4LiVMhFTXskuDEqx4ascxUr_deleted.push(Temporal.Instant.from(
        v[\\"@value\\"].substring(19).match(/[Z+-]/)
          ? v[\\"@value\\"]
          : v[\\"@value\\"] + \\"Z\\"
      ))
    }
    instance.#_8g8g4LiVMhFTXskuDEqx4ascxUr_deleted = _8g8g4LiVMhFTXskuDEqx4ascxUr_deleted;
    
+9 −2
Original line number Diff line number Diff line
@@ -184,10 +184,17 @@ const scalarTypes: Record<string, ScalarType> = {
    dataCheck(v) {
      return `typeof ${v} === "object" && "@type" in ${v}
        && "@value" in ${v} && typeof ${v}["@value"] === "string"
        && ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"`;
        && ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"
        // Check if the value is a valid RFC 3339 date-time string
        && new Date(${v}["@value"]).toString() !== "Invalid Date"
        `;
    },
    decoder(v) {
      return `Temporal.Instant.from(${v}["@value"])`;
      return `Temporal.Instant.from(
        ${v}["@value"].substring(19).match(/[Z+-]/)
          ? ${v}["@value"]
          : ${v}["@value"] + "Z"
      )`;
    },
  },
  "http://www.w3.org/2001/XMLSchema#duration": {
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ test("Object.fromJsonLd()", async () => {
      "content": "Hello",
      "mediaType": "text/plain",
    },
    "published": "2025-01-01 12:34:56",
  }, { documentLoader: mockDocumentLoader, contextLoader: mockDocumentLoader });
  assertInstanceOf(obj, Object);
  assertEquals(obj.name, "Test");
@@ -153,6 +154,7 @@ test("Object.fromJsonLd()", async () => {
  assertInstanceOf(obj.source, Source);
  assertEquals(obj.source.content, "Hello");
  assertEquals(obj.source.mediaType, "text/plain");
  assertEquals(obj.published, Temporal.Instant.from("2025-01-01T12:34:56Z"));

  const createJsonLd = {
    "@context": "https://www.w3.org/ns/activitystreams",