Merge pull request #985 from cms/fix-min-max-date

[ENHANCEMENT] Simplify min and max date functions
This commit is contained in:
Angelos Chalaris
2019-06-13 08:04:52 +03:00
committed by GitHub
3 changed files with 5 additions and 5 deletions

View File

@ -2,10 +2,10 @@
Returns the maximum of the given dates.
Use `Math.max.apply()` to find the maximum date value, `new Date()` to convert it to a `Date` object.
Use the ES6 spread syntax with `Math.max` to find the maximum date value, `new Date()` to convert it to a `Date` object.
```js
const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
const maxDate = dates => new Date(Math.max(...dates));
```
```js

View File

@ -2,10 +2,10 @@
Returns the minimum of the given dates.
Use `Math.min.apply()` to find the minimum date value, `new Date()` to convert it to a `Date` object.
Use the ES6 spread syntax to find the minimum date value, `new Date()` to convert it to a `Date` object.
```js
const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
const minDate = dates => new Date(Math.min(...dates));
```
```js

View File

@ -4,7 +4,7 @@ const {minDate} = require('./_30s.js');
test('minDate is a Function', () => {
expect(minDate).toBeInstanceOf(Function);
});
test('minDate produces the maximum date', () => {
test('minDate produces the minimum date', () => {
const array = [
new Date(2017, 4, 13),
new Date(2018, 2, 12),