0.2.2 • Published 3 years ago

shape-date v0.2.2

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago

GitHub file size in bytes GitHub repo size GitHub tag (latest by date) GitHub Libraries.io dependency status for latest release npm

shape-date

shape a date from minimal input

this module is designed to give you back a Date even from a single day value, defaulting the rest to the current date.

example

const shapeDate = require('shape-date')

/*
  shapeDate([value, [separator='-']]) => Date

    [value] (Number)         :: just the day value
    [value] (String)         :: DD[-MM[-YYYY]]
    [separator='-'] (String) :: one of . / _ ,
*/

// imagine today is the 5th of November 2020:

shapeDate()             // 2020-11-05
shapeDate(3)            // 2020-11-03
shapeDate('4-7')        // 2020-07-04
shapeDate('7.01', '.')  // 2020-01-07
shapeDate('12-11-1990') // 1990-11-12