Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add isSameOrAfter and isSameOrBefore
- Loading branch information
Showing
8 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Is Same or Before | ||
version: 2.10.7 | ||
signature: | | ||
moment().isSameOrBefore(Moment|String|Number|Date|Array); | ||
moment().isSameOrBefore(Moment|String|Number|Date|Array, String); | ||
--- | ||
|
||
Check if a moment is before or the same as another moment. | ||
|
||
```javascript | ||
moment('2010-10-20').isSameOrBefore('2010-10-21'); // true | ||
moment('2010-10-20').isSameOrBefore('2010-10-20'); // true | ||
moment('2010-10-20').isSameOrBefore('2010-10-19'); // false | ||
``` | ||
|
||
If you want to limit the granularity to a unit other than milliseconds, pass the units as the second parameter. | ||
|
||
As the second parameter determines the precision, and not just a single value to check, using day will check for year, month and day. | ||
|
||
```javascript | ||
moment('2010-10-20').isSameOrBefore('2009-12-31', 'year'); // false | ||
moment('2010-10-20').isSameOrBefore('2010-12-31', 'year'); // true | ||
moment('2010-10-20').isSameOrBefore('2011-01-01', 'year'); // true | ||
``` | ||
|
||
Like `moment#isAfter` and `moment#isSame`, any of the units of time that are supported for `moment#startOf` are supported for `moment#isSameOrBefore`: | ||
|
||
``` | ||
year month week day hour minute second | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: Is Same Or After | ||
version: 2.10.7 | ||
signature: | | ||
moment().isSameOrAfter(Moment|String|Number|Date|Array); | ||
moment().isSameOrAfter(Moment|String|Number|Date|Array, String); | ||
--- | ||
|
||
|
||
Check if a moment is after or the same as another moment. | ||
|
||
```javascript | ||
moment('2010-10-20').isSameOrAfter('2010-10-19'); // true | ||
moment('2010-10-20').isSameOrAfter('2010-10-20'); // true | ||
moment('2010-10-20').isSameOrAfter('2010-10-21'); // false | ||
``` | ||
|
||
If you want to limit the granularity to a unit other than milliseconds, pass the units as the second parameter. | ||
|
||
As the second parameter determines the precision, and not just a single value to check, using day will check for year, month and day. | ||
|
||
```javascript | ||
moment('2010-10-20').isSameOrAfter('2011-12-31', 'year'); // false | ||
moment('2010-10-20').isSameOrAfter('2010-01-01', 'year'); // true | ||
moment('2010-10-20').isSameOrAfter('2009-12-31', 'year'); // true | ||
``` | ||
|
||
Like `moment#isSame` and `moment#isBefore`, any of the units of time that are supported for `moment#startOf` are supported for `moment#isSameOrAfter`: | ||
|
||
``` | ||
year month week day hour minute second | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.