parse-year

Parse a year into its full number value

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
parse-year
011.0.08 years ago8 years agoMinified + gzip package size for parse-year in KB

Readme

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