rittenhop-dev/versions/5.94.2/node_modules/isostring/index.js
2024-09-23 19:40:12 -04:00

22 lines
540 B
JavaScript

module.exports = isDate;
/**
* Matching format per: http://www.w3.org/TR/NOTE-datetime
*/
var isoformat = '^\\d{4}-\\d{2}-\\d{2}' + // Match YYYY-MM-DD
'((T\\d{2}:\\d{2}(:\\d{2})?)' + // Match THH:mm:ss
'(\\.\\d{1,6})?' + // Match .sssss
'(Z|(\\+|-)\\d{2}:\\d{2})?)?$'; // Time zone (Z or +hh:mm)
var matcher = new RegExp(isoformat);
function isDate (val) {
return typeof val === 'string' &&
matcher.test(val) &&
!isNaN(Date.parse(val));
}