Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ranged-date

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ranged-date - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

92

docs/API.md
## Module
### <a name="rangedDate"></a> rangedDate ⇒ <code>number</code> \| <code>boolean</code>
Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified time range from the current date.
Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified range from the current date.

@@ -11,3 +11,3 @@ | Param | Type | Attributes | Default | Description |

| fwd | <code>number</code> | <code>&#60;optional&#62;</code> | <code>0.5</code> | Years after current date as upper bound. |
| exclude | <code><a href="#rangedDate~exclude">rangedDate~exclude</a></code> | <code>&#60;optional&#62;</code> | <code>{}</code> | Specifies type exclusions, if any. |
| exclude | <code><a href="#rangedDate~exclude">rangedDate~exclude</a></code> | <code>&#60;optional&#62;</code> | <code>{}</code> | Specifies range exclusions, if any. |

@@ -18,111 +18,69 @@ > Source: [index.js](https://github.com/jpcx/ranged-date/blob/master/index.js), [line 109](https://github.com/jpcx/ranged-date/blob/master/index.js#L109)

**Example**
**Examples**
```js
// returns current time in ms
rangedDate(new Date())
```
**Example**
```js
// returns current time in ms
rangedDate(String(new Date()))
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now())
```
**Example**
```js
// returns current time in ms
rangedDate(String(Date.now()))
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now() / 1000)
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now() * 1000)
```
**Example**
```js
// returns false
rangedDate(Date.now() - 10000, 0.0000001, 0.0000001)
```
**Example**
```js
// returns current time in ms - 10000
rangedDate(Date.now() - 10000, 0.000001, 0.000001)
```
**Example**
```js
// returns false
rangedDate(10)
```
**Example**
```js
// returns 10
const yrSince1970 = new Date().getUTCFullYear() - 1970
rangedDate(10, yrSince1970 + 2)
```
**Example**
```js
// returns false
rangedDate(Date.now() + 100000000000)
```
**Example**
```js
// returns current time in ms + 100000000000
rangedDate(Date.now() + 100000000000, 0.1, 5)
```
**Example**
```js
// returns -946771200000
const yrSince1940 = new Date().getUTCFullYear() - 1940
rangedDate(-946771200, yrSince1940 + 2, -(yrSince1940 - 2))
```
**Example**
```js
// returns false
rangedDate(Date.now(), 0.5, 0.5, { ms: true })
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now(), 0.5, 0.5, { s: true, us: true })
```
**Example**
```js
// returns false
rangedDate(Date.now() / 1000, 0.5, 0.5, { s: true })
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now() / 1000, 0.5, 0.5, { ms: true, us: true })
```
**Example**
```js
// returns false
rangedDate(Date.now() * 1000, 0.5, 0.5, { us: true })
```
**Example**
```js
// returns current time in ms
rangedDate(Date.now() * 1000, 0.5, 0.5, { ms: true, s: true })
```
**Example**
```js
// returns false
rangedDate(Date.now(), 0.5, 0.5, { ms: true, s: true, us: true })
```
**Example**
```js
// returns current time in ms
rangedDate(new Date(), 0.5, 0.5, { ms: true, s: true, us: true })
```
**Example**
```js
// returns false

@@ -135,3 +93,3 @@ rangedDate(String(new Date()), 0.5, 0.5, { ms: true, s: true, us: true })

### <a name="rangedDate~exclude"></a> <code>rangedDate~exclude</code>
Settings for exclusion of milliseconds, seconds, or microseconds as possibilities for type matching.
Settings for exclusion of milliseconds, seconds, or microseconds as possibilities for range matching.

@@ -138,0 +96,0 @@ **Properties**

@@ -33,9 +33,7 @@ ## Global Functions

**Example**
**Examples**
```js
// returns true
inRange(0, -1, 1)
```
**Example**
```js
// returns false

@@ -58,9 +56,7 @@ inRange(-1, 0, 1)

**Example**
**Examples**
```js
// returns years until unix epoch
yrDist(0)
```
**Example**
```js
// returns 1

@@ -85,9 +81,7 @@ yrDist(Date.now() + 31536000000)

**Example**
**Examples**
```js
// returns current time in ms
bound(Date.now(), 0.5, 0.5)
```
**Example**
```js
// returns false

@@ -107,3 +101,3 @@ bound(Date.now() * 1000, 0.5, 0.5)

| fwd | <code>number</code> | Years after current date as upper bound. |
| exclude | <code><a href="https://github.com/jpcx/ranged-date/blob/master/docs/API.md#rangedDate~exclude">rangedDate~exclude</a></code> | Specifies type exclusions, if any. |
| exclude | <code><a href="https://github.com/jpcx/ranged-date/blob/master/docs/API.md#rangedDate~exclude">rangedDate~exclude</a></code> | Specifies range exclusions, if any. |

@@ -114,61 +108,39 @@ > Source: [index.js](https://github.com/jpcx/ranged-date/blob/master/index.js), [line 93](https://github.com/jpcx/ranged-date/blob/master/index.js#L93)

**Example**
**Examples**
```js
// returns current time in ms
check(Date.now(), 0.5, 0.5, {})
```
**Example**
```js
// returns current time in ms
check(Date.now() / 1000, 0.5, 0.5, {})
```
**Example**
```js
// returns current time in ms
check(Date.now() * 1000, 0.5, 0.5, {})
```
**Example**
```js
// returns false
check(Date.now() - 100000000000, 0.5, 0.5, {})
```
**Example**
```js
// returns current time in ms - 100000000000
check(Date.now() - 100000000000, 5, 0.5, {})
```
**Example**
```js
// returns false
check(Date.now(), 0.5, 0.5, { ms: true })
```
**Example**
```js
// returns current time in ms
check(Date.now(), 0.5, 0.5, { s: true, us: true })
```
**Example**
```js
// returns false
check(Date.now() / 1000, 0.5, 0.5, { s: true })
```
**Example**
```js
// returns current time in ms
check(Date.now() / 1000, 0.5, 0.5, { ms: true, us: true })
```
**Example**
```js
// returns false
check(Date.now() * 1000, 0.5, 0.5, { us: true })
```
**Example**
```js
// returns current time in ms
check(Date.now() * 1000, 0.5, 0.5, { ms: true, s: true })
```
**Example**
```js
// returns false
check(Date.now(), 0.5, 0.5, { ms: true, s: true , us: true })
```

@@ -54,3 +54,3 @@ 'use strict'

* @param {number} fwd - Years after current date as upper bound.
* @param {rangedDate~exclude} exclude - Specifies exclusions, if any.
* @param {rangedDate~exclude} exclude - Specifies range exclusions, if any.
* @returns {(number|boolean)} Converted ms or false if outside range.

@@ -101,3 +101,3 @@ * @example

/**
* Exclude milliseconds, seconds, or microseconds as possibilities for type matching.
* Exclude milliseconds, seconds, or microseconds as possibilities for range matching.
*

@@ -112,3 +112,3 @@ * @typedef {rangedDate~exclude}

/**
* Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified time range from the current date.
* Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified range from the current date.
*

@@ -119,3 +119,3 @@ * @module rangedDate

* @param {number} [fwd=0.5] - Years after current date as upper bound.
* @param {rangedDate~exclude} [exclude={}] - Specifies type exclusions, if any.
* @param {rangedDate~exclude} [exclude={}] - Specifies range exclusions, if any.
* @returns {(number|boolean)} Converted time in ms or false if outside range.

@@ -122,0 +122,0 @@ * @example

{
"name": "ranged-date",
"version": "1.1.0",
"description": "Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified time range from the current date.",
"version": "1.1.1",
"description": "Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified range from the current date.",
"engines": {

@@ -20,4 +20,4 @@ "node": ">=6.0.0"

"milliseconds",
"seconds",
"microseconds",
"seconds",
"minutes",

@@ -24,0 +24,0 @@ "hours",

@@ -5,5 +5,5 @@ # ranged-date

Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified time range from the current date.
Converts a given string, number, or Date object to the number of milliseconds since the Unix epoch, provided that it can be recognized as millisecond, second, or microsecond time within a specified range from the current date.
Milliseconds, seconds, or microseconds may be excluded as possibilities for type matching.
Milliseconds, seconds, or microseconds may be excluded as possibilities for range matching.

@@ -15,3 +15,3 @@ Useful for:

**Warning:**
* *Although it is unlikely for a given number to fall within the default range (one year), it is advisable to both restrict the range and use type exclusions wherever possible, in order to avoid incorrectly classifying and converting values that were not intended to be timestamps.*
* *Although it is unlikely for a given number to fall within the default range (one year), it is advisable to both restrict the range and use exclusions wherever possible, in order to avoid incorrectly classifying and converting values that were not intended to be timestamps.*

@@ -78,3 +78,3 @@ ## Getting Started

| fwd | <code>number</code> | <code>&#60;optional&#62;</code> | <code>0.5</code> | Years after current date as upper bound. |
| exclude | <code><a href="#rangedDate~exclude">rangedDate~exclude</a></code> | <code>&#60;optional&#62;</code> | <code>{}</code> | Specifies type exclusions, if any. |
| exclude | <code><a href="#rangedDate~exclude">rangedDate~exclude</a></code> | <code>&#60;optional&#62;</code> | <code>{}</code> | Specifies range exclusions, if any. |

@@ -84,3 +84,3 @@ **Returns**: <code>number</code> \| <code>boolean</code> - Converted ms or false if outside range.

### <a name="rangedDate~exclude"></a> <code>rangedDate~exclude</code>
Settings for exclusion of milliseconds, seconds, or microseconds as possibilities for type matching.
Settings for exclusion of milliseconds, seconds, or microseconds as possibilities for range matching.

@@ -87,0 +87,0 @@ **Properties**

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