@shopify/dates
Advanced tools
Comparing version 0.3.6 to 0.4.0
@@ -8,4 +8,8 @@ # Changelog | ||
<!-- ## [Unreleased] --> | ||
## [0.4.0] - 2020-06-04 | ||
### Added | ||
- Added `isLessThanOneWeekAway` and `isLessThanOneYearAgo` functions [[#1438](https://github.com/Shopify/quilt/pull/1438)] | ||
## [0.3.4] - 2020-03-13 | ||
@@ -12,0 +16,0 @@ |
@@ -10,3 +10,5 @@ export * from './apply-time-zone-offset'; | ||
export * from './is-less-than-one-week-ago'; | ||
export * from './is-less-than-one-week-away'; | ||
export * from './is-less-than-one-year-ago'; | ||
export * from './is-less-than-one-year-away'; | ||
export * from './is-same-day'; | ||
@@ -13,0 +15,0 @@ export * from './is-same-month'; |
@@ -13,3 +13,5 @@ "use strict"; | ||
tslib_1.__exportStar(require("./is-less-than-one-week-ago"), exports); | ||
tslib_1.__exportStar(require("./is-less-than-one-week-away"), exports); | ||
tslib_1.__exportStar(require("./is-less-than-one-year-ago"), exports); | ||
tslib_1.__exportStar(require("./is-less-than-one-year-away"), exports); | ||
tslib_1.__exportStar(require("./is-same-day"), exports); | ||
@@ -16,0 +18,0 @@ tslib_1.__exportStar(require("./is-same-month"), exports); |
{ | ||
"name": "@shopify/dates", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Lightweight date operations library.", |
@@ -154,2 +154,16 @@ # `@shopify/dates` | ||
### `isLessThanOneWeekAway` | ||
Takes in a date object and an optional "now" date object (that defaults to `new Date()`). Returns a boolean indicating whether or not the date is less than one week after the "now" date. | ||
```ts | ||
import {isLessThanOneWeekAway} from '@shopify/dates'; | ||
const moreThanOneWeekAway = new Date(Date.now() + 8 * TimeUnit.Day); | ||
const lessThanOneWeekAway = new Date(Date.now() + 6 * TimeUnit.Day); | ||
isLessThanOneWeekAway(moreThanOneWeekAway); // false | ||
isLessThanOneWeekAway(lessThanOneWeekAway); // true | ||
``` | ||
### `isLessThanOneYearAgo` | ||
@@ -169,2 +183,16 @@ | ||
### `isLessThanOneYearAway` | ||
Takes in a date object and an optional "now" date object (that defaults to `new Date()`). Returns a boolean indicating whether or not the date is less than one year after the "now" date. | ||
```ts | ||
import {isLessThanOneYearAway} from '@shopify/dates'; | ||
const moreThanOneYearAway = new Date(Date.now() + 53 * TimeUnit.Week); | ||
const lessThanOneYearAway = new Date(Date.now() + 51 * TimeUnit.Week); | ||
isLessThanOneYearAway(moreThanOneYearAway); // false | ||
isLessThanOneYearAway(lessThanOneYearAway); // true | ||
``` | ||
### `isSameDay` | ||
@@ -171,0 +199,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56679
93
805
337