mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
[JS] - Parse a date in using the given format first and then try the default date parser
- it aims to fix #14672.
This commit is contained in:
parent
079dea2274
commit
f0b549c2a2
3 changed files with 33 additions and 11 deletions
|
@ -373,6 +373,10 @@ class Util extends PDFObject {
|
|||
}
|
||||
|
||||
scand(cFormat, cDate) {
|
||||
if (typeof cDate !== "string") {
|
||||
return new Date(cDate);
|
||||
}
|
||||
|
||||
if (cDate === "") {
|
||||
return new Date();
|
||||
}
|
||||
|
@ -536,15 +540,15 @@ class Util extends PDFObject {
|
|||
|
||||
const [re, actions] = this._scandCache.get(cFormat);
|
||||
|
||||
const matches = new RegExp(re, "g").exec(cDate);
|
||||
const matches = new RegExp(`^${re}$`, "g").exec(cDate);
|
||||
if (!matches || matches.length !== actions.length + 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = {
|
||||
year: 0,
|
||||
year: 2000,
|
||||
month: 0,
|
||||
day: 0,
|
||||
day: 1,
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
seconds: 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue