Add minDate, maxDate
This commit is contained in:
19
snippets/maxDate.md
Normal file
19
snippets/maxDate.md
Normal file
@ -0,0 +1,19 @@
|
||||
### maxDate
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
|
||||
```
|
||||
|
||||
```js
|
||||
const array = [
|
||||
new Date(2017, 4, 13),
|
||||
new Date(2018, 2, 12),
|
||||
new Date(2016, 0, 10),
|
||||
new Date(2016, 0, 9),
|
||||
];
|
||||
maxDate(array); // 2018-03-11T22:00:00.000Z
|
||||
```
|
||||
19
snippets/minDate.md
Normal file
19
snippets/minDate.md
Normal file
@ -0,0 +1,19 @@
|
||||
### minDate
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
|
||||
```
|
||||
|
||||
```js
|
||||
const array = [
|
||||
new Date(2017, 4, 13),
|
||||
new Date(2018, 2, 12),
|
||||
new Date(2016, 0, 10),
|
||||
new Date(2016, 0, 9),
|
||||
];
|
||||
minDate(array); // 2016-01-08T22:00:00.000Z
|
||||
```
|
||||
@ -173,11 +173,13 @@ mask:string,utility,regexp,intermediate
|
||||
matches:object,type,intermediate
|
||||
matchesWith:object,type,function,intermediate
|
||||
maxBy:math,array,function,beginner
|
||||
maxDate:date,math,beginner
|
||||
maxN:array,math,beginner
|
||||
median:math,array,intermediate
|
||||
memoize:function,advanced
|
||||
merge:object,array,intermediate
|
||||
minBy:math,array,function,beginner
|
||||
minDate:date,math,beginner
|
||||
minN:array,math,beginner
|
||||
mostPerformant:utility,function
|
||||
negate:function,beginner
|
||||
|
||||
Reference in New Issue
Block a user