Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
ranged-date
Advanced tools
Converts a given input to the number of milliseconds since the Unix epoch, provided that it can be parsed and recognized as seconds, milliseconds, or microseconds within a specified range in years.
Converts a given input to the number of milliseconds since the Unix epoch, provided that it can be parsed and recognized as seconds, milliseconds, or microseconds within a specified range in years.
Node.JS version 6.0.0 or above.
npm i ranged-date
The following command will test the package for errors.
npm test
const rangedDate = require('ranged-date')
const time = ~~(Date.now() / 1000) // Test unixtime in seconds
const past = time - 31536000 // One year prior
const future = time + 31536000 // One year after
console.log(rangedDate(time)) // converted ms
console.log(rangedDate(time * 1000)) // converted ms
console.log(rangedDate(time * 1000 * 1000)) // converted ms
console.log(rangedDate(String(time))) // converted ms
console.log(rangedDate(past)) // false
console.log(rangedDate(past, 2)) // converted ms
console.log(rangedDate(future)) // false
console.log(rangedDate(future, null, 2)) // converted ms
number
| boolean
Returns: number
| boolean
- Converted ms or false if outside range.
Param | Type | Attributes | Default | Description |
---|---|---|---|---|
data | Date | number | string | Data to attempt to match. | ||
low | number | <optional> | 0.5 | Lower bound, in years. |
up | number | <optional> | 0.5 | Upper bound, in years. |
Please refer to the docs for more in-depth documentation.
Versioning using SemVer. For available versions, see the tags on this repository.
This project is licensed under the ISC License - see the LICENSE.md file for details
FAQs
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.
We found that ranged-date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.