parse-year

1.0.0 • Public • Published

parse-year Build Status

Parse a year into its full number value

Install

$ npm install --save parse-year

Usage

var parseYear = require('parse-year');
 
parseYear('2015') // 2015
parseYear('15', true) // 2015

API

parseYear(year, [expand], [now]) -> number / undefined

Parses the year, returning undefined if the input was invalid.

year

Required
Type: string / number

The year input to parse.

expand

Type: boolean
Default: false

If true, expand the year from a 1 or 2 digit number into a full year number, e.g. '15' to 2015.

now

Type: date
Default: new Date()

The date from which to calculate the full year. Only used when expand is true.

License

MIT © Ben Drucker

Readme

Keywords

Package Sidebar

Install

npm i parse-year

Weekly Downloads

21,896

Version

1.0.0

License

MIT

Last publish

Collaborators

  • bendrucker