From cf9e6a17632cf1a5738e2b5fb9bc669d51e7075f Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Sun, 27 Dec 2015 14:33:03 +0200 Subject: [PATCH] Add isSameOrAfter and isSameOrBefore --- docs/moment/05-query/04-is-same-or-before.md | 31 ++++++++++++++++++ docs/moment/05-query/05-is-same-or-after.md | 32 +++++++++++++++++++ .../{04-is-between.md => 06-is-between.md} | 0 ...-time.md => 07-is-daylight-saving-time.md} | 0 ...is-dst-shifted.md => 08-is-dst-shifted.md} | 0 ...{05-is-leap-year.md => 09-is-leap-year.md} | 0 .../{08-is-a-moment.md => 10-is-a-moment.md} | 0 .../{09-is-a-date.md => 11-is-a-date.md} | 0 8 files changed, 63 insertions(+) create mode 100644 docs/moment/05-query/04-is-same-or-before.md create mode 100644 docs/moment/05-query/05-is-same-or-after.md rename docs/moment/05-query/{04-is-between.md => 06-is-between.md} (100%) rename docs/moment/05-query/{06-is-daylight-saving-time.md => 07-is-daylight-saving-time.md} (100%) rename docs/moment/05-query/{07-is-dst-shifted.md => 08-is-dst-shifted.md} (100%) rename docs/moment/05-query/{05-is-leap-year.md => 09-is-leap-year.md} (100%) rename docs/moment/05-query/{08-is-a-moment.md => 10-is-a-moment.md} (100%) rename docs/moment/05-query/{09-is-a-date.md => 11-is-a-date.md} (100%) diff --git a/docs/moment/05-query/04-is-same-or-before.md b/docs/moment/05-query/04-is-same-or-before.md new file mode 100644 index 000000000..686f09acf --- /dev/null +++ b/docs/moment/05-query/04-is-same-or-before.md @@ -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 +``` diff --git a/docs/moment/05-query/05-is-same-or-after.md b/docs/moment/05-query/05-is-same-or-after.md new file mode 100644 index 000000000..8229600eb --- /dev/null +++ b/docs/moment/05-query/05-is-same-or-after.md @@ -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 +``` diff --git a/docs/moment/05-query/04-is-between.md b/docs/moment/05-query/06-is-between.md similarity index 100% rename from docs/moment/05-query/04-is-between.md rename to docs/moment/05-query/06-is-between.md diff --git a/docs/moment/05-query/06-is-daylight-saving-time.md b/docs/moment/05-query/07-is-daylight-saving-time.md similarity index 100% rename from docs/moment/05-query/06-is-daylight-saving-time.md rename to docs/moment/05-query/07-is-daylight-saving-time.md diff --git a/docs/moment/05-query/07-is-dst-shifted.md b/docs/moment/05-query/08-is-dst-shifted.md similarity index 100% rename from docs/moment/05-query/07-is-dst-shifted.md rename to docs/moment/05-query/08-is-dst-shifted.md diff --git a/docs/moment/05-query/05-is-leap-year.md b/docs/moment/05-query/09-is-leap-year.md similarity index 100% rename from docs/moment/05-query/05-is-leap-year.md rename to docs/moment/05-query/09-is-leap-year.md diff --git a/docs/moment/05-query/08-is-a-moment.md b/docs/moment/05-query/10-is-a-moment.md similarity index 100% rename from docs/moment/05-query/08-is-a-moment.md rename to docs/moment/05-query/10-is-a-moment.md diff --git a/docs/moment/05-query/09-is-a-date.md b/docs/moment/05-query/11-is-a-date.md similarity index 100% rename from docs/moment/05-query/09-is-a-date.md rename to docs/moment/05-query/11-is-a-date.md