JSPM

parse-year

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24008
  • Score
    100M100P100Q136345F
  • License MIT

Parse a year into its full number value

Package Exports

  • parse-year

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-year) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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