From b4f8884a221d6d294c9fb6d15f11d9e4522b9790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sat, 29 Mar 2025 17:22:37 +0100 Subject: [PATCH 01/26] Import asserts from dev deps --- utils/splitUtcDateTime_test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/splitUtcDateTime_test.ts b/utils/splitUtcDateTime_test.ts index e27a70e..d34247f 100644 --- a/utils/splitUtcDateTime_test.ts +++ b/utils/splitUtcDateTime_test.ts @@ -1,5 +1,4 @@ -import { assertEquals } from "https://deno.land/std@0.168.0/testing/asserts.ts"; -import { assert } from "../dev_deps.ts"; +import { assert, assertEquals } from "../dev_deps.ts"; import { splitUtcDateTime } from "./splitUtcDateTime.ts"; Deno.test("splits instant to date and time in UTC", () => { From 1fa9b0320294fd3a9f1c38ba8124eff5bc652433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sat, 29 Mar 2025 17:44:38 +0100 Subject: [PATCH 02/26] Import testing asserts with jsr --- dev_deps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_deps.ts b/dev_deps.ts index 8f67df8..433c359 100644 --- a/dev_deps.ts +++ b/dev_deps.ts @@ -9,4 +9,4 @@ export { assertStrictEquals, assertStringIncludes, assertThrows, -} from "https://deno.land/std@0.168.0/testing/asserts.ts"; +} from "jsr:@std/assert"; From 530955583dc7faa0f11aea3190a8a0838653356c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sat, 29 Mar 2025 17:48:46 +0100 Subject: [PATCH 03/26] Add props for jsr publishing --- deno.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deno.json b/deno.json index 05fe940..b861194 100644 --- a/deno.json +++ b/deno.json @@ -1,4 +1,8 @@ { + "name": "@bjuppa/complaindate", + "version": "1.0.1", + "license": "MIT", + "exports": "./mod.ts", "lock": false, "lint": { "exclude": [ From 392280da81d4aa5dc4849f4bc241a69078adc116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sat, 29 Mar 2025 18:43:02 +0100 Subject: [PATCH 04/26] Import types with keyword --- ExPlainDate.ts | 4 ++-- ExPlainDate_test.ts | 4 ++-- PlainDate.ts | 4 ++-- PlainDate_test.ts | 4 ++-- PlainTime.ts | 2 +- support/function-signatures.ts | 2 +- utils/addBusinessDays.ts | 2 +- utils/addDays.ts | 2 +- utils/addMonths.ts | 2 +- utils/addQuarters.ts | 2 +- utils/addYears.ts | 2 +- utils/differenceInBusinessDays.ts | 2 +- utils/differenceInDays.ts | 2 +- utils/differenceInMonths.ts | 2 +- utils/differenceInQuarters.ts | 2 +- utils/firstWeekDay.ts | 4 ++-- utils/firstWeekDay_test.ts | 2 +- utils/formatPlainDate.ts | 2 +- utils/formatPlainTime.ts | 2 +- utils/isBusinessDay.ts | 2 +- utils/isWeekendDay.ts | 2 +- utils/ordinal.ts | 2 +- utils/parsePlainDate.ts | 2 +- utils/parsePlainTime.ts | 2 +- utils/pipePlainDate.ts | 2 +- utils/pipePlainDate_test.ts | 2 +- utils/quarter.ts | 4 ++-- utils/splitDateTime.ts | 4 ++-- utils/splitLocalDateTime.ts | 4 ++-- utils/splitUtcDateTime.ts | 4 ++-- utils/startOfBusinessWeek.ts | 2 +- utils/startOfMonth.ts | 2 +- utils/startOfQuarter.ts | 2 +- utils/startOfWeekend.ts | 2 +- utils/startOfYear.ts | 2 +- utils/weekDayNumber.ts | 4 ++-- 36 files changed, 46 insertions(+), 46 deletions(-) diff --git a/ExPlainDate.ts b/ExPlainDate.ts index e8f5474..573c91e 100644 --- a/ExPlainDate.ts +++ b/ExPlainDate.ts @@ -1,7 +1,7 @@ -import { ComPlainDate, PlainDate, PlainDateFactory } from "./PlainDate.ts"; +import { type ComPlainDate, PlainDate, type PlainDateFactory } from "./PlainDate.ts"; import { createLocalInstant } from "./utils/createLocalInstant.ts"; import { createInstant } from "./utils/createInstant.ts"; -import { QuarterNumber, WeekDay, WeekDayNumber } from "./constants.ts"; +import { type QuarterNumber, WeekDay, type WeekDayNumber } from "./constants.ts"; import { addDays } from "./utils/addDays.ts"; import { addBusinessDays } from "./utils/addBusinessDays.ts"; import { addMonths } from "./utils/addMonths.ts"; diff --git a/ExPlainDate_test.ts b/ExPlainDate_test.ts index bc8ae03..e897e10 100644 --- a/ExPlainDate_test.ts +++ b/ExPlainDate_test.ts @@ -1,11 +1,11 @@ -import { ExPlainDate, ExtendedPlainDate } from "./ExPlainDate.ts"; +import { ExPlainDate, type ExtendedPlainDate } from "./ExPlainDate.ts"; import { PlainDate } from "./PlainDate.ts"; import { assertEquals, assertStringIncludes, assertThrows, } from "./dev_deps.ts"; -import { PlainDateMapFn } from "./support/function-signatures.ts"; +import type { PlainDateMapFn } from "./support/function-signatures.ts"; Deno.test("factory accepts PlainDate", () => { const exPlainDate = ExPlainDate(PlainDate({ year: 2022, month: 2, day: 2 })); diff --git a/PlainDate.ts b/PlainDate.ts index 92ababa..4bc3424 100644 --- a/PlainDate.ts +++ b/PlainDate.ts @@ -1,6 +1,6 @@ import { createUtcInstant } from "./utils/createUtcInstant.ts"; -import { MonthNumber } from "./constants.ts"; -import { RequireAtLeastOne } from "./support/utility-types.ts"; +import type { MonthNumber } from "./constants.ts"; +import type { RequireAtLeastOne } from "./support/utility-types.ts"; export type FormatPlainDateOptions = Omit< Intl.DateTimeFormatOptions, diff --git a/PlainDate_test.ts b/PlainDate_test.ts index 4a554ef..631ec71 100644 --- a/PlainDate_test.ts +++ b/PlainDate_test.ts @@ -1,6 +1,6 @@ -import { ComPlainDate, PlainDate } from "./PlainDate.ts"; +import { type ComPlainDate, PlainDate } from "./PlainDate.ts"; import { assert, assertEquals, assertFalse, assertThrows } from "./dev_deps.ts"; -import { PlainDateMapFn } from "./support/function-signatures.ts"; +import type { PlainDateMapFn } from "./support/function-signatures.ts"; Deno.test("factory accepts number date parts", () => { const plainDate = PlainDate({ year: 2022, month: 2, day: 2 }); diff --git a/PlainTime.ts b/PlainTime.ts index ee26ca3..380c363 100644 --- a/PlainTime.ts +++ b/PlainTime.ts @@ -1,6 +1,6 @@ import { HOURS_IN_DAY, MS_IN_HOUR } from "./constants.ts"; import { tallyMilliseconds } from "./support/tallyMilliseconds.ts"; -import { RequireAtLeastOne } from "./support/utility-types.ts"; +import type { RequireAtLeastOne } from "./support/utility-types.ts"; export type FormatPlainTimeOptions = & Omit< diff --git a/support/function-signatures.ts b/support/function-signatures.ts index 07e0e15..c3b4f64 100644 --- a/support/function-signatures.ts +++ b/support/function-signatures.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** Describes a function taking a plain-date object and returning the same. */ export type PlainDateMapFn = (date: T) => T; diff --git a/utils/addBusinessDays.ts b/utils/addBusinessDays.ts index f04e395..873e957 100644 --- a/utils/addBusinessDays.ts +++ b/utils/addBusinessDays.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { BUSINESS_DAYS_IN_WEEK, DAYS_IN_WEEK, WeekDay } from "../constants.ts"; import { addDays } from "./addDays.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; diff --git a/utils/addDays.ts b/utils/addDays.ts index b019e48..10fd8be 100644 --- a/utils/addDays.ts +++ b/utils/addDays.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Get a function curried with a number of days diff --git a/utils/addMonths.ts b/utils/addMonths.ts index 48a3277..2151b8c 100644 --- a/utils/addMonths.ts +++ b/utils/addMonths.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { addDays } from "./addDays.ts"; import { startOfMonth } from "./startOfMonth.ts"; diff --git a/utils/addQuarters.ts b/utils/addQuarters.ts index b4de1d8..502374d 100644 --- a/utils/addQuarters.ts +++ b/utils/addQuarters.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { addMonths } from "./addMonths.ts"; /** diff --git a/utils/addYears.ts b/utils/addYears.ts index 7fbcb33..b8e323d 100644 --- a/utils/addYears.ts +++ b/utils/addYears.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Get a function curried with a number of years to add to its plain-date arguments. diff --git a/utils/differenceInBusinessDays.ts b/utils/differenceInBusinessDays.ts index 4c75b07..e0a9715 100644 --- a/utils/differenceInBusinessDays.ts +++ b/utils/differenceInBusinessDays.ts @@ -1,7 +1,7 @@ import { differenceInDays } from "./differenceInDays.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; import { BUSINESS_DAYS_IN_WEEK, DAYS_IN_WEEK, WeekDay } from "../constants.ts"; -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Get a function curried with a plain-date, from which to get the number of diff --git a/utils/differenceInDays.ts b/utils/differenceInDays.ts index 4df83ac..e06d210 100644 --- a/utils/differenceInDays.ts +++ b/utils/differenceInDays.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { HOURS_IN_DAY, MS_IN_HOUR } from "../constants.ts"; import { differenceInMilliseconds } from "./differenceInMilliseconds.ts"; diff --git a/utils/differenceInMonths.ts b/utils/differenceInMonths.ts index a70fa26..63a32ee 100644 --- a/utils/differenceInMonths.ts +++ b/utils/differenceInMonths.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { differenceInYears } from "./differenceInYears.ts"; /** diff --git a/utils/differenceInQuarters.ts b/utils/differenceInQuarters.ts index 9bd7d9e..25bc6e2 100644 --- a/utils/differenceInQuarters.ts +++ b/utils/differenceInQuarters.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { differenceInYears } from "./differenceInYears.ts"; import { quarter } from "./quarter.ts"; diff --git a/utils/firstWeekDay.ts b/utils/firstWeekDay.ts index b153152..1740e2c 100644 --- a/utils/firstWeekDay.ts +++ b/utils/firstWeekDay.ts @@ -1,5 +1,5 @@ -import { ComPlainDate } from "../PlainDate.ts"; -import { DAYS_IN_WEEK, WeekDayNumber } from "../constants.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; +import { DAYS_IN_WEEK, type WeekDayNumber } from "../constants.ts"; import { addDays } from "./addDays.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; diff --git a/utils/firstWeekDay_test.ts b/utils/firstWeekDay_test.ts index 25b6a3e..ab9ec9a 100644 --- a/utils/firstWeekDay_test.ts +++ b/utils/firstWeekDay_test.ts @@ -1,7 +1,7 @@ import { firstWeekDay } from "./firstWeekDay.ts"; import { assertEquals } from "../dev_deps.ts"; import { PlainDate } from "../PlainDate.ts"; -import { WeekDay, WeekDayNumber } from "../constants.ts"; +import { WeekDay, type WeekDayNumber } from "../constants.ts"; Deno.test("returns same day from a monday", () => { assertEquals( diff --git a/utils/formatPlainDate.ts b/utils/formatPlainDate.ts index c7f351b..c41f2fe 100644 --- a/utils/formatPlainDate.ts +++ b/utils/formatPlainDate.ts @@ -1,4 +1,4 @@ -import { ComPlainDate, FormatPlainDateOptions } from "../PlainDate.ts"; +import type { ComPlainDate, FormatPlainDateOptions } from "../PlainDate.ts"; /** * Curry a function to get localized strings of its plain-date arguments. diff --git a/utils/formatPlainTime.ts b/utils/formatPlainTime.ts index e650427..7b44396 100644 --- a/utils/formatPlainTime.ts +++ b/utils/formatPlainTime.ts @@ -1,4 +1,4 @@ -import { ComPlainTime, FormatPlainTimeOptions } from "../PlainTime.ts"; +import type { ComPlainTime, FormatPlainTimeOptions } from "../PlainTime.ts"; /** * Curry a function to get localized strings of its plain-time arguments. diff --git a/utils/isBusinessDay.ts b/utils/isBusinessDay.ts index 47b4d6b..f937c08 100644 --- a/utils/isBusinessDay.ts +++ b/utils/isBusinessDay.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { WeekDay } from "../constants.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; diff --git a/utils/isWeekendDay.ts b/utils/isWeekendDay.ts index 6d40510..7759716 100644 --- a/utils/isWeekendDay.ts +++ b/utils/isWeekendDay.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { isBusinessDay } from "./isBusinessDay.ts"; /** diff --git a/utils/ordinal.ts b/utils/ordinal.ts index 1cdd699..2c016d8 100644 --- a/utils/ordinal.ts +++ b/utils/ordinal.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { differenceInDays } from "./differenceInDays.ts"; import { startOfYear } from "./startOfYear.ts"; diff --git a/utils/parsePlainDate.ts b/utils/parsePlainDate.ts index f9028a1..06da736 100644 --- a/utils/parsePlainDate.ts +++ b/utils/parsePlainDate.ts @@ -1,4 +1,4 @@ -import { ComPlainDate, PlainDate } from "../PlainDate.ts"; +import { type ComPlainDate, PlainDate } from "../PlainDate.ts"; import { dateParts } from "../support/dateParts.ts"; /** diff --git a/utils/parsePlainTime.ts b/utils/parsePlainTime.ts index ec963ed..e3b1b79 100644 --- a/utils/parsePlainTime.ts +++ b/utils/parsePlainTime.ts @@ -1,4 +1,4 @@ -import { ComPlainTime, PlainTime } from "../PlainTime.ts"; +import { type ComPlainTime, PlainTime } from "../PlainTime.ts"; import { timeParts } from "../support/timeParts.ts"; /** diff --git a/utils/pipePlainDate.ts b/utils/pipePlainDate.ts index b32f577..d9f7b5d 100644 --- a/utils/pipePlainDate.ts +++ b/utils/pipePlainDate.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Get a function curried with a pipeline of functions diff --git a/utils/pipePlainDate_test.ts b/utils/pipePlainDate_test.ts index 6059917..3432fc9 100644 --- a/utils/pipePlainDate_test.ts +++ b/utils/pipePlainDate_test.ts @@ -1,7 +1,7 @@ import { pipePlainDate } from "./pipePlainDate.ts"; import { PlainDate } from "../PlainDate.ts"; import { assertEquals } from "../dev_deps.ts"; -import { PlainDateMapFn } from "../support/function-signatures.ts"; +import type { PlainDateMapFn } from "../support/function-signatures.ts"; Deno.test("given pipeline of operations is applied to the plain-date", () => { const plainDate = PlainDate({ year: "2022", month: "12", day: "22" }); diff --git a/utils/quarter.ts b/utils/quarter.ts index 36c5cfa..0f0e617 100644 --- a/utils/quarter.ts +++ b/utils/quarter.ts @@ -1,5 +1,5 @@ -import { ComPlainDate } from "../PlainDate.ts"; -import { QuarterNumber } from "../constants.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; +import type { QuarterNumber } from "../constants.ts"; /** * Get the quarter of the year for a plain-date. diff --git a/utils/splitDateTime.ts b/utils/splitDateTime.ts index 7ab3eaa..f628692 100644 --- a/utils/splitDateTime.ts +++ b/utils/splitDateTime.ts @@ -1,5 +1,5 @@ -import { ComPlainDate, PlainDate } from "../PlainDate.ts"; -import { ComPlainTime, PlainTime } from "../PlainTime.ts"; +import { type ComPlainDate, PlainDate } from "../PlainDate.ts"; +import { type ComPlainTime, PlainTime } from "../PlainTime.ts"; /** * Get a function curried with a timezone, to split native JS `Date` objects diff --git a/utils/splitLocalDateTime.ts b/utils/splitLocalDateTime.ts index 5513d7a..a1b04bc 100644 --- a/utils/splitLocalDateTime.ts +++ b/utils/splitLocalDateTime.ts @@ -1,5 +1,5 @@ -import { ComPlainDate, PlainDate } from "../PlainDate.ts"; -import { ComPlainTime, PlainTime } from "../PlainTime.ts"; +import { type ComPlainDate, PlainDate } from "../PlainDate.ts"; +import { type ComPlainTime, PlainTime } from "../PlainTime.ts"; /** * Split native JS `Date` objects into separate plain-date and plain-time parts diff --git a/utils/splitUtcDateTime.ts b/utils/splitUtcDateTime.ts index 2369eb4..cb5dc82 100644 --- a/utils/splitUtcDateTime.ts +++ b/utils/splitUtcDateTime.ts @@ -1,5 +1,5 @@ -import { ComPlainDate, PlainDate } from "../PlainDate.ts"; -import { ComPlainTime, PlainTime } from "../PlainTime.ts"; +import { type ComPlainDate, PlainDate } from "../PlainDate.ts"; +import { type ComPlainTime, PlainTime } from "../PlainTime.ts"; /** * Split native JS `Date` objects into separate diff --git a/utils/startOfBusinessWeek.ts b/utils/startOfBusinessWeek.ts index 540a693..41ff573 100644 --- a/utils/startOfBusinessWeek.ts +++ b/utils/startOfBusinessWeek.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { WeekDay } from "../constants.ts"; import { addDays } from "./addDays.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; diff --git a/utils/startOfMonth.ts b/utils/startOfMonth.ts index f6154a2..b21ea99 100644 --- a/utils/startOfMonth.ts +++ b/utils/startOfMonth.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Jump to the first day of a plain-date's month. diff --git a/utils/startOfQuarter.ts b/utils/startOfQuarter.ts index ffecd35..394e248 100644 --- a/utils/startOfQuarter.ts +++ b/utils/startOfQuarter.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { quarter } from "./quarter.ts"; /** diff --git a/utils/startOfWeekend.ts b/utils/startOfWeekend.ts index 009e441..39ac10c 100644 --- a/utils/startOfWeekend.ts +++ b/utils/startOfWeekend.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; import { WeekDay } from "../constants.ts"; import { addDays } from "./addDays.ts"; import { weekDayNumber } from "./weekDayNumber.ts"; diff --git a/utils/startOfYear.ts b/utils/startOfYear.ts index 0370c6d..f9380b8 100644 --- a/utils/startOfYear.ts +++ b/utils/startOfYear.ts @@ -1,4 +1,4 @@ -import { ComPlainDate } from "../PlainDate.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Jump to January 1 of a plain-date's year. diff --git a/utils/weekDayNumber.ts b/utils/weekDayNumber.ts index 97bdacd..302bb8a 100644 --- a/utils/weekDayNumber.ts +++ b/utils/weekDayNumber.ts @@ -1,5 +1,5 @@ -import { DAYS_IN_WEEK, WeekDayNumber } from "../constants.ts"; -import { ComPlainDate } from "../PlainDate.ts"; +import { DAYS_IN_WEEK, type WeekDayNumber } from "../constants.ts"; +import type { ComPlainDate } from "../PlainDate.ts"; /** * Get the ISO weekday number (1-7) starting with Monday from a plain-date. From 3eb1ddff5a16e872c6ae27787ab920c39c68b13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 08:16:11 +0200 Subject: [PATCH 05/26] Add missing explicit return types --- utils/addTime.ts | 2 +- utils/subtractTime.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/addTime.ts b/utils/addTime.ts index 1b13780..986ac04 100644 --- a/utils/addTime.ts +++ b/utils/addTime.ts @@ -17,7 +17,7 @@ export function addTime({ minutes?: number | string; seconds?: number | string; milliseconds?: number | string; -}) { +}): (instant: Date) => Date { return (instant: Date): Date => new Date( instant.valueOf() + diff --git a/utils/subtractTime.ts b/utils/subtractTime.ts index aceded5..bbcea27 100644 --- a/utils/subtractTime.ts +++ b/utils/subtractTime.ts @@ -17,7 +17,7 @@ export function subtractTime({ minutes?: number | string; seconds?: number | string; milliseconds?: number | string; -}) { +}): (instant: Date) => Date{ return (instant: Date): Date => new Date( instant.valueOf() - From f316252fcfcd149cf3ae732b0e7264a16e3e01ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 08:17:18 +0200 Subject: [PATCH 06/26] Format code --- .github/workflows/npm-publish.yml | 2 +- ExPlainDate.ts | 12 ++++++++++-- utils/subtractTime.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 8ed54f9..c1bb74b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - registry-url: 'https://registry.npmjs.org' + registry-url: "https://registry.npmjs.org" - name: Build package run: deno run -A ./scripts/build_npm.ts ${{steps.get_tag_version.outputs.TAG_VERSION}} diff --git a/ExPlainDate.ts b/ExPlainDate.ts index 573c91e..dcce063 100644 --- a/ExPlainDate.ts +++ b/ExPlainDate.ts @@ -1,7 +1,15 @@ -import { type ComPlainDate, PlainDate, type PlainDateFactory } from "./PlainDate.ts"; +import { + type ComPlainDate, + PlainDate, + type PlainDateFactory, +} from "./PlainDate.ts"; import { createLocalInstant } from "./utils/createLocalInstant.ts"; import { createInstant } from "./utils/createInstant.ts"; -import { type QuarterNumber, WeekDay, type WeekDayNumber } from "./constants.ts"; +import { + type QuarterNumber, + WeekDay, + type WeekDayNumber, +} from "./constants.ts"; import { addDays } from "./utils/addDays.ts"; import { addBusinessDays } from "./utils/addBusinessDays.ts"; import { addMonths } from "./utils/addMonths.ts"; diff --git a/utils/subtractTime.ts b/utils/subtractTime.ts index bbcea27..65df1c2 100644 --- a/utils/subtractTime.ts +++ b/utils/subtractTime.ts @@ -17,7 +17,7 @@ export function subtractTime({ minutes?: number | string; seconds?: number | string; milliseconds?: number | string; -}): (instant: Date) => Date{ +}): (instant: Date) => Date { return (instant: Date): Date => new Date( instant.valueOf() - From d4f8431e325bd171ff9096af1ccf861ab182f9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 08:51:14 +0200 Subject: [PATCH 07/26] Add jsr publishing git workflow https://jsr.io/docs/publishing-packages#publishing-from-github-actions --- .github/workflows/publish.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ad5781d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: Publish +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Publish package + run: npx jsr publish From e8b26e869119e47627ab1bf468b08f9ca1dc674c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 09:32:46 +0200 Subject: [PATCH 08/26] Document JSR publish flow --- DEVELOPMENT.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f9ff291..72bbb1e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -14,10 +14,14 @@ deno fmt ## Releases +Set a new version in [`deno.json`](deno.json) and push to `main` branch to +[automatically publish to JSR](https://jsr.io/docs/publishing-packages#publishing-from-github-actions) +via a [GitHub Action](https://github.com/bjuppa/com-plain-date/actions). + Releases are to be created and managed through [GitHub Releases](https://github.com/bjuppa/com-plain-date/releases). -New releases are automatically published to +GitHub releases are automatically published to [deno.land](https://deno.land/x/complaindate) with a [GitHub Webhook](https://github.com/bjuppa/com-plain-date/settings/hooks) and to [npm](https://www.npmjs.com/package/complaindate) with a From 9a0bad70fda1e42b039e6d44b9c50e3975018c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 09:43:51 +0200 Subject: [PATCH 09/26] Import dnt from jsr --- scripts/build_npm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 1f20e41..7186af9 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,4 +1,4 @@ -import { build, emptyDir } from "https://deno.land/x/dnt/mod.ts"; +import { build, emptyDir } from "jsr:@deno/dnt@^0.41.3"; await emptyDir("./npm"); From 608c59905ba408ef63a1e969755b6044ffc78ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 10:10:42 +0200 Subject: [PATCH 10/26] Add compilerOptions to fix typechecking in asserts https://github.com/denoland/dnt/issues/422 --- scripts/build_npm.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 7186af9..bb9aaa1 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -10,6 +10,9 @@ await build({ test: "dev", }, }, + compilerOptions: { + lib: ["ESNext"], + }, package: { // package.json properties name: "complaindate", From 12a05ee4490f05747f17e3c61f8e5f9e582397ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 10:12:33 +0200 Subject: [PATCH 11/26] Format code --- deno.json | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/deno.json b/deno.json index b861194..4d6edb6 100644 --- a/deno.json +++ b/deno.json @@ -5,18 +5,12 @@ "exports": "./mod.ts", "lock": false, "lint": { - "exclude": [ - "npm/" - ] + "exclude": ["npm/"] }, "fmt": { - "exclude": [ - "npm/" - ] + "exclude": ["npm/"] }, "test": { - "exclude": [ - "npm/" - ] + "exclude": ["npm/"] } } From cefeeff7ff01d0f45b92e2b8ef6c9e31c6c704b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 11:08:32 +0200 Subject: [PATCH 12/26] Exclude tests from publishing --- deno.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deno.json b/deno.json index 4d6edb6..7509898 100644 --- a/deno.json +++ b/deno.json @@ -4,6 +4,9 @@ "license": "MIT", "exports": "./mod.ts", "lock": false, + "publish": { + "exclude": ["**/*_test.ts"] + }, "lint": { "exclude": ["npm/"] }, From 2da7ed4d4c7d8f281e9dc66cc0933751dc94a234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:07:14 +0200 Subject: [PATCH 13/26] Exclude unnecessary files when publishing to jsr --- deno.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 7509898..25062f3 100644 --- a/deno.json +++ b/deno.json @@ -5,7 +5,15 @@ "exports": "./mod.ts", "lock": false, "publish": { - "exclude": ["**/*_test.ts"] + "exclude": [ + "**/*_test.ts", + ".github", + ".vscode", + "examples", + "scripts", + "DEVELOPMENT.md", + "dev_deps.ts" + ] }, "lint": { "exclude": ["npm/"] From d16a7fbc0606c7bc055427f23406e9f41e37d741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:11:59 +0200 Subject: [PATCH 14/26] Exclude npm directory from all deno operations --- deno.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/deno.json b/deno.json index 25062f3..e25d323 100644 --- a/deno.json +++ b/deno.json @@ -15,13 +15,5 @@ "dev_deps.ts" ] }, - "lint": { - "exclude": ["npm/"] - }, - "fmt": { - "exclude": ["npm/"] - }, - "test": { - "exclude": ["npm/"] - } + "exclude": ["npm/"] } From a1bf65a2c7271b2f944ae3dcdc9e5e9204545d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:13:35 +0200 Subject: [PATCH 15/26] Indicate publish exclude directories --- deno.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index e25d323..074a02c 100644 --- a/deno.json +++ b/deno.json @@ -7,10 +7,10 @@ "publish": { "exclude": [ "**/*_test.ts", - ".github", - ".vscode", - "examples", - "scripts", + ".github/", + ".vscode/", + "examples/", + "scripts/", "DEVELOPMENT.md", "dev_deps.ts" ] From 325e6bf7fa1b4ac1f9b6b2339fbc9a700ed5d000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:29:18 +0200 Subject: [PATCH 16/26] Exclude deno.json when publishing to jsr --- deno.json | 1 + 1 file changed, 1 insertion(+) diff --git a/deno.json b/deno.json index 074a02c..800bc26 100644 --- a/deno.json +++ b/deno.json @@ -11,6 +11,7 @@ ".vscode/", "examples/", "scripts/", + "deno.json", "DEVELOPMENT.md", "dev_deps.ts" ] From c9a4511094c449016532952b0a3f110c6ea2af52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:32:16 +0200 Subject: [PATCH 17/26] Reorder excludes --- deno.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 800bc26..455ac5c 100644 --- a/deno.json +++ b/deno.json @@ -12,8 +12,8 @@ "examples/", "scripts/", "deno.json", - "DEVELOPMENT.md", - "dev_deps.ts" + "dev_deps.ts", + "DEVELOPMENT.md" ] }, "exclude": ["npm/"] From 2dd15bb113e9b250a8521363e5a86451ad0c496e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:41:52 +0200 Subject: [PATCH 18/26] Improve jsr publishing docs --- DEVELOPMENT.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 72bbb1e..fa8fab9 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -14,9 +14,10 @@ deno fmt ## Releases -Set a new version in [`deno.json`](deno.json) and push to `main` branch to -[automatically publish to JSR](https://jsr.io/docs/publishing-packages#publishing-from-github-actions) -via a [GitHub Action](https://github.com/bjuppa/com-plain-date/actions). +Set a new `version` in [`deno.json`](deno.json) and push to `main` branch to +[automatically publish](https://jsr.io/docs/publishing-packages#publishing-from-github-actions) +to [jsr](https://jsr.io/@bjuppa/complaindate) +with a [GitHub Action](https://github.com/bjuppa/com-plain-date/actions/). Releases are to be created and managed through [GitHub Releases](https://github.com/bjuppa/com-plain-date/releases). From 610a7e4411eda1c816a2edc6c1ecae6d6e5fe25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 16:55:01 +0200 Subject: [PATCH 19/26] Point to new API docs at jsr.io This reverts commit 64f29da3ebc7a739d4daf5afdd5fe3ca120f4152. --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2125ba2..05fdd43 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,12 @@ timezones on the surface_. This readme aims to explain how ComPlainDate works, but doesn't contain full explanations of all available operations. The detailed documentation and -categorized lists of available functions were once available at the _deno.land_ -website, but that is no longer the case. +categorized lists of available functions are available at the _jsr.io_ +website: -We hope to regain documentation once this package is published at JSR instead, -see [Issue #88](https://github.com/bjuppa/com-plain-date/issues/88) for -progress. - -Please note that all the links to the _deno.land_ docs from this readme are -currently not working. The simplest workaround is to browse the source files on -GitHub instead, and read the docblocks straight from the source. Not ideal, we -know, sorry. +Visit +[the ComPlainDate API documentation](https://jsr.io/@bjuppa/complaindate) to +explore which specific utilities you can use to solve your problem. ## Installation From 91e04543aa06e25726101284a1050bd6b8b5803c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:03:56 +0200 Subject: [PATCH 20/26] Update link to specific API docs at jsr.io --- README.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 05fdd43..45bc6e7 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ time to reach for the other concepts, described below. ### `PlainDate` for _calendar dates_ Plain-date objects adhere to the -[`ComPlainDate` contract](https://deno.land/x/complaindate/mod.ts?s=ComPlainDate) +[`ComPlainDate` contract](https://jsr.io/@bjuppa/complaindate/doc/~/ComPlainDate) and have three numeric properties (`year`, `month`, and `day`) used for most operations. @@ -122,7 +122,7 @@ encouraged to build your own mapper functions on top of the existing ones. ### `PlainTime` for _time-of-day_ Plain-time objects adhere to the -[`ComPlainTime` contract](https://deno.land/x/complaindate/mod.ts?s=ComPlainTime) +[`ComPlainTime` contract](https://jsr.io/@bjuppa/complaindate/doc/~/ComPlainTime) and have four numeric properties (`hour`, `minute`, `second`, and `millisecond`), that may be used for operations, but those are surprisingly uncommon. @@ -136,8 +136,8 @@ method is best for controlled formatting in user interfaces. ## Creating plain-date and plain-time objects Pass any _calendar-date_ or _wall-time_ **shaped** objects to the factory -functions [`PlainDate`](https://deno.land/x/complaindate/mod.ts?s=PlainDate) and -[`PlainTime`](https://deno.land/x/complaindate/mod.ts?s=PlainTime): +functions [`PlainDate`](https://jsr.io/@bjuppa/complaindate/doc/~/PlainDate) and +[`PlainTime`](https://jsr.io/@bjuppa/complaindate/doc/~/PlainTime): ```ts const someDate = PlainDate({ @@ -165,8 +165,8 @@ const midnight = PlainTime({}); // 00:00 ### Extraction from strings Functions -[`parsePlainDate`](https://deno.land/x/complaindate/mod.ts?s=parsePlainDate) and -[`parsePlainTime`](https://deno.land/x/complaindate/mod.ts?s=parsePlainTime) +[`parsePlainDate`](https://jsr.io/@bjuppa/complaindate/doc/~/parsePlainDate) and +[`parsePlainTime`](https://jsr.io/@bjuppa/complaindate/doc/~/parsePlainTime) creates objects from **strings**: ```ts @@ -180,7 +180,7 @@ const midday = parsePlainTime("12:00"); ### Extraction from JavaScript `Date` objects If you have a JavaScript `Date` object, calling -[`splitDateTime`](https://deno.land/x/complaindate/mod.ts?s=splitDateTime) will +[`splitDateTime`](https://jsr.io/@bjuppa/complaindate/doc/~/splitDateTime) will extract separate plain-date and plain-time objects for a given **timezone**: ```ts @@ -191,9 +191,9 @@ const [june6, time1337] = splitDateTime("Europe/Stockholm")(aJsDate); ``` A `Date` can also be split in UTC using -[`splitUtcDateTime`](https://deno.land/x/complaindate/mod.ts?s=splitUtcDateTime) +[`splitUtcDateTime`](https://jsr.io/@bjuppa/complaindate/doc/~/splitUtcDateTime) or the system's timezone with -[`splitLocalDateTime`](https://deno.land/x/complaindate/mod.ts?s=splitLocalDateTime): +[`splitLocalDateTime`](https://jsr.io/@bjuppa/complaindate/doc/~/splitLocalDateTime): ```ts const [june6, time1137] = splitUtcDateTime(aJsDate); @@ -275,7 +275,7 @@ a timezone supported in your backend may not be supported in the user's current browser. Before using a timezone string in frontend code, pass it through the -[`safeTimezone`](https://deno.land/x/complaindate/mod.ts?s=safeTimezone) utility +[`safeTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/safeTimezone) utility to get a string guaranteed to be a valid timezone in the local system. Should the given timezone name be unsuitable, it will return the operating system's named timezone instead, or `"UTC"` if no timezone can be determined. For the @@ -283,7 +283,7 @@ user, this should make for the best possible graceful degradation when their preferred timezone is unavailable. When your application doesn't support timezone as a user preference, the -[`localTimezone`](https://deno.land/x/complaindate/mod.ts?s=localTimezone) +[`localTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/localTimezone) utility can be used to retrieve a relevant timezone for the current view. Although, be careful with server side rendering here… @@ -293,7 +293,7 @@ Because the timezone used may be a fallback and not what the user expects, it's important to _always_ display the actual timezone name whenever time information is present in the user interface. -The [`formatTimezone`](https://deno.land/x/complaindate/mod.ts?s=formatTimezone) +The [`formatTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/formatTimezone) utility will make a timezone name look pretty for the user. It replaces underscores with spaces to give a less technical impression, for example `"Africa/Dar es Salaam"` instead of `"Africa/Dar_es_Salaam"`. @@ -302,7 +302,7 @@ underscores with spaces to give a less technical impression, for example If your user interface provides a way for users to select their preferred timezone, use -[`supportedCanonicalTimezones`](https://deno.land/x/complaindate/mod.ts?s=supportedCanonicalTimezones) +[`supportedCanonicalTimezones`](https://jsr.io/@bjuppa/complaindate/doc/~/supportedCanonicalTimezones) to get a list of all the named timezones in the system. You may even create an endpoint that returns the timezones supported by your backend and intersect that with the browser's timezones to really make sure no unhandled timezone is @@ -315,20 +315,20 @@ to become an autocomplete "combobox" for the user to select from. See the for details and examples. Don't forget to use -[`localTimezone`](https://deno.land/x/complaindate/mod.ts?s=localTimezone) to +[`localTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/localTimezone) to set a sensible initial value for the input! ### Validating timezones User input can be run through -[`sanitizeTimezone`](https://deno.land/x/complaindate/mod.ts?s=sanitizeTimezone) +[`sanitizeTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/sanitizeTimezone) to clean up a timezone string, removing some common user typos and converting whitespace to underscore. The result can be checked with -[`isTimezone`](https://deno.land/x/complaindate/mod.ts?s=isTimezone). +[`isTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/isTimezone). If you'd rather throw `RangeError` on failure, or want to extract a timezone name that is part of a longer string, use -[`parseTimezone`](https://deno.land/x/complaindate/mod.ts?s=parseTimezone) +[`parseTimezone`](https://jsr.io/@bjuppa/complaindate/doc/~/parseTimezone) directly to both sanitize and validate the result. ## Working with JavaScript `Date` objects @@ -345,10 +345,10 @@ const instant = new Date(...); With ComPlainDate `Date` objects can also be created from any date-time **shaped** objects in a specified timezone with -[`createInstant`](https://deno.land/x/complaindate/mod.ts?s=createInstant), -[`createLocalInstant`](https://deno.land/x/complaindate/mod.ts?s=createLocalInstant) +[`createInstant`](https://jsr.io/@bjuppa/complaindate/doc/~/createInstant), +[`createLocalInstant`](https://jsr.io/@bjuppa/complaindate/doc/~/createLocalInstant) and -[`createUtcInstant`](https://deno.land/x/complaindate/mod.ts?s=createUtcInstant): +[`createUtcInstant`](https://jsr.io/@bjuppa/complaindate/doc/~/createUtcInstant): ```ts const noon2023Feb3InSweden = createInstant("Europe/Stockholm")({ @@ -382,7 +382,7 @@ const jsDateInUtc = createUtcInstant({ ``` For UTC, that last example can also be written using the -[`toUtcInstant`](https://deno.land/x/complaindate/mod.ts?s=ComPlainDate#prop_toUtcInstant) +[`toUtcInstant`](https://jsr.io/@bjuppa/complaindate/doc/~/ComPlainDate#property_toutcinstant) method of the plain-date object, passing an optional wall-time shaped object: ```ts @@ -391,7 +391,7 @@ jan1.toUtcInstant(...midday); // 2023-01-01T12:00:00.000Z ### Displaying a `Date` to users -The [`formatInstant`](https://deno.land/x/complaindate/mod.ts?s=formatInstant) +The [`formatInstant`](https://jsr.io/@bjuppa/complaindate/doc/~/formatInstant) utility generates formatting functions to reuse for consistency throughout a user interface. It is curried in three rounds with a locale, format options, and a timezone. Each parameter has a sensible default if left out, using the @@ -417,8 +417,8 @@ format24hDateTimeForUser(aJsDate); // "6/13/2023, 08:00:00 EDT" ### Operations on `Date` -Use functions [`addTime`](https://deno.land/x/complaindate/mod.ts?s=addTime) and -[`subtractTime`](https://deno.land/x/complaindate/mod.ts?s=subtractTime) to get +Use functions [`addTime`](https://jsr.io/@bjuppa/complaindate/doc/~/addTime) and +[`subtractTime`](https://jsr.io/@bjuppa/complaindate/doc/~/subtractTime) to get a new `Date` object shifted some **duration** from an existing one. Units up to `hours` make sense here because an hour is exactly 60 minutes no matter what timezone you're in. These methods just sum up the total milliseconds before @@ -575,14 +575,14 @@ use in a non-functional paradigm too! First of all, there are no external dependencies, and there will never be any. -The base [`PlainDate`](https://deno.land/x/complaindate/mod.ts?s=ComPlainDate) -and [`PlainTime`](https://deno.land/x/complaindate/mod.ts?s=ComPlainTime) +The base [`PlainDate`](https://jsr.io/@bjuppa/complaindate/doc/~/ComPlainDate) +and [`PlainTime`](https://jsr.io/@bjuppa/complaindate/doc/~/ComPlainTime) objects are carefully composed to be _minimal loveable objects_, containing only what is needed for a neat developer experience. The utility functions are meant to be imported and applied with these base objects when required. When bundle size is not an issue (i.e. server-side), you can work with full -[`ExPlainDate`](https://deno.land/x/complaindate/mod.ts?s=ExtendedPlainDate) +[`ExPlainDate`](https://jsr.io/@bjuppa/complaindate/doc/~/ExtendedPlainDate) objects if you want to call available operations directly on the plain-date object. This may sound convenient, but it is very hard to tree-shake, making your bundle size unnecessary big when used. From b7ad85ac3a2b78b190d4e03797dbdcd33faedba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:22:38 +0200 Subject: [PATCH 21/26] Import with jsr specifier --- examples/quick-start.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/quick-start.ts b/examples/quick-start.ts index 2840ac5..82510fe 100644 --- a/examples/quick-start.ts +++ b/examples/quick-start.ts @@ -10,7 +10,7 @@ import { startOfYear, WeekDay, weekDayNumber, -} from "https://deno.land/x/complaindate/mod.ts"; +} from "jsr:@bjuppa/complaindate"; // Extract a plain-date and a plain-time from any JS `Date` const [june6, time1337] = splitDateTime( From 97562f598fb1fe97d91d421b7eafb19e024e5f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:25:07 +0200 Subject: [PATCH 22/26] Point to jsr installation, and remove deno.land --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45bc6e7..3dd029c 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ explore which specific utilities you can use to solve your problem. ## Installation -ComPlainDate is distributed as an **npm** package as well as a **Deno** module: +ComPlainDate is distributed as packages via both **jsr** and **npm**: +- [jsr.io/@bjuppa/complaindate](https://jsr.io/@bjuppa/complaindate) - [npmjs.com/package/complaindate](https://www.npmjs.com/package/complaindate) -- [deno.land/x/complaindate](https://deno.land/x/complaindate) ## Table of contents From 0fee849fdb87e5a35c839ab1bbbf53bdade5ac9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:25:47 +0200 Subject: [PATCH 23/26] Document publishing to npm before deno.land --- DEVELOPMENT.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index fa8fab9..245ed21 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -22,11 +22,11 @@ with a [GitHub Action](https://github.com/bjuppa/com-plain-date/actions/). Releases are to be created and managed through [GitHub Releases](https://github.com/bjuppa/com-plain-date/releases). -GitHub releases are automatically published to -[deno.land](https://deno.land/x/complaindate) with a -[GitHub Webhook](https://github.com/bjuppa/com-plain-date/settings/hooks) and to +When created, GitHub releases are automatically published to [npm](https://www.npmjs.com/package/complaindate) with a -[GitHub Action](https://github.com/bjuppa/com-plain-date/actions). +[GitHub Action](https://github.com/bjuppa/com-plain-date/actions) and to +[deno.land](https://deno.land/x/complaindate) with a +[GitHub Webhook](https://github.com/bjuppa/com-plain-date/settings/hooks). ## Testing the package From 00e86e8fd0bbdf9507e1d7802a8f2b591705ff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:41:55 +0200 Subject: [PATCH 24/26] Use deno v2 in github actions --- .github/workflows/npm-publish.yml | 4 ++-- .github/workflows/run-tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index c1bb74b..7f1c550 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -17,9 +17,9 @@ jobs: run: echo TAG_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: - deno-version: v1.x # Run with latest stable Deno. + deno-version: v2.x # Run with latest stable Deno. - name: Setup Node uses: actions/setup-node@v3 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 615eed9..4c7b827 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,9 +10,9 @@ jobs: uses: actions/checkout@v3 - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: - deno-version: v1.x # Run with latest stable Deno. + deno-version: v2.x # Run with latest stable Deno. - name: Check formatting run: deno fmt --check From 584f57c05924a5b57a70a9a7eebde6da44a5cc28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:42:08 +0200 Subject: [PATCH 25/26] Use node v22 in github actions --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7f1c550..ccc8713 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -24,7 +24,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 22 registry-url: "https://registry.npmjs.org" - name: Build package From 69d63f5c811822df08598772c886591f584ccafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Sun, 30 Mar 2025 17:45:19 +0200 Subject: [PATCH 26/26] Format markdown --- DEVELOPMENT.md | 4 ++-- README.md | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 245ed21..a80f0df 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -16,8 +16,8 @@ deno fmt Set a new `version` in [`deno.json`](deno.json) and push to `main` branch to [automatically publish](https://jsr.io/docs/publishing-packages#publishing-from-github-actions) -to [jsr](https://jsr.io/@bjuppa/complaindate) -with a [GitHub Action](https://github.com/bjuppa/com-plain-date/actions/). +to [jsr](https://jsr.io/@bjuppa/complaindate) with a +[GitHub Action](https://github.com/bjuppa/com-plain-date/actions/). Releases are to be created and managed through [GitHub Releases](https://github.com/bjuppa/com-plain-date/releases). diff --git a/README.md b/README.md index 3dd029c..0ec3270 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,10 @@ timezones on the surface_. This readme aims to explain how ComPlainDate works, but doesn't contain full explanations of all available operations. The detailed documentation and -categorized lists of available functions are available at the _jsr.io_ -website: +categorized lists of available functions are available at the _jsr.io_ website: -Visit -[the ComPlainDate API documentation](https://jsr.io/@bjuppa/complaindate) to -explore which specific utilities you can use to solve your problem. +Visit [the ComPlainDate API documentation](https://jsr.io/@bjuppa/complaindate) +to explore which specific utilities you can use to solve your problem. ## Installation