diff --git a/package-lock.json b/package-lock.json index 5a60f1c9..dac3626e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,19 +57,6 @@ "node": ">=22" } }, - "../discord-markdown": { - "name": "@cloudrac3r/discord-markdown", - "version": "2.9.0", - "extraneous": true, - "license": "MIT", - "dependencies": { - "simple-markdown": "^0.7.3" - }, - "devDependencies": { - "@cloudrac3r/tap-dot": "^2.0.2", - "supertape": "^13.6.2" - } - }, "node_modules/@babel/helper-string-parser": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", @@ -146,9 +133,9 @@ } }, "node_modules/@cloudrac3r/discord-markdown": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@cloudrac3r/discord-markdown/-/discord-markdown-2.9.0.tgz", - "integrity": "sha512-0S22mNlT9rPhYnxP+qzKWayVe+hFWcEqxVCviF/pyzWAb9nLaBZkIVk0jHTImoA1MY0mqx1uMKjIcxVHkEZe3A==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@cloudrac3r/discord-markdown/-/discord-markdown-2.9.1.tgz", + "integrity": "sha512-sYaDfRBaS7uMVQx4wJwT68F6OzJZX84DF2XvHkQr8vdwTCvnpeaT26obqvzNawVwVoQ4xjIMZxafgMrAEK4Oxw==", "license": "MIT", "dependencies": { "simple-markdown": "^0.7.3" @@ -283,9 +270,9 @@ } }, "node_modules/@cloudrac3r/tell-me-when": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@cloudrac3r/tell-me-when/-/tell-me-when-2.0.0.tgz", - "integrity": "sha512-U+TEOTe6f/vSIeD/QP0VPrkLrhnFtQs2euxBOAaqC8rzQKu8nNoKSFuhipT6DyuCZH48B58+qrPMmH2w2IgMhA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@cloudrac3r/tell-me-when/-/tell-me-when-2.0.1.tgz", + "integrity": "sha512-nm1Ao/vpHDn2YMivnc9EVr/QrcT5IG6G7o1Ffh31YafIo9Cc3bSN1jPLL9eOuKKLCYT1/DZP7Nh8PXAN371bAQ==", "license": "MIT", "bin": { "tell-me-when": "dist/src/cli.js" @@ -1175,7 +1162,6 @@ "version": "13.0.3", "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz", "integrity": "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==", - "hasInstallScript": true, "license": "MIT", "dependencies": { "node-addon-api": "^8.0.0" diff --git a/package.json b/package.json index 4c9de0ed..e807089a 100644 --- a/package.json +++ b/package.json @@ -71,5 +71,8 @@ "addbot": "node addbot.js", "test": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap --no-worker test/test.js | tap-dot", "cover": "c8 -o test/coverage --skip-full -x db/migrations -x src/m2d/event-dispatcher.js -x src/matrix/file.js -x src/matrix/api.js -x src/d2m/converters/rlottie-wasm.js -r html -r text supertape --no-check-assertions-count --format fail --no-worker test/test.js -- --slow" + }, + "allowScripts": { + "better-sqlite3": true } } diff --git a/src/d2m/converters/message-to-event.js b/src/d2m/converters/message-to-event.js index 4314a0e9..45d97468 100644 --- a/src/d2m/converters/message-to-event.js +++ b/src/d2m/converters/message-to-event.js @@ -915,8 +915,8 @@ async function messageToEvent(message, guild, options = {}, di) { // Add time if (event.scheduled_end_time) { - const formatter = new Intl.DateTimeFormat("en-NZ", {month: "long", day: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "shortGeneric", timeZone: reg.ooye.time_zone}) // 9 June at 3:00 pm NZT - var displayTime = formatter.formatRange(new Date(event.scheduled_start_time), new Date(event.scheduled_end_time)) + const formatter = new Intl.DateTimeFormat("en-NZ", {weekday: "long", month: "long", day: "numeric", hour: "numeric", minute: "2-digit", timeZone: "UTC"}) // 9 June at 3:00 pm NZT + var displayTime = formatter.formatRange(new Date(event.scheduled_start_time), new Date(event.scheduled_end_time)) + " (UTC)" } else { var displayTime = discordTime.convertDiscordTime(unixSeconds, "F") } diff --git a/src/d2m/converters/message-to-event.test.js b/src/d2m/converters/message-to-event.test.js index 397be392..a7b17335 100644 --- a/src/d2m/converters/message-to-event.test.js +++ b/src/d2m/converters/message-to-event.test.js @@ -1589,12 +1589,12 @@ test("message2event: irl invite event renders embed", async t => { { $type: "m.room.message", msgtype: "m.notice", - body: `| Scheduled Event - 8 June at 10:00 pm NZT – 9 June at 12:00 am NZT` + body: `| Scheduled Event - Sunday, 8 June, 10:00 am – 12:00 pm (UTC)` + `\n| ## forest exploration` + `\n| ` + `\n| 📍 the dark forest`, format: "org.matrix.custom.html", - formatted_body: `

Scheduled Event - 8 June at 10:00 pm NZT – 9 June at 12:00 am NZT

` + formatted_body: `

Scheduled Event - Sunday, 8 June, 10:00 am – 12:00 pm (UTC)

` + `forest exploration` + `

📍 the dark forest

`, "m.mentions": {} @@ -1622,13 +1622,13 @@ test("message2event: vc invite event renders embed", async t => { { $type: "m.room.message", msgtype: "m.notice", - body: `| Scheduled Event - 9 June at 3:00 pm NZT` + body: `| Scheduled Event - Monday, 9 June 2025 at 3:00 am (UTC)` + `\n| ## Cooking (Netrunners)` + `\n| Short circuited brain interfaces actually just means your brain is medium rare, yum.` + `\n| ` + `\n| 🔊 Cooking`, format: "org.matrix.custom.html", - formatted_body: `

Scheduled Event - 9 June at 3:00 pm NZT

` + formatted_body: `

Scheduled Event - Monday, 9 June 2025 at 3:00 am (UTC)

` + `Cooking (Netrunners)
Short circuited brain interfaces actually just means your brain is medium rare, yum.` + `

🔊 Cooking

`, "m.mentions": {} @@ -1664,13 +1664,13 @@ test("message2event: vc invite event renders embed with room link", async t => { { $type: "m.room.message", msgtype: "m.notice", - body: `| Scheduled Event - 9 June at 3:00 pm NZT` + body: `| Scheduled Event - Monday, 9 June 2025 at 3:00 am (UTC)` + `\n| ## Cooking (Netrunners)` + `\n| Short circuited brain interfaces actually just means your brain is medium rare, yum.` + `\n| ` + `\n| 🔊 Hey. - https://matrix.to/#/!FuDZhlOAtqswlyxzeR:cadence.moe?via=cadence.moe`, format: "org.matrix.custom.html", - formatted_body: `

Scheduled Event - 9 June at 3:00 pm NZT

` + formatted_body: `

Scheduled Event - Monday, 9 June 2025 at 3:00 am (UTC)

` + `Cooking (Netrunners)
Short circuited brain interfaces actually just means your brain is medium rare, yum.` + `

🔊 Hey. - Hey.

`, "m.mentions": {} diff --git a/src/web/pug/time.pug b/src/web/pug/time.pug index 1d71c228..ed37bec4 100644 --- a/src/web/pug/time.pug +++ b/src/web/pug/time.pug @@ -67,7 +67,6 @@ html(lang="en") if style !== "R" p #[span#remaining.remaining]#[span#direction] #[span#tick.tick] script. - document.body.classList.add("yes-script") const WIDTH = !{WIDTH} const timestamp = !{timestamp} const style = "!{style}" @@ -104,6 +103,7 @@ html(lang="en") st.style.fontSize = Math.floor(parseInt(st.style.fontSize) * WIDTH / l) + "px"; } } + document.body.classList.add("yes-script") let frame = 0 function updateTimeRemaining() { @@ -116,15 +116,17 @@ html(lang="en") } let difference = Math.abs(timeForRemaining.getTime() - now.getTime()) + // Temporal.Duration isn't Baseline https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration let foundSignificantField = false - let remainingText = UNITS.map(([unit, duration], index) => { + const remainingTextParts = UNITS.map(([unit, duration], index) => { const multiplier = Math.floor(difference / duration) difference -= multiplier * duration if (multiplier > 0 || foundSignificantField) { foundSignificantField = true return multiplier + "\u00a0" + unit + (multiplier !== 1 ? "s" : "") } - }).filter(s => s).join(", ") + }).filter(s => s) + const remainingText = remainingTextParts.length === 2 ? remainingTextParts.join(" and ") : remainingTextParts.join(", ") if (remainingText) { remaining.textContent = remainingText direction.textContent =