expand-year
Version:
Expand a short year to a full year (15 -> 2015)
14 lines (10 loc) • 322 B
JavaScript
var zeroFill = require('zero-fill')
var parseIntStrict = require('parse-int')
var pad = zeroFill(2)
module.exports = function expandYear (year, now) {
now = now || new Date()
var base = now.getFullYear().toString().substr(0, 2)
year = parseIntStrict(year)
return parseIntStrict(base + pad(year))
}