New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/dates

Package Overview
Dependencies
Maintainers
13
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/dates - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

package.json
{
"name": "@shopify/dates",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",

@@ -30,3 +30,3 @@ "description": "Lightweight date operations library.",

"devDependencies": {
"@shopify/jest-dom-mocks": "^2.7.7"
"@shopify/jest-dom-mocks": "^2.8.0"
},

@@ -33,0 +33,0 @@ "files": [

@@ -81,2 +81,72 @@ # `@shopify/dates`

### `isLessThanOneDayAgo`
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 day before the "now" date.
```ts
import {isLessThanOneDayAgo} from '@shopify/dates';
const moreThanOneDayAgo = new Date('2018-01-01Z00:00');
const lessThanOneDayAgo = new Date(Date.now() - 23 * TimeUnit.Hour);
isLessThanOneDayAgo(moreThanOneDayAgo); // false
isLessThanOneDayAgo(lessThanOneDayAgo); // true
```
### `isLessThanOneHourAgo`
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 hour before the "now" date.
```ts
import {isLessThanOneHourAgo} from '@shopify/dates';
const moreThanOneHourAgo = new Date('2018-01-01Z00:00');
const lessThanOneHourAgo = new Date(Date.now() - 59 * TimeUnit.Minute);
isLessThanOneHourAgo(moreThanOneHourAgo); // false
isLessThanOneHourAgo(lessThanOneHourAgo); // true
```
### `isLessThanOneMinuteAgo`
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 minute before the "now" date.
```ts
import {isLessThanOneMinuteAgo} from '@shopify/dates';
const moreThanOneMinuteAgo = new Date('2018-01-01Z00:00');
const lessThanOneMinuteAgo = new Date(Date.now() - 59 * TimeUnit.Second);
isLessThanOneMinuteAgo(moreThanOneMinuteAgo); // false
isLessThanOneMinuteAgo(lessThanOneMinuteAgo); // true
```
### `isLessThanOneWeekAgo`
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 before the "now" date.
```ts
import {isLessThanOneWeekAgo} from '@shopify/dates';
const moreThanOneWeekAgo = new Date('2018-01-01Z00:00');
const lessThanOneWeekAgo = new Date(Date.now() - 6 * TimeUnit.Day);
isLessThanOneWeekAgo(moreThanOneWeekAgo); // false
isLessThanOneWeekAgo(lessThanOneWeekAgo); // true
```
### `isLessThanOneYearAgo`
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 before the "now" date.
```ts
import {isLessThanOneYearAgo} from '@shopify/dates';
const moreThanOneYearAgo = new Date('2018-01-01Z00:00');
const lessThanOneYearAgo = new Date(Date.now() - 51 * TimeUnit.Week);
isLessThanOneYearAgo(moreThanOneYearAgo); // false
isLessThanOneYearAgo(lessThanOneYearAgo); // true
```
### `isSameDay`

@@ -83,0 +153,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc