@beyonk/date-utils
Advanced tools
Comparing version 4.9.0 to 4.9.1
@@ -5,4 +5,8 @@ import { pluralize } from 'just-pluralize' | ||
const defaultTranslate = ({ time }) => { | ||
return `until ${time}` | ||
} | ||
function formatFinish ({ start, finish }, opts = {}) { | ||
const { format, ...otherOpts } = opts | ||
const { format, translate = defaultTranslate, ...otherOpts } = opts | ||
@@ -20,4 +24,4 @@ switch (format) { | ||
return finish.isSame(start, 'day') | ||
? `until ${formatShortTime(finish, otherOpts)}` | ||
: `until ${formatMediumDateTime(finish, otherOpts)}` | ||
? translate({ time: formatShortTime(finish, otherOpts) }) | ||
: translate({ time: formatMediumDateTime(finish, otherOpts) }) | ||
} | ||
@@ -24,0 +28,0 @@ } |
@@ -25,2 +25,14 @@ import { expect } from '@hapi/code' | ||
expectation: 'until Sun, 31 Oct, 14:15' | ||
}, | ||
{ | ||
test: 'passed translate function', | ||
interval: { | ||
start: dayjs('2021-10-30T12:15'), | ||
finish: dayjs('2021-10-31T14:15') | ||
}, | ||
opts: { | ||
locale: 'en-GB', | ||
translate: ({ time }) => `finishes at ${time}` | ||
}, | ||
expectation: 'finishes at Sun, 31 Oct, 14:15' | ||
} | ||
@@ -27,0 +39,0 @@ ] |
{ | ||
"name": "@beyonk/date-utils", | ||
"version": "4.9.0", | ||
"version": "4.9.1", | ||
"description": "Beyonk Date Utils", | ||
@@ -40,2 +40,3 @@ "author": "Antony Jones <aj@desirableobjects.co.uk>", | ||
}, | ||
"access": "restricted", | ||
"scripts": { | ||
@@ -42,0 +43,0 @@ "test": "NODE_ENV=test mocha './!(node_modules)/**/**.+(spec).js'", |
Sorry, the diff of this file is not supported yet
55851
1805