Socket
Socket
Sign inDemoInstall

date-detect-range

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-detect-range

Prints a human readable version of an array of dates


Version published
Maintainers
1
Created
Source

Date detect range

Prints a human readable version of an array of dates.

Rules

  • two dates print with an "and" inbetween
    • ["2000-05-15", "2000-05-16"] → 2000-05-15 and 2000-05-16
    • ["2000-05-15", "2000-05-17"] → 2000-05-15 and 2000-05-17
  • more than two dates in a row print with a "to" inbetween
    • ["2000-05-15", "2000-05-16", "2000-05-17"] → 2000-05-15 to 2000-05-17
    • ["2000-05-15", "2000-05-16", "2000-05-17", "2000-05-20"] → 2000-05-15 to 2000-05-17, 2000-05-20
  • if there are not more than two dates in a row output is the output (ordered)
    • ["2000-05-15", "2000-05-16", "2000-05-18", "2000-05-20"] → 2000-05-15, 2000-05-16, 2000-05-18, 2000-05-20

Usage


import  DetectRange from 'date-detect-range'
import 'moment/locale/de'; // localise to german

let dates = ["2000-05-15", "2000-05-16", "2000-05-17"];

let range = new DetectRange(dates).format({
    and: " und ",
    to: " bis ",
    format: "dd D. MMMM",
});

console.log(range); // → Sa 15. Mai bis Mo 17. Mai,  

Keywords

FAQs

Package last updated on 23 Jul 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