1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +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:
Calixte Denizet 2022-03-19 16:07:38 +01:00
parent 079dea2274
commit f0b549c2a2
3 changed files with 33 additions and 11 deletions

View file

@ -598,6 +598,21 @@ describe("Scripting", function () {
});
});
describe("AFParseDateEx", function () {
it("should parse a date with a format", async () => {
const check = async (date, format, expected) => {
const value = await myeval(
`AFParseDateEx("${date}", "${format}").toISOString()`
);
expect(value).toEqual(new Date(expected).toISOString());
};
await check("05", "dd", "2000/01/05");
await check("12", "mm", "2000/12/01");
await check("2022", "yyyy", "2022/01/01");
});
});
describe("AFExtractNums", function () {
it("should extract numbers", async () => {
let value = await myeval(`AFExtractNums("123 456 789")`);