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

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.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-81.82%
Maintainers
1
Weekly downloads
 
Created
Source

ranged-date

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.

Getting Started

Prerequisites

Node.JS version 6.0.0 or above.

Installing

npm i ranged-date

Testing

The following command will test the package for errors.

npm test

Deployment

const rangedDate = require('ranged-date')

Usage

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

Documentation

rangedDate ⇒ number | boolean

Returns: number | boolean - Converted ms or false if outside range.

ParamTypeAttributesDefaultDescription
dataDate | number | stringData to attempt to match.
lownumber<optional>0.5Lower bound, in years.
upnumber<optional>0.5Upper bound, in years.

Please refer to the docs for more in-depth documentation.

Versioning

Versioning using SemVer. For available versions, see the tags on this repository.

Authors

  • Justin Collier - jpcx

License

This project is licensed under the ISC License - see the LICENSE.md file for details

Keywords

FAQs

Package last updated on 05 Apr 2018

Did you know?

Socket

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.

Install

Related posts

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