2 Object.defineProperty(exports, "__esModule", { value: true });
3 const DT_SEPARATOR = /t|\s/i;
4 const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
5 const TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i;
6 const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7 function validTimestamp(str, allowDate) {
8 // http://tools.ietf.org/html/rfc3339#section-5.6
9 const dt = str.split(DT_SEPARATOR);
10 return ((dt.length === 2 && validDate(dt[0]) && validTime(dt[1])) ||
11 (allowDate && dt.length === 1 && validDate(dt[0])));
13 exports.default = validTimestamp;
14 function validDate(str) {
15 const matches = DATE.exec(str);
18 const y = +matches[1];
19 const m = +matches[2];
20 const d = +matches[3];
25 // leap year: https://tools.ietf.org/html/rfc3339#appendix-C
26 (m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0))));
28 function validTime(str) {
29 const matches = TIME.exec(str);
32 const hr = +matches[1];
33 const min = +matches[2];
34 const sec = +matches[3];
35 const tzH = +(matches[4] || 0);
36 const tzM = +(matches[5] || 0);
37 return ((hr <= 23 && min <= 59 && sec <= 59) ||
39 (hr - tzH === 23 && min - tzM === 59 && sec === 60));
41 validTimestamp.code = 'require("ajv/dist/runtime/timestamp").default';
42 //# sourceMappingURL=timestamp.js.map