From 9b0cfbf2f0c21aff62db38b3b1cb52860a3d54d3 Mon Sep 17 00:00:00 2001 From: Chinenye Onuegbu Date: Thu, 18 Oct 2018 13:10:31 +0200 Subject: [PATCH] Add roundToNearestMinutes function (#928) (closes #787) --- CHANGELOG.md | 2 + src/esm/fp/index.js | 2 + src/esm/index.js | 1 + src/esm/locale/index.js | 2 + src/fp/index.js | 2 + src/fp/index.js.flow | 2 + src/fp/roundToNearestMinutes/index.d.ts | 4 + src/fp/roundToNearestMinutes/index.js | 8 ++ src/fp/roundToNearestMinutes/index.js.flow | 55 ++++++++ .../index.d.ts | 4 + .../roundToNearestMinutesWithOptions/index.js | 8 ++ .../index.js.flow | 59 +++++++++ src/fp/test.js | 16 +++ src/index.js | 1 + src/index.js.flow | 6 + src/locale/index.js | 2 + src/roundToNearestMinutes/index.d.ts | 4 + src/roundToNearestMinutes/index.js | 49 +++++++ src/roundToNearestMinutes/index.js.flow | 54 ++++++++ src/roundToNearestMinutes/test.js | 74 +++++++++++ typings.d.ts | 122 ++++++++++++++++++ 21 files changed, 477 insertions(+) create mode 100644 src/fp/roundToNearestMinutes/index.d.ts create mode 100644 src/fp/roundToNearestMinutes/index.js create mode 100644 src/fp/roundToNearestMinutes/index.js.flow create mode 100644 src/fp/roundToNearestMinutesWithOptions/index.d.ts create mode 100644 src/fp/roundToNearestMinutesWithOptions/index.js create mode 100644 src/fp/roundToNearestMinutesWithOptions/index.js.flow create mode 100644 src/roundToNearestMinutes/index.d.ts create mode 100644 src/roundToNearestMinutes/index.js create mode 100644 src/roundToNearestMinutes/index.js.flow create mode 100644 src/roundToNearestMinutes/test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d95a83172b..2273361b3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,8 @@ for the list of changes made since `v2.0.0-alpha.1`. - `lastDayOfDecade` +- Added `roundToNearestMinutes` + ### Changed - **BREAKING**: new format string API for `format` function diff --git a/src/esm/fp/index.js b/src/esm/fp/index.js index fb60905598..080c08961f 100644 --- a/src/esm/fp/index.js +++ b/src/esm/fp/index.js @@ -220,6 +220,8 @@ export {default as min} from './min/index.js' export {default as minWithOptions} from './minWithOptions/index.js' export {default as parse} from './parse/index.js' export {default as parseWithOptions} from './parseWithOptions/index.js' +export {default as roundToNearestMinutes} from './roundToNearestMinutes/index.js' +export {default as roundToNearestMinutesWithOptions} from './roundToNearestMinutesWithOptions/index.js' export {default as setDate} from './setDate/index.js' export {default as setDateWithOptions} from './setDateWithOptions/index.js' export {default as setDay} from './setDay/index.js' diff --git a/src/esm/index.js b/src/esm/index.js index 6f58a4e0f8..c37a5c7445 100644 --- a/src/esm/index.js +++ b/src/esm/index.js @@ -110,6 +110,7 @@ export {default as lastDayOfYear} from './lastDayOfYear/index.js' export {default as max} from './max/index.js' export {default as min} from './min/index.js' export {default as parse} from './parse/index.js' +export {default as roundToNearestMinutes} from './roundToNearestMinutes/index.js' export {default as setDate} from './setDate/index.js' export {default as setDay} from './setDay/index.js' export {default as setDayOfYear} from './setDayOfYear/index.js' diff --git a/src/esm/locale/index.js b/src/esm/locale/index.js index a3d56cd782..d17e12b474 100644 --- a/src/esm/locale/index.js +++ b/src/esm/locale/index.js @@ -1,5 +1,6 @@ // This file is generated automatically by `scripts/build/indices.js`. Please, don't change it. +export {default as af} from './af/index.js' export {default as bn} from './bn/index.js' export {default as de} from './de/index.js' export {default as enCA} from './en-CA/index.js' @@ -9,6 +10,7 @@ export {default as eo} from './eo/index.js' export {default as es} from './es/index.js' export {default as et} from './et/index.js' export {default as fr} from './fr/index.js' +export {default as gl} from './gl/index.js' export {default as he} from './he/index.js' export {default as hu} from './hu/index.js' export {default as it} from './it/index.js' diff --git a/src/fp/index.js b/src/fp/index.js index 8e20e0b115..ec6d9687d3 100644 --- a/src/fp/index.js +++ b/src/fp/index.js @@ -221,6 +221,8 @@ module.exports = { minWithOptions: require('./minWithOptions/index.js'), parse: require('./parse/index.js'), parseWithOptions: require('./parseWithOptions/index.js'), + roundToNearestMinutes: require('./roundToNearestMinutes/index.js'), + roundToNearestMinutesWithOptions: require('./roundToNearestMinutesWithOptions/index.js'), setDate: require('./setDate/index.js'), setDateWithOptions: require('./setDateWithOptions/index.js'), setDay: require('./setDay/index.js'), diff --git a/src/fp/index.js.flow b/src/fp/index.js.flow index 6facc7d30c..2437aab5af 100644 --- a/src/fp/index.js.flow +++ b/src/fp/index.js.flow @@ -282,6 +282,8 @@ declare module.exports: { minWithOptions: CurriedFn2, parse: CurriedFn3, parseWithOptions: CurriedFn4, + roundToNearestMinutes: CurriedFn2, + roundToNearestMinutesWithOptions: CurriedFn3, setDate: CurriedFn2, setDateWithOptions: CurriedFn3, setDay: CurriedFn2, diff --git a/src/fp/roundToNearestMinutes/index.d.ts b/src/fp/roundToNearestMinutes/index.d.ts new file mode 100644 index 0000000000..d2aaff5272 --- /dev/null +++ b/src/fp/roundToNearestMinutes/index.d.ts @@ -0,0 +1,4 @@ +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +import {roundToNearestMinutes} from 'date-fns/fp' +export = roundToNearestMinutes diff --git a/src/fp/roundToNearestMinutes/index.js b/src/fp/roundToNearestMinutes/index.js new file mode 100644 index 0000000000..a56ffdca76 --- /dev/null +++ b/src/fp/roundToNearestMinutes/index.js @@ -0,0 +1,8 @@ +// This file is generated automatically by `scripts/build/fp.js`. Please, don't change it. + +import fn from '../../roundToNearestMinutes/index.js' +import convertToFP from '../_lib/convertToFP/index.js' + +var roundToNearestMinutes = convertToFP(fn, 2) + +export default roundToNearestMinutes diff --git a/src/fp/roundToNearestMinutes/index.js.flow b/src/fp/roundToNearestMinutes/index.js.flow new file mode 100644 index 0000000000..148996fc2f --- /dev/null +++ b/src/fp/roundToNearestMinutes/index.js.flow @@ -0,0 +1,55 @@ +// @flow +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +type Interval = { + start: Date | string | number, + end: Date | string | number +} + +type Options = { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7, + additionalDigits?: 0 | 1 | 2, + locale?: Locale, + includeSeconds?: boolean, + addSuffix?: boolean, + unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year', + roundingMethod?: 'floor' | 'ceil' | 'round', + awareOfUnicodeTokens?: boolean +} + +type Locale = { + formatDistance: Function, + formatRelative: Function, + localize: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + formatLong: Object, + date: Function, + time: Function, + dateTime: Function, + match: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + options?: { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 + } +} + +type CurriedFn1 = (a: A) => R + +type CurriedFn2 = (a: A) => CurriedFn1 + | (a: A, b: B) => R + +declare module.exports: CurriedFn2 diff --git a/src/fp/roundToNearestMinutesWithOptions/index.d.ts b/src/fp/roundToNearestMinutesWithOptions/index.d.ts new file mode 100644 index 0000000000..5c11131345 --- /dev/null +++ b/src/fp/roundToNearestMinutesWithOptions/index.d.ts @@ -0,0 +1,4 @@ +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +import {roundToNearestMinutesWithOptions} from 'date-fns/fp' +export = roundToNearestMinutesWithOptions diff --git a/src/fp/roundToNearestMinutesWithOptions/index.js b/src/fp/roundToNearestMinutesWithOptions/index.js new file mode 100644 index 0000000000..0ea1077c8c --- /dev/null +++ b/src/fp/roundToNearestMinutesWithOptions/index.js @@ -0,0 +1,8 @@ +// This file is generated automatically by `scripts/build/fp.js`. Please, don't change it. + +import fn from '../../roundToNearestMinutes/index.js' +import convertToFP from '../_lib/convertToFP/index.js' + +var roundToNearestMinutesWithOptions = convertToFP(fn, 3) + +export default roundToNearestMinutesWithOptions diff --git a/src/fp/roundToNearestMinutesWithOptions/index.js.flow b/src/fp/roundToNearestMinutesWithOptions/index.js.flow new file mode 100644 index 0000000000..0934082a08 --- /dev/null +++ b/src/fp/roundToNearestMinutesWithOptions/index.js.flow @@ -0,0 +1,59 @@ +// @flow +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +type Interval = { + start: Date | string | number, + end: Date | string | number +} + +type Options = { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7, + additionalDigits?: 0 | 1 | 2, + locale?: Locale, + includeSeconds?: boolean, + addSuffix?: boolean, + unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year', + roundingMethod?: 'floor' | 'ceil' | 'round', + awareOfUnicodeTokens?: boolean +} + +type Locale = { + formatDistance: Function, + formatRelative: Function, + localize: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + formatLong: Object, + date: Function, + time: Function, + dateTime: Function, + match: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + options?: { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 + } +} + +type CurriedFn1 = (a: A) => R + +type CurriedFn2 = (a: A) => CurriedFn1 + | (a: A, b: B) => R + +type CurriedFn3 = (a: A) => CurriedFn2 + | (a: A, b: B) => CurriedFn1 + | (a: A, b: B, c: C) => R + +declare module.exports: CurriedFn3 diff --git a/src/fp/test.js b/src/fp/test.js index 366fadf05c..7bec0f5b91 100644 --- a/src/fp/test.js +++ b/src/fp/test.js @@ -1307,6 +1307,22 @@ describe('FP functions', function () { assert.deepEqual(result, new Date(2016, 10 /* Nov */, 5, 4, 4, 4, 0)) }) + it('roundToNearestMinutes', function () { + var result = fp.roundToNearestMinutes(5)(new Date(2014, 6 /* Jul */, 10, 12, 11, 34, 99)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 10)) + + var result = fp.roundToNearestMinutes()(new Date(2014, 6 /* Jul */, 10, 12, 11, 34, 99)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 11)) + }) + + it('roundToNearestMinutesWithOptions', function () { + var result = fp.roundToNearestMinutesWithOptions({})(5)(new Date(2014, 6 /* Jul */, 10, 12, 11, 34, 99)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 10)) + + var result = fp.roundToNearestMinutesWithOptions({})()(new Date(2014, 6 /* Jul */, 10, 12, 11, 34, 99)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 11)) + }) + it('setDate', function () { var result = fp.setDate(30)(new Date(2014, 8 /* Sep */, 1)) assert.deepEqual(result, new Date(2014, 8 /* Sep */, 30)) diff --git a/src/index.js b/src/index.js index 48a8c438ae..d0694efe4a 100644 --- a/src/index.js +++ b/src/index.js @@ -111,6 +111,7 @@ module.exports = { max: require('./max/index.js'), min: require('./min/index.js'), parse: require('./parse/index.js'), + roundToNearestMinutes: require('./roundToNearestMinutes/index.js'), setDate: require('./setDate/index.js'), setDay: require('./setDay/index.js'), setDayOfYear: require('./setDayOfYear/index.js'), diff --git a/src/index.js.flow b/src/index.js.flow index bc35b8369c..95606b07f5 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -651,6 +651,12 @@ declare module.exports: { options?: Options ) => Date, + roundToNearestMinutes: ( + date: Date | string | number, + nearestTo?: number, + options?: Options + ) => Date, + setDate: ( date: Date | string | number, dayOfMonth: number, diff --git a/src/locale/index.js b/src/locale/index.js index a9a09be870..5cc82f40f3 100644 --- a/src/locale/index.js +++ b/src/locale/index.js @@ -1,6 +1,7 @@ // This file is generated automatically by `scripts/build/indices.js`. Please, don't change it. module.exports = { + af: require('./af/index.js'), bn: require('./bn/index.js'), de: require('./de/index.js'), enCA: require('./en-CA/index.js'), @@ -10,6 +11,7 @@ module.exports = { es: require('./es/index.js'), et: require('./et/index.js'), fr: require('./fr/index.js'), + gl: require('./gl/index.js'), he: require('./he/index.js'), hu: require('./hu/index.js'), it: require('./it/index.js'), diff --git a/src/roundToNearestMinutes/index.d.ts b/src/roundToNearestMinutes/index.d.ts new file mode 100644 index 0000000000..c7574e655b --- /dev/null +++ b/src/roundToNearestMinutes/index.d.ts @@ -0,0 +1,4 @@ +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +import {roundToNearestMinutes} from 'date-fns' +export = roundToNearestMinutes diff --git a/src/roundToNearestMinutes/index.js b/src/roundToNearestMinutes/index.js new file mode 100644 index 0000000000..907e482fba --- /dev/null +++ b/src/roundToNearestMinutes/index.js @@ -0,0 +1,49 @@ +import toDate from '../toDate/index.js' +import toInteger from '../_lib/toInteger/index.js' + +/** + * @name roundToNearestMinutes + * @category Minute Helpers + * @summary Rounds the given date to the nearest minute + * + * @description + * Rounds the given date to the nearest minute + * + * @param {Date|String|Number} date - the date to round + * @param {Number} [nearestTo=1] - the closest minute to round to, must be between 1 and 30 inclusive + * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} + * @returns {Date} the new date rounded to the closest minute + * @throws {TypeError} 1 argument required + * @throws {RangeError} `nearestTo` must be between 1 and 30 + * + * @example + * // Round 10 July 2014 12:12:34 to nearest minute: + * var result = roundToNearestMinutes(new Date(2014, 6, 10, 12, 12, 34)) + * //=> Thu Jul 10 2014 12:13:00 + */ +export default function roundToNearestMinutes (dirtyDate, dirtyNearestTo, dirtyOptions) { + if (arguments.length < 1) { + throw new TypeError('1 argument required, but only none provided present') + } + + var nearestTo = arguments.length === 1 ? 1 : toInteger(dirtyNearestTo) + + if (arguments.length === 2 && typeof dirtyNearestTo !== 'number' && typeof dirtyNearestTo !== 'string') { + dirtyOptions = dirtyNearestTo + nearestTo = 1 + } + + if (!nearestTo || nearestTo > 30 || nearestTo < 1) { + throw new RangeError('nearestTo must be between 1 and 30') + } + + var date = toDate(dirtyDate, dirtyOptions) + var seconds = date.getSeconds() // relevant if nearestTo is 1, which is the default case + var minutes = date.getMinutes() + seconds / 60 + var roundedMinutes = Math.floor(minutes / nearestTo) * nearestTo + var remainderMinutes = minutes % nearestTo + var addedMinutes = Math.round(remainderMinutes / nearestTo) * nearestTo + + return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), roundedMinutes + addedMinutes) +} diff --git a/src/roundToNearestMinutes/index.js.flow b/src/roundToNearestMinutes/index.js.flow new file mode 100644 index 0000000000..b7b0da25b2 --- /dev/null +++ b/src/roundToNearestMinutes/index.js.flow @@ -0,0 +1,54 @@ +// @flow +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +type Interval = { + start: Date | string | number, + end: Date | string | number +} + +type Options = { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7, + additionalDigits?: 0 | 1 | 2, + locale?: Locale, + includeSeconds?: boolean, + addSuffix?: boolean, + unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year', + roundingMethod?: 'floor' | 'ceil' | 'round', + awareOfUnicodeTokens?: boolean +} + +type Locale = { + formatDistance: Function, + formatRelative: Function, + localize: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + formatLong: Object, + date: Function, + time: Function, + dateTime: Function, + match: { + ordinalNumber: Function, + era: Function, + quarter: Function, + month: Function, + day: Function, + dayPeriod: Function + }, + options?: { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7 + } +} + +declare module.exports: ( + date: Date | string | number, + nearestTo?: number, + options?: Options +) => Date diff --git a/src/roundToNearestMinutes/test.js b/src/roundToNearestMinutes/test.js new file mode 100644 index 0000000000..e775b1d56e --- /dev/null +++ b/src/roundToNearestMinutes/test.js @@ -0,0 +1,74 @@ +// @flow +/* eslint-env mocha */ + +import assert from 'power-assert' +import roundToNearestMinutes from '.' + +describe('roundToNearestMinutes', function () { + it('rounds given date to the nearest minute by default', function () { + var result = roundToNearestMinutes(new Date(2014, 6 /* Jul */, 10, 12, 16, 16)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 16, 0)) + }) + + it('accepts a string', function () { + var result = roundToNearestMinutes( + new Date(2014, 6 /* Jul */, 10, 12, 13, 16).toISOString() + ) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 13, 0)) + }) + + it('accepts a timestamp', function () { + var result = roundToNearestMinutes( + new Date(2014, 6 /* Jul */, 10, 12, 13, 16).getTime() + ) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 13, 0)) + }) + + it('rounds to the closest x minutes if nearestTo is provided', function () { + var result = roundToNearestMinutes(new Date(2014, 6 /* Jul */, 10, 12, 10, 30), 4) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 12, 0)) + }) + + it('rounds up >=30 seconds for nearestTo=1', function () { + var result = roundToNearestMinutes(new Date(2014, 6 /* Jul */, 10, 12, 13, 30)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 14, 0)) + }) + + it('rounds down <30 seconds for nearestTo=1', function () { + var result = roundToNearestMinutes(new Date(2014, 6 /* Jul */, 10, 12, 13, 29, 999)) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 13, 0)) + }) + + it('does not mutate the original date', function () { + var date = new Date(2014, 6 /* Jul */, 10, 12, 10, 10, 99) + roundToNearestMinutes(date) + assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 10, 10, 99)) + }) + + it('treats second arg as options if not string or number', function () { + // $ExpectedMistake + var result = roundToNearestMinutes(new Date(2014, 6 /* Jul */, 10, 12, 13, 29, 999), {}) + assert.deepEqual(result, new Date(2014, 6 /* Jul */, 10, 12, 13, 0)) + }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = roundToNearestMinutes(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = roundToNearestMinutes.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 10, 30), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) + + it('throws `TypeError` exception if passed less than 1 argument', function () { + assert.throws(roundToNearestMinutes.bind(null), TypeError) + }) + + it('throws `RangeError` if nearestTo is not between 1 and 30', function () { + var date = new Date(2014, 6 /* Jul */, 10, 12, 10, 30) + assert.throws(roundToNearestMinutes.bind(null, date, 31), RangeError) + assert.throws(roundToNearestMinutes.bind(null, date, 0), RangeError) + }) +}) diff --git a/typings.d.ts b/typings.d.ts index ec6fdde250..be4eb761b0 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -788,6 +788,13 @@ declare module 'date-fns' { ): Date namespace parse {} + function roundToNearestMinutes ( + date: Date | string | number, + nearestTo?: number, + options?: Options + ): Date + namespace roundToNearestMinutes {} + function setDate ( date: Date | string | number, dayOfMonth: number, @@ -1592,6 +1599,11 @@ declare module 'date-fns/parse' { export = parse } +declare module 'date-fns/roundToNearestMinutes' { + import {roundToNearestMinutes} from 'date-fns' + export = roundToNearestMinutes +} + declare module 'date-fns/setDate' { import {setDate} from 'date-fns' export = setDate @@ -2332,6 +2344,11 @@ declare module 'date-fns/parse/index' { export = parse } +declare module 'date-fns/roundToNearestMinutes/index' { + import {roundToNearestMinutes} from 'date-fns' + export = roundToNearestMinutes +} + declare module 'date-fns/setDate/index' { import {setDate} from 'date-fns' export = setDate @@ -3072,6 +3089,11 @@ declare module 'date-fns/parse/index.js' { export = parse } +declare module 'date-fns/roundToNearestMinutes/index.js' { + import {roundToNearestMinutes} from 'date-fns' + export = roundToNearestMinutes +} + declare module 'date-fns/setDate/index.js' { import {setDate} from 'date-fns' export = setDate @@ -3925,6 +3947,12 @@ declare module 'date-fns/fp' { const parseWithOptions: CurriedFn4 namespace parseWithOptions {} + const roundToNearestMinutes: CurriedFn2 + namespace roundToNearestMinutes {} + + const roundToNearestMinutesWithOptions: CurriedFn3 + namespace roundToNearestMinutesWithOptions {} + const setDate: CurriedFn2 namespace setDate {} @@ -5254,6 +5282,16 @@ declare module 'date-fns/fp/parseWithOptions' { export = parseWithOptions } +declare module 'date-fns/fp/roundToNearestMinutes' { + import {roundToNearestMinutes} from 'date-fns/fp' + export = roundToNearestMinutes +} + +declare module 'date-fns/fp/roundToNearestMinutesWithOptions' { + import {roundToNearestMinutesWithOptions} from 'date-fns/fp' + export = roundToNearestMinutesWithOptions +} + declare module 'date-fns/fp/setDate' { import {setDate} from 'date-fns/fp' export = setDate @@ -6734,6 +6772,16 @@ declare module 'date-fns/fp/parseWithOptions/index' { export = parseWithOptions } +declare module 'date-fns/fp/roundToNearestMinutes/index' { + import {roundToNearestMinutes} from 'date-fns/fp' + export = roundToNearestMinutes +} + +declare module 'date-fns/fp/roundToNearestMinutesWithOptions/index' { + import {roundToNearestMinutesWithOptions} from 'date-fns/fp' + export = roundToNearestMinutesWithOptions +} + declare module 'date-fns/fp/setDate/index' { import {setDate} from 'date-fns/fp' export = setDate @@ -8214,6 +8262,16 @@ declare module 'date-fns/fp/parseWithOptions/index.js' { export = parseWithOptions } +declare module 'date-fns/fp/roundToNearestMinutes/index.js' { + import {roundToNearestMinutes} from 'date-fns/fp' + export = roundToNearestMinutes +} + +declare module 'date-fns/fp/roundToNearestMinutesWithOptions/index.js' { + import {roundToNearestMinutesWithOptions} from 'date-fns/fp' + export = roundToNearestMinutesWithOptions +} + declare module 'date-fns/fp/setDate/index.js' { import {setDate} from 'date-fns/fp' export = setDate @@ -9310,6 +9368,13 @@ declare module 'date-fns/esm' { ): Date namespace parse {} + function roundToNearestMinutes ( + date: Date | string | number, + nearestTo?: number, + options?: Options + ): Date + namespace roundToNearestMinutes {} + function setDate ( date: Date | string | number, dayOfMonth: number, @@ -10114,6 +10179,11 @@ declare module 'date-fns/esm/parse' { export default parse } +declare module 'date-fns/esm/roundToNearestMinutes' { + import {roundToNearestMinutes} from 'date-fns/esm' + export default roundToNearestMinutes +} + declare module 'date-fns/esm/setDate' { import {setDate} from 'date-fns/esm' export default setDate @@ -10854,6 +10924,11 @@ declare module 'date-fns/esm/parse/index' { export default parse } +declare module 'date-fns/esm/roundToNearestMinutes/index' { + import {roundToNearestMinutes} from 'date-fns/esm' + export default roundToNearestMinutes +} + declare module 'date-fns/esm/setDate/index' { import {setDate} from 'date-fns/esm' export default setDate @@ -11594,6 +11669,11 @@ declare module 'date-fns/esm/parse/index.js' { export default parse } +declare module 'date-fns/esm/roundToNearestMinutes/index.js' { + import {roundToNearestMinutes} from 'date-fns/esm' + export default roundToNearestMinutes +} + declare module 'date-fns/esm/setDate/index.js' { import {setDate} from 'date-fns/esm' export default setDate @@ -12447,6 +12527,12 @@ declare module 'date-fns/esm/fp' { const parseWithOptions: CurriedFn4 namespace parseWithOptions {} + const roundToNearestMinutes: CurriedFn2 + namespace roundToNearestMinutes {} + + const roundToNearestMinutesWithOptions: CurriedFn3 + namespace roundToNearestMinutesWithOptions {} + const setDate: CurriedFn2 namespace setDate {} @@ -13776,6 +13862,16 @@ declare module 'date-fns/esm/fp/parseWithOptions' { export default parseWithOptions } +declare module 'date-fns/esm/fp/roundToNearestMinutes' { + import {roundToNearestMinutes} from 'date-fns/esm/fp' + export default roundToNearestMinutes +} + +declare module 'date-fns/esm/fp/roundToNearestMinutesWithOptions' { + import {roundToNearestMinutesWithOptions} from 'date-fns/esm/fp' + export default roundToNearestMinutesWithOptions +} + declare module 'date-fns/esm/fp/setDate' { import {setDate} from 'date-fns/esm/fp' export default setDate @@ -15256,6 +15352,16 @@ declare module 'date-fns/esm/fp/parseWithOptions/index' { export default parseWithOptions } +declare module 'date-fns/esm/fp/roundToNearestMinutes/index' { + import {roundToNearestMinutes} from 'date-fns/esm/fp' + export default roundToNearestMinutes +} + +declare module 'date-fns/esm/fp/roundToNearestMinutesWithOptions/index' { + import {roundToNearestMinutesWithOptions} from 'date-fns/esm/fp' + export default roundToNearestMinutesWithOptions +} + declare module 'date-fns/esm/fp/setDate/index' { import {setDate} from 'date-fns/esm/fp' export default setDate @@ -16736,6 +16842,16 @@ declare module 'date-fns/esm/fp/parseWithOptions/index.js' { export default parseWithOptions } +declare module 'date-fns/esm/fp/roundToNearestMinutes/index.js' { + import {roundToNearestMinutes} from 'date-fns/esm/fp' + export default roundToNearestMinutes +} + +declare module 'date-fns/esm/fp/roundToNearestMinutesWithOptions/index.js' { + import {roundToNearestMinutesWithOptions} from 'date-fns/esm/fp' + export default roundToNearestMinutesWithOptions +} + declare module 'date-fns/esm/fp/setDate/index.js' { import {setDate} from 'date-fns/esm/fp' export default setDate @@ -19530,6 +19646,12 @@ interface dateFns { options?: Options ): Date + roundToNearestMinutes( + date: Date | string | number, + nearestTo?: number, + options?: Options + ): Date + setDate( date: Date | string | number, dayOfMonth: number,