diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 8ed54f9..ccc8713 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -17,15 +17,15 @@ 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 with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' + node-version: 22 + 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/.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 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 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f9ff291..a80f0df 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -14,14 +14,19 @@ deno fmt ## Releases +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). -New 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 diff --git a/ExPlainDate.ts b/ExPlainDate.ts index e8f5474..dcce063 100644 --- a/ExPlainDate.ts +++ b/ExPlainDate.ts @@ -1,7 +1,15 @@ -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/README.md b/README.md index 2125ba2..0ec3270 100644 --- a/README.md +++ b/README.md @@ -25,24 +25,17 @@ 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 -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 @@ -107,7 +100,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. @@ -127,7 +120,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. @@ -141,8 +134,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({ @@ -170,8 +163,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 @@ -185,7 +178,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 @@ -196,9 +189,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); @@ -280,7 +273,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 @@ -288,7 +281,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… @@ -298,7 +291,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"`. @@ -307,7 +300,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 @@ -320,20 +313,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 @@ -350,10 +343,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")({ @@ -387,7 +380,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 @@ -396,7 +389,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 @@ -422,8 +415,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 @@ -580,14 +573,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. diff --git a/deno.json b/deno.json index 05fe940..455ac5c 100644 --- a/deno.json +++ b/deno.json @@ -1,18 +1,20 @@ { + "name": "@bjuppa/complaindate", + "version": "1.0.1", + "license": "MIT", + "exports": "./mod.ts", "lock": false, - "lint": { + "publish": { "exclude": [ - "npm/" + "**/*_test.ts", + ".github/", + ".vscode/", + "examples/", + "scripts/", + "deno.json", + "dev_deps.ts", + "DEVELOPMENT.md" ] }, - "fmt": { - "exclude": [ - "npm/" - ] - }, - "test": { - "exclude": [ - "npm/" - ] - } + "exclude": ["npm/"] } 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"; 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( diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 1f20e41..bb9aaa1 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"); @@ -10,6 +10,9 @@ await build({ test: "dev", }, }, + compilerOptions: { + lib: ["ESNext"], + }, package: { // package.json properties name: "complaindate", 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/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/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/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", () => { 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/subtractTime.ts b/utils/subtractTime.ts index aceded5..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 { return (instant: Date): Date => new Date( instant.valueOf() - 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.