Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ranged-date
Advanced tools
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 time range from the current date.
Milliseconds, seconds, or microseconds may be excluded as possibilities for type matching.
Useful for:
Warning:
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 sec = ~~(Date.now() / 1000) // Test unixtime
const ms = sec * 1000 // Test millisecond time
const us = ms * 1000 // Test microsecond time
const past = sec - 31536000 // Unixtime one year prior
const future = sec + 31536000 // Unixtime one year after
console.log(rangedDate(sec)) // converted time in ms
console.log(rangedDate(ms)) // time in ms
console.log(rangedDate(us)) // converted time in ms
console.log(rangedDate(String(sec))) // converted time in ms
console.log(rangedDate(past)) // false
console.log(rangedDate(past, 2)) // converted time in ms
console.log(rangedDate(future)) // false
console.log(rangedDate(future, null, 2)) // converted time in ms
console.log(rangedDate(sec, 0.5, 0.5, { s: true })) // false
console.log(rangedDate(ms, 0.5, 0.5, { ms: true })) // false
console.log(rangedDate(us, 0.5, 0.5, { us: true })) // false
console.log(
rangedDate(new Date(ms), 0.5, 0.5, { ms: true })
) // converted time in ms
number
| boolean
Param | Type | Attributes | Default | Description |
---|---|---|---|---|
data | Date | number | string | Data to attempt to recognize as valid date. | ||
back | number | <optional> | 0.5 | Years before current date as lower bound. |
fwd | number | <optional> | 0.5 | Years after current date as upper bound. |
exclude | rangedDate~exclude | <optional> | {} | Specifies type exclusions, if any. |
Returns: number
| boolean
- Converted ms or false if outside range.
rangedDate~exclude
Settings for exclusion of milliseconds, seconds, or microseconds as possibilities for type matching.
Properties
Name | Type | Attributes | Description |
---|---|---|---|
ms | boolean | <optional> | Exclude milliseconds. |
s | boolean | <optional> | Exclude seconds. |
us | boolean | <optional> | Exclude microseconds. |
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.
The npm package ranged-date receives a total of 4 weekly downloads. As such, ranged-date popularity was classified as not popular.
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.