mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Merge pull request #21258 from Snuffleupagus/mv-getModificationDate
Move the `getModificationDate` helper function into `src/core/core_utils.js`
This commit is contained in:
commit
6bbcb46db8
@ -26,7 +26,6 @@ import {
|
||||
BBOX_INIT,
|
||||
F32_BBOX_INIT,
|
||||
FeatureTest,
|
||||
getModificationDate,
|
||||
info,
|
||||
isArrayEqual,
|
||||
LINE_DESCENT_FACTOR,
|
||||
@ -43,6 +42,7 @@ import {
|
||||
collectActions,
|
||||
escapeString,
|
||||
getInheritableProperty,
|
||||
getModificationDate,
|
||||
getParentToUpdate,
|
||||
getRotationMatrix,
|
||||
IDENTITY_MATRIX,
|
||||
|
||||
@ -716,6 +716,22 @@ function stringToUTF16String(str, bigEndian = false) {
|
||||
return buf.join("");
|
||||
}
|
||||
|
||||
function getModificationDate(date = new Date()) {
|
||||
if (!(date instanceof Date)) {
|
||||
date = new Date(date);
|
||||
}
|
||||
const buffer = [
|
||||
date.getUTCFullYear().toString(),
|
||||
(date.getUTCMonth() + 1).toString().padStart(2, "0"),
|
||||
date.getUTCDate().toString().padStart(2, "0"),
|
||||
date.getUTCHours().toString().padStart(2, "0"),
|
||||
date.getUTCMinutes().toString().padStart(2, "0"),
|
||||
date.getUTCSeconds().toString().padStart(2, "0"),
|
||||
];
|
||||
|
||||
return buffer.join("");
|
||||
}
|
||||
|
||||
function getRotationMatrix(rotation, width, height) {
|
||||
switch (rotation) {
|
||||
case 90:
|
||||
@ -753,6 +769,7 @@ export {
|
||||
fetchBinaryData,
|
||||
getInheritableProperty,
|
||||
getLookupTableFactory,
|
||||
getModificationDate,
|
||||
getNewAnnotationsMap,
|
||||
getParentToUpdate,
|
||||
getRotationMatrix,
|
||||
|
||||
@ -23,17 +23,14 @@
|
||||
import {
|
||||
deepCompare,
|
||||
getInheritableProperty,
|
||||
getModificationDate,
|
||||
getNewAnnotationsMap,
|
||||
stringToAsciiOrUTF16BE,
|
||||
} from "../core_utils.js";
|
||||
import { Dict, isName, Name, Ref, RefSet, RefSetCache } from "../primitives.js";
|
||||
import {
|
||||
getModificationDate,
|
||||
stringToBytes,
|
||||
stringToPDFString,
|
||||
} from "../../shared/util.js";
|
||||
import { incrementalUpdate, writeValue } from "../writer.js";
|
||||
import { NameTree, NumberTree } from "../name_number_tree.js";
|
||||
import { stringToBytes, stringToPDFString } from "../../shared/util.js";
|
||||
import { AnnotationFactory } from "../annotation.js";
|
||||
import { BaseStream } from "../base_stream.js";
|
||||
import { StringStream } from "../stream.js";
|
||||
|
||||
@ -69,6 +69,7 @@ const AnnotationMode = {
|
||||
ENABLE_STORAGE: 3,
|
||||
};
|
||||
|
||||
const AnnotationPrefix = "pdfjs_internal_id_";
|
||||
const AnnotationEditorPrefix = "pdfjs_internal_editor_";
|
||||
|
||||
const AnnotationEditorType = {
|
||||
@ -1122,22 +1123,6 @@ function isArrayEqual(arr1, arr2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getModificationDate(date = new Date()) {
|
||||
if (!(date instanceof Date)) {
|
||||
date = new Date(date);
|
||||
}
|
||||
const buffer = [
|
||||
date.getUTCFullYear().toString(),
|
||||
(date.getUTCMonth() + 1).toString().padStart(2, "0"),
|
||||
date.getUTCDate().toString().padStart(2, "0"),
|
||||
date.getUTCHours().toString().padStart(2, "0"),
|
||||
date.getUTCMinutes().toString().padStart(2, "0"),
|
||||
date.getUTCSeconds().toString().padStart(2, "0"),
|
||||
];
|
||||
|
||||
return buffer.join("");
|
||||
}
|
||||
|
||||
let NormalizeRegex = null;
|
||||
let NormalizationMap = null;
|
||||
function normalizeUnicode(str) {
|
||||
@ -1169,8 +1154,6 @@ function getUuid() {
|
||||
return bytesToString(buf);
|
||||
}
|
||||
|
||||
const AnnotationPrefix = "pdfjs_internal_id_";
|
||||
|
||||
function _isValidExplicitDest(validRef, validName, dest) {
|
||||
if (!Array.isArray(dest) || dest.length < 2) {
|
||||
return false;
|
||||
@ -1273,7 +1256,6 @@ export {
|
||||
FeatureTest,
|
||||
FONT_IDENTITY_MATRIX,
|
||||
FormatError,
|
||||
getModificationDate,
|
||||
getUuid,
|
||||
getVerbosityLevel,
|
||||
ImageKind,
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
escapePDFName,
|
||||
escapeString,
|
||||
getInheritableProperty,
|
||||
getModificationDate,
|
||||
getSizeInBytes,
|
||||
isAscii,
|
||||
isWhiteSpace,
|
||||
@ -557,6 +558,14 @@ describe("core_utils", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getModificationDate", function () {
|
||||
it("should get a correctly formatted date", function () {
|
||||
const date = new Date(Date.UTC(3141, 5, 9, 2, 6, 53));
|
||||
expect(getModificationDate(date)).toEqual("31410609020653");
|
||||
expect(getModificationDate(date.toString())).toEqual("31410609020653");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSizeInBytes", function () {
|
||||
it("should get the size in bytes to use to represent a positive integer", function () {
|
||||
expect(getSizeInBytes(0)).toEqual(0);
|
||||
|
||||
@ -17,7 +17,6 @@ import {
|
||||
BaseException,
|
||||
bytesToString,
|
||||
createValidAbsoluteUrl,
|
||||
getModificationDate,
|
||||
getUuid,
|
||||
stringToBytes,
|
||||
stringToPDFString,
|
||||
@ -210,14 +209,6 @@ describe("util", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getModificationDate", function () {
|
||||
it("should get a correctly formatted date", function () {
|
||||
const date = new Date(Date.UTC(3141, 5, 9, 2, 6, 53));
|
||||
expect(getModificationDate(date)).toEqual("31410609020653");
|
||||
expect(getModificationDate(date.toString())).toEqual("31410609020653");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getUuid", function () {
|
||||
it("should get uuid string", function () {
|
||||
const uuid = getUuid();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user