@pdf-viewer/react
Version:
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
26 lines (25 loc) • 699 B
JavaScript
const p = new RegExp(
"^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"
), t = (s, e, o, c) => {
const n = parseInt(s, 10);
return n >= e && n <= o ? n : c;
}, f = (s) => {
const e = p.exec(s);
if (!e)
return null;
const o = parseInt(e[1], 10), c = t(e[2], 1, 12, 1) - 1, n = t(e[3], 1, 31, 1);
let r = t(e[4], 0, 23, 0), a = t(e[5], 0, 59, 0);
const i = t(e[6], 0, 59, 0), l = e[7] || "Z", d = t(e[8], 0, 23, 0), u = t(e[9], 0, 59, 0);
switch (l) {
case "-":
r += d, a += u;
break;
case "+":
r -= d, a -= u;
break;
}
return new Date(Date.UTC(o, c, n, r, a, i));
};
export {
f as convertPDFDate
};