项目作者: bernardini687

项目描述 :
shape a date from minimal input
高级语言: JavaScript
项目地址: git://github.com/bernardini687/shape-date.git
创建时间: 2020-03-21T10:47:11Z
项目社区:https://github.com/bernardini687/shape-date

开源协议:MIT License

下载


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

  1. const shapeDate = require('shape-date')
  2. /*
  3. shapeDate([value, [separator='-']]) => Date
  4. [value] (Number) :: just the day value
  5. [value] (String) :: DD[-MM[-YYYY]]
  6. [separator='-'] (String) :: one of . / _ ,
  7. */
  8. // imagine today is the 5th of November 2020:
  9. shapeDate() // 2020-11-05
  10. shapeDate(3) // 2020-11-03
  11. shapeDate('4-7') // 2020-07-04
  12. shapeDate('7.01', '.') // 2020-01-07
  13. shapeDate('12-11-1990') // 1990-11-12