From bf99751533bb5ad1daf0b29f842fcb659d34163c Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 09:50:43 +0000 Subject: [PATCH 01/10] sort observedAttributes --- src/relative-time-element.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index 54ec790..ac80d63 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -66,20 +66,21 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat static get observedAttributes() { return [ - 'datetime', - 'day', - 'format', - 'lang', - 'hour', - 'minute', - 'month', 'second', - 'title', + 'minute', + 'hour', 'weekday', + 'day', + 'month', 'year', - 'tense', 'time-zone-name', - 'prefix' + 'prefix', + 'threhsold', + 'tense', + 'format', + 'datetime', + 'lang', + 'title' ] } From af2006d4f7822f87afebba59f2c898717b7192f3 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 09:56:16 +0000 Subject: [PATCH 02/10] add second property --- src/relative-time-element.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index ac80d63..0519847 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -129,6 +129,7 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat return relativeFormat.format(int, unit) } const formatter = new DateTimeFormat(locale, { + second: this.second, minute: this.minute, hour: this.hour, day: this.day, @@ -139,6 +140,15 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat return `${this.prefix} ${formatter.format(date)}`.trim() } + get second() { + const second = this.getAttribute('second') + if (second === 'numeric' || second === '2-digit') return second + } + + set second(value: 'numeric' | '2-digit' | undefined) { + this.setAttribute('second', value || '') + } + get minute() { const minute = this.getAttribute('minute') if (minute === 'numeric' || minute === '2-digit') return minute From 981071cc8633faa11156d1e37261b5fb7fe9b81c Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 09:56:26 +0000 Subject: [PATCH 03/10] add weekday property --- src/relative-time-element.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index 0519847..a807168 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -132,6 +132,7 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat second: this.second, minute: this.minute, hour: this.hour, + weekday: this.weekday, day: this.day, month: this.month, year: this.year, @@ -167,6 +168,15 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat this.setAttribute('hour', value || '') } + get weekday() { + const weekday = this.getAttribute('weekday') + if (weekday === 'long' || weekday === 'short' || weekday === 'narrow') return weekday + } + + set weekday(value: 'short' | 'long' | 'narrow' | undefined) { + this.setAttribute('weekday', value || '') + } + get day() { const day = this.getAttribute('day') ?? 'numeric' if (day === 'numeric' || day === '2-digit') return day From c53136e89e12832df75b7b663d9f07d75de3567b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:27:37 +0000 Subject: [PATCH 04/10] only use shadowDOM if it's available --- src/relative-time-element.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index a807168..cdc116e 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -64,6 +64,8 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat return this.closest('[lang]')?.getAttribute('lang') ?? 'default' } + #renderRoot: Node = this.shadowRoot ? this.shadowRoot : this.attachShadow ? this.attachShadow({mode: 'open'}) : this + static get observedAttributes() { return [ 'second', @@ -288,11 +290,6 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat this.datetime = value?.toISOString() || '' } - constructor() { - super() - if (!this.shadowRoot) this.attachShadow({mode: 'open'}) - } - connectedCallback(): void { this.update() } @@ -310,7 +307,7 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat } update() { - const oldText: string = this.shadowRoot!.textContent || '' + const oldText: string = this.#renderRoot.textContent || '' const oldTitle: string = this.getAttribute('title') || '' let newTitle: string = oldTitle let newText: string = oldText @@ -325,7 +322,7 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat newText = this.getFormattedDate(now) || '' if (newText) { - this.shadowRoot!.textContent = newText + this.#renderRoot.textContent = newText } if (newText !== oldText || newTitle !== oldTitle) { From 4d4af86740521ed6eb04c2048e1a006a07ec254a Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:34:42 +0000 Subject: [PATCH 05/10] move relative-time to duration-format --- src/{relative-time.ts => duration-format.ts} | 2 +- src/relative-time-element.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{relative-time.ts => duration-format.ts} (98%) diff --git a/src/relative-time.ts b/src/duration-format.ts similarity index 98% rename from src/relative-time.ts rename to src/duration-format.ts index 8591344..018700f 100644 --- a/src/relative-time.ts +++ b/src/duration-format.ts @@ -1,6 +1,6 @@ export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' -export default class RelativeTime { +export default class DurationFormat { date: Date constructor(date: Date) { diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index cdc116e..06cbd2a 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -1,4 +1,4 @@ -import DurationFormat from './relative-time.js' +import DurationFormat from './duration-format.js' import {DateTimeFormat as DateTimeFormatPonyFill} from './datetimeformat-ponyfill.js' import {RelativeTimeFormat as RelativeTimeFormatPonyfill} from './relative-time-ponyfill.js' import {isDuration, withinDuration} from './duration.js' From fbce2e2d064a9aa450b26cc51579d31db57e1bcf Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:34:55 +0000 Subject: [PATCH 06/10] add some basic tests for duration-format --- test/duration-format.ts | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/duration-format.ts diff --git a/test/duration-format.ts b/test/duration-format.ts new file mode 100644 index 0000000..c2db60a --- /dev/null +++ b/test/duration-format.ts @@ -0,0 +1,61 @@ +import {assert} from '@open-wc/testing' +import DurationFormat from '../src/duration-format.js' + +suite('duration format', function () { + let dateNow + function freezeTime(expected) { + dateNow = Date + + function MockDate(...args) { + if (args.length) { + return new dateNow(...args) + } + return new dateNow(expected) + } + + MockDate.UTC = dateNow.UTC + MockDate.parse = dateNow.parse + MockDate.now = () => expected.getTime() + MockDate.prototype = dateNow.prototype + + // eslint-disable-next-line no-global-assign + Date = MockDate + } + teardown(() => { + if (dateNow) { + // eslint-disable-next-line no-global-assign + Date = dateNow + dateNow = null + } + }) + + const referenceDate = '2022-10-24T14:46:00.000Z' + const tests = new Set([ + // Same as the current time + // Dates in the future + {method: 'timeUntil', datetime: '2022-10-24T15:46:00.000Z', expected: [1, 'hour']}, + {method: 'timeUntil', datetime: '2022-10-24T16:00:00.000Z', expected: [1, 'hour']}, + {method: 'timeUntil', datetime: '2022-10-24T16:15:00.000Z', expected: [1, 'hour']}, + {method: 'timeUntil', datetime: '2022-10-24T16:31:00.000Z', expected: [2, 'hour']}, + {method: 'timeUntil', datetime: '2022-10-30T14:46:00.000Z', expected: [6, 'day']}, + {method: 'timeUntil', datetime: '2022-11-24T14:46:00.000Z', expected: [1, 'month']}, + {method: 'timeUntil', datetime: '2023-10-23T14:46:00.000Z', expected: [1, 'year']}, + {method: 'timeUntil', datetime: '2023-10-24T14:46:00.000Z', expected: [1, 'year']}, + {method: 'timeUntil', datetime: '2024-03-31T14:46:00.000Z', expected: [1, 'year']}, + {method: 'timeUntil', datetime: '2024-04-01T14:46:00.000Z', expected: [2, 'year']}, + { + method: 'timeUntil', + reference: '2022-12-31T12:00:00.000Z', + datetime: '2024-03-01T12:00:00.000Z', + expected: [1, 'year'] + } + ]) + + for (const {method, datetime, expected, reference = referenceDate} of tests) { + test(`${datetime} ${method} -> ${expected}`, function () { + freezeTime(new Date(reference)) + assert.deepEqual(new DurationFormat(new Date(datetime))[method](), expected) + }) + } + +}) From c33c541f65d2536848a36ac99ff423025b068dd9 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:35:40 +0000 Subject: [PATCH 07/10] make duration-format a named export --- src/duration-format.ts | 2 +- src/relative-time-element.ts | 2 +- test/duration-format.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/duration-format.ts b/src/duration-format.ts index 018700f..c7c8c05 100644 --- a/src/duration-format.ts +++ b/src/duration-format.ts @@ -1,6 +1,6 @@ export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' -export default class DurationFormat { +export class DurationFormat { date: Date constructor(date: Date) { diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index 06cbd2a..532007a 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -1,4 +1,4 @@ -import DurationFormat from './duration-format.js' +import {DurationFormat} from './duration-format.js' import {DateTimeFormat as DateTimeFormatPonyFill} from './datetimeformat-ponyfill.js' import {RelativeTimeFormat as RelativeTimeFormatPonyfill} from './relative-time-ponyfill.js' import {isDuration, withinDuration} from './duration.js' diff --git a/test/duration-format.ts b/test/duration-format.ts index c2db60a..b44d129 100644 --- a/test/duration-format.ts +++ b/test/duration-format.ts @@ -1,5 +1,5 @@ import {assert} from '@open-wc/testing' -import DurationFormat from '../src/duration-format.js' +import {DurationFormat} from '../src/duration-format.js' suite('duration format', function () { let dateNow From e2920fc88ffad4537b950e2c379db5d5afe23ba9 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:38:43 +0000 Subject: [PATCH 08/10] refactor duration-format into functions, not class --- src/duration-format.ts | 210 +++++++++++++++++------------------ src/relative-time-element.ts | 7 +- test/duration-format.ts | 27 +++-- 3 files changed, 117 insertions(+), 127 deletions(-) diff --git a/src/duration-format.ts b/src/duration-format.ts index c7c8c05..520af7d 100644 --- a/src/duration-format.ts +++ b/src/duration-format.ts @@ -1,119 +1,111 @@ export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' -export class DurationFormat { - date: Date - - constructor(date: Date) { - this.date = date - } - - timeAgo(): [number, Unit] { - const ms = new Date().getTime() - this.date.getTime() - const sec = Math.round(ms / 1000) - const min = Math.round(sec / 60) - const hr = Math.round(min / 60) - const day = Math.round(hr / 24) - const month = Math.round(day / 30) - const year = Math.round(month / 12) - if (ms < 0) { - return [0, 'second'] - } else if (sec < 10) { - return [0, 'second'] - } else if (sec < 45) { - return [-sec, 'second'] - } else if (sec < 90) { - return [-min, 'minute'] - } else if (min < 45) { - return [-min, 'minute'] - } else if (min < 90) { - return [-hr, 'hour'] - } else if (hr < 24) { - return [-hr, 'hour'] - } else if (hr < 36) { - return [-day, 'day'] - } else if (day < 30) { - return [-day, 'day'] - } else if (month < 18) { - return [-month, 'month'] - } else { - return [-year, 'year'] - } +export function timeAgo(date: Date): [number, Unit] { + const ms = new Date().getTime() - date.getTime() + const sec = Math.round(ms / 1000) + const min = Math.round(sec / 60) + const hr = Math.round(min / 60) + const day = Math.round(hr / 24) + const month = Math.round(day / 30) + const year = Math.round(month / 12) + if (ms < 0) { + return [0, 'second'] + } else if (sec < 10) { + return [0, 'second'] + } else if (sec < 45) { + return [-sec, 'second'] + } else if (sec < 90) { + return [-min, 'minute'] + } else if (min < 45) { + return [-min, 'minute'] + } else if (min < 90) { + return [-hr, 'hour'] + } else if (hr < 24) { + return [-hr, 'hour'] + } else if (hr < 36) { + return [-day, 'day'] + } else if (day < 30) { + return [-day, 'day'] + } else if (month < 18) { + return [-month, 'month'] + } else { + return [-year, 'year'] } +} - microTimeAgo(): [number, Unit] { - const ms = new Date().getTime() - this.date.getTime() - const sec = Math.round(ms / 1000) - const min = Math.round(sec / 60) - const hr = Math.round(min / 60) - const day = Math.round(hr / 24) - const month = Math.round(day / 30) - const year = Math.round(month / 12) - if (min < 1) { - return [1, 'minute'] - } else if (min < 60) { - return [min, 'minute'] - } else if (hr < 24) { - return [hr, 'hour'] - } else if (day < 365) { - return [day, 'day'] - } else { - return [year, 'year'] - } +export function microTimeAgo(date: Date): [number, Unit] { + const ms = new Date().getTime() - date.getTime() + const sec = Math.round(ms / 1000) + const min = Math.round(sec / 60) + const hr = Math.round(min / 60) + const day = Math.round(hr / 24) + const month = Math.round(day / 30) + const year = Math.round(month / 12) + if (min < 1) { + return [1, 'minute'] + } else if (min < 60) { + return [min, 'minute'] + } else if (hr < 24) { + return [hr, 'hour'] + } else if (day < 365) { + return [day, 'day'] + } else { + return [year, 'year'] } +} - timeUntil(): [number, Unit] { - const ms = this.date.getTime() - new Date().getTime() - const sec = Math.round(ms / 1000) - const min = Math.round(sec / 60) - const hr = Math.round(min / 60) - const day = Math.round(hr / 24) - const month = Math.round(day / 30) - const year = Math.round(month / 12) - if (month >= 18) { - return [year, 'year'] - } else if (month >= 12) { - return [year, 'year'] - } else if (day >= 45) { - return [month, 'month'] - } else if (day >= 30) { - return [month, 'month'] - } else if (hr >= 36) { - return [day, 'day'] - } else if (hr >= 24) { - return [day, 'day'] - } else if (min >= 90) { - return [hr, 'hour'] - } else if (min >= 45) { - return [hr, 'hour'] - } else if (sec >= 90) { - return [min, 'minute'] - } else if (sec >= 45) { - return [min, 'minute'] - } else if (sec >= 10) { - return [sec, 'second'] - } else { - return [0, 'second'] - } +export function timeUntil(date: Date): [number, Unit] { + const ms = date.getTime() - new Date().getTime() + const sec = Math.round(ms / 1000) + const min = Math.round(sec / 60) + const hr = Math.round(min / 60) + const day = Math.round(hr / 24) + const month = Math.round(day / 30) + const year = Math.round(month / 12) + if (month >= 18) { + return [year, 'year'] + } else if (month >= 12) { + return [year, 'year'] + } else if (day >= 45) { + return [month, 'month'] + } else if (day >= 30) { + return [month, 'month'] + } else if (hr >= 36) { + return [day, 'day'] + } else if (hr >= 24) { + return [day, 'day'] + } else if (min >= 90) { + return [hr, 'hour'] + } else if (min >= 45) { + return [hr, 'hour'] + } else if (sec >= 90) { + return [min, 'minute'] + } else if (sec >= 45) { + return [min, 'minute'] + } else if (sec >= 10) { + return [sec, 'second'] + } else { + return [0, 'second'] } +} - microTimeUntil(): [number, Unit] { - const ms = this.date.getTime() - new Date().getTime() - const sec = Math.round(ms / 1000) - const min = Math.round(sec / 60) - const hr = Math.round(min / 60) - const day = Math.round(hr / 24) - const month = Math.round(day / 30) - const year = Math.round(month / 12) - if (day >= 365) { - return [year, 'year'] - } else if (hr >= 24) { - return [day, 'day'] - } else if (min >= 60) { - return [hr, 'hour'] - } else if (min > 1) { - return [min, 'minute'] - } else { - return [1, 'minute'] - } +export function microTimeUntil(date: Date): [number, Unit] { + const ms = date.getTime() - new Date().getTime() + const sec = Math.round(ms / 1000) + const min = Math.round(sec / 60) + const hr = Math.round(min / 60) + const day = Math.round(hr / 24) + const month = Math.round(day / 30) + const year = Math.round(month / 12) + if (day >= 365) { + return [year, 'year'] + } else if (hr >= 24) { + return [day, 'day'] + } else if (min >= 60) { + return [hr, 'hour'] + } else if (min > 1) { + return [min, 'minute'] + } else { + return [1, 'minute'] } } diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index 532007a..be35920 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -1,4 +1,4 @@ -import {DurationFormat} from './duration-format.js' +import {microTimeAgo, microTimeUntil, timeUntil, timeAgo} from './duration-format.js' import {DateTimeFormat as DateTimeFormatPonyFill} from './datetimeformat-ponyfill.js' import {RelativeTimeFormat as RelativeTimeFormatPonyfill} from './relative-time-ponyfill.js' import {isDuration, withinDuration} from './duration.js' @@ -117,16 +117,15 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat const inFuture = now.getTime() < date.getTime() const within = withinDuration(now, date, this.threshold) const locale = this.#lang - const durationFormat = new DurationFormat(date) const relativeFormat = new RelativeTimeFormat(locale, {numeric: 'auto'}) if (tense === 'past' || (tense === 'auto' && !inFuture && within)) { - const [int, unit] = micro ? durationFormat.microTimeAgo() : durationFormat.timeAgo() + const [int, unit] = micro ? microTimeAgo(date) : timeAgo(date) if (micro) return `${int}${unit[0]}` return relativeFormat.format(int, unit) } if (tense === 'future' || (tense === 'auto' && inFuture && within)) { - const [int, unit] = micro ? durationFormat.microTimeUntil() : durationFormat.timeUntil() + const [int, unit] = micro ? microTimeUntil(date) : timeUntil(date) if (micro) return `${int}${unit[0]}` return relativeFormat.format(int, unit) } diff --git a/test/duration-format.ts b/test/duration-format.ts index b44d129..fdf8b97 100644 --- a/test/duration-format.ts +++ b/test/duration-format.ts @@ -1,5 +1,5 @@ import {assert} from '@open-wc/testing' -import {DurationFormat} from '../src/duration-format.js' +import {timeUntil} from '../src/duration-format.js' suite('duration format', function () { let dateNow @@ -33,18 +33,18 @@ suite('duration format', function () { const tests = new Set([ // Same as the current time // Dates in the future - {method: 'timeUntil', datetime: '2022-10-24T15:46:00.000Z', expected: [1, 'hour']}, - {method: 'timeUntil', datetime: '2022-10-24T16:00:00.000Z', expected: [1, 'hour']}, - {method: 'timeUntil', datetime: '2022-10-24T16:15:00.000Z', expected: [1, 'hour']}, - {method: 'timeUntil', datetime: '2022-10-24T16:31:00.000Z', expected: [2, 'hour']}, - {method: 'timeUntil', datetime: '2022-10-30T14:46:00.000Z', expected: [6, 'day']}, - {method: 'timeUntil', datetime: '2022-11-24T14:46:00.000Z', expected: [1, 'month']}, - {method: 'timeUntil', datetime: '2023-10-23T14:46:00.000Z', expected: [1, 'year']}, - {method: 'timeUntil', datetime: '2023-10-24T14:46:00.000Z', expected: [1, 'year']}, - {method: 'timeUntil', datetime: '2024-03-31T14:46:00.000Z', expected: [1, 'year']}, - {method: 'timeUntil', datetime: '2024-04-01T14:46:00.000Z', expected: [2, 'year']}, + {method: timeUntil, datetime: '2022-10-24T15:46:00.000Z', expected: [1, 'hour']}, + {method: timeUntil, datetime: '2022-10-24T16:00:00.000Z', expected: [1, 'hour']}, + {method: timeUntil, datetime: '2022-10-24T16:15:00.000Z', expected: [1, 'hour']}, + {method: timeUntil, datetime: '2022-10-24T16:31:00.000Z', expected: [2, 'hour']}, + {method: timeUntil, datetime: '2022-10-30T14:46:00.000Z', expected: [6, 'day']}, + {method: timeUntil, datetime: '2022-11-24T14:46:00.000Z', expected: [1, 'month']}, + {method: timeUntil, datetime: '2023-10-23T14:46:00.000Z', expected: [1, 'year']}, + {method: timeUntil, datetime: '2023-10-24T14:46:00.000Z', expected: [1, 'year']}, + {method: timeUntil, datetime: '2024-03-31T14:46:00.000Z', expected: [1, 'year']}, + {method: timeUntil, datetime: '2024-04-01T14:46:00.000Z', expected: [2, 'year']}, { - method: 'timeUntil', + method: timeUntil, reference: '2022-12-31T12:00:00.000Z', datetime: '2024-03-01T12:00:00.000Z', expected: [1, 'year'] @@ -54,8 +54,7 @@ suite('duration format', function () { for (const {method, datetime, expected, reference = referenceDate} of tests) { test(`${datetime} ${method} -> ${expected}`, function () { freezeTime(new Date(reference)) - assert.deepEqual(new DurationFormat(new Date(datetime))[method](), expected) + assert.deepEqual(method(new Date(datetime)), expected) }) } - }) From 6b9d2f44b817266b57e65c4c3e7e801eca25481a Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:39:23 +0000 Subject: [PATCH 09/10] npm audit fix --force --- package-lock.json | 98 +++-------------------------------------------- 1 file changed, 6 insertions(+), 92 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb92880..0a1b90c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -217,18 +217,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@esm-bundle/chai": { "version": "4.3.4-fix.0", "resolved": "https://registry.npmjs.org/@esm-bundle/chai/-/chai-4.3.4-fix.0.tgz", @@ -2739,18 +2727,6 @@ "node": ">=0.10.0" } }, - "node_modules/eslint-plugin-import/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-import/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2790,18 +2766,6 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, - "node_modules/eslint-plugin-jsx-a11y/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-jsx-a11y/node_modules/semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -2981,18 +2945,6 @@ "node": ">=8" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -4471,9 +4423,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -6236,17 +6188,6 @@ "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" - }, - "dependencies": { - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } } }, "@esm-bundle/chai": { @@ -8100,15 +8041,6 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -8268,15 +8200,6 @@ "esutils": "^2.0.2" } }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -8312,15 +8235,6 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", @@ -9484,9 +9398,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From 68ae19a139ff9614c400add7e6c255286764d18f Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 4 Nov 2022 11:41:49 +0000 Subject: [PATCH 10/10] add missing properties to readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 131468b..a037dd0 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,10 @@ So, a relative date phrase is used for up to a month and then the actual date is | `tense` | `tense` | `'auto'\|'past'\|'future'` | `'auto'` | | `threshold` | `threshold` | `string` | `'P30D'` | | `prefix` | `prefix` | `string` | `'on'` | +| `second` | `second` | `'numeric'\|'2-digit'\|undefined` | `undefined` | | `minute` | `minute` | `'numeric'\|'2-digit'\|undefined` | `undefined` | | `hour` | `hour` | `'numeric'\|'2-digit'\|undefined` | `undefined` | +| `weekday` | `weekday` | `'short'\|'long'\|'narrow'\|undefined` | `undefined` | | `day` | `day` | `'numeric'\|'2-digit'\|undefined` | `'numeric'` | | `month` | `month` | `'numeric'\|'2-digit'\|'short'\|'long'\|'narrow'\|undefined` | `'short'` | | `year` | `year` | `'numeric'\|'2-digit'\|undefined` | `'numeric'`*| @@ -148,7 +150,7 @@ When formatting an absolute date (see above `threshold` for more details) it can ``` -##### minute, hour, day, month, year, timeZoneName +##### second, minute, hour, weekday, day, month, year, timeZoneName For dates outside of the specified `threshold`, the formatting of the date can be configured using these attributes. The values for these attributes are passed to [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat):