UNPKG

is-iso-date

Version:

A simple utility to check if a string is an ISO-compliant date.

9 lines (6 loc) 356 B
'use strict'; module.exports = isISODate; var isoDateRegExp = new RegExp( /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/ ); function isISODate( str ) { return isoDateRegExp.test( str ); }