| | |
| | | * @api public |
| | | */ |
| | | |
| | | module.exports = function(val, options) { |
| | | module.exports = function (val, options) { |
| | | options = options || {}; |
| | | var type = typeof val; |
| | | if (type === 'string' && val.length > 0) { |
| | | return parse(val); |
| | | } else if (type === 'number' && isNaN(val) === false) { |
| | | } else if (type === 'number' && isFinite(val)) { |
| | | return options.long ? fmtLong(val) : fmtShort(val); |
| | | } |
| | | throw new Error( |
| | |
| | | if (str.length > 100) { |
| | | return; |
| | | } |
| | | var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( |
| | | var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( |
| | | str |
| | | ); |
| | | if (!match) { |