Skip to content

Commit 9d64458

Browse files
michaeljgrimmclaude
andcommitted
Fix timezone-dependent zip date in deterministic export
Build the fixed zip date from local-time components instead of a UTC instant. fflate encodes the DOS date from local getFullYear/etc, so the UTC midnight value rolled back to 1979 west of UTC (below fflate's 1980 floor, throwing) and produced timezone-dependent output bytes elsewhere. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent de49be1 commit 9d64458

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

dist/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export class OPFPptxError extends Error {
3737
}
3838

3939
const FIXED_TIMESTAMP = "1980-01-01T00:00:00Z";
40-
const FIXED_ZIP_DATE = new Date(FIXED_TIMESTAMP);
40+
// fflate derives the DOS zip date from local-time fields, so build this from
41+
// local components: a UTC instant rolls back to 1979 west of UTC (below
42+
// fflate's 1980 floor) and would otherwise yield timezone-dependent bytes.
43+
const FIXED_ZIP_DATE = new Date(1980, 0, 1, 0, 0, 0);
4144
const DEFAULT_SEED = 0x4f504658;
4245
const CANONICAL_SCHEMA = "https://openpresentation.org/schema/opf/v1";
4346
const EMUS_PER_INCH = 914400;

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export class OPFPptxError extends Error {
3737
}
3838

3939
const FIXED_TIMESTAMP = "1980-01-01T00:00:00Z";
40-
const FIXED_ZIP_DATE = new Date(FIXED_TIMESTAMP);
40+
// fflate derives the DOS zip date from local-time fields, so build this from
41+
// local components: a UTC instant rolls back to 1979 west of UTC (below
42+
// fflate's 1980 floor) and would otherwise yield timezone-dependent bytes.
43+
const FIXED_ZIP_DATE = new Date(1980, 0, 1, 0, 0, 0);
4144
const DEFAULT_SEED = 0x4f504658;
4245
const CANONICAL_SCHEMA = "https://openpresentation.org/schema/opf/v1";
4346
const EMUS_PER_INCH = 914400;

0 commit comments

Comments
 (0)