mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Tidy
This commit is contained in:
parent
6a1caf0904
commit
668c47d5a0
@ -24,44 +24,40 @@ function formatPDFDate(dateString: string): string {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
let date: Date;
|
||||||
let date: Date;
|
|
||||||
|
|
||||||
// Check if it's a PDF date format (starts with "D:")
|
// Check if it's a PDF date format (starts with "D:")
|
||||||
if (dateString.startsWith('D:')) {
|
if (dateString.startsWith('D:')) {
|
||||||
// Parse PDF date format: D:YYYYMMDDHHmmSSOHH'mm'
|
// Parse PDF date format: D:YYYYMMDDHHmmSSOHH'mm'
|
||||||
const dateStr = dateString.substring(2); // Remove "D:"
|
const dateStr = dateString.substring(2); // Remove "D:"
|
||||||
|
|
||||||
// Extract date parts
|
// Extract date parts
|
||||||
const year = parseInt(dateStr.substring(0, 4));
|
const year = parseInt(dateStr.substring(0, 4));
|
||||||
const month = parseInt(dateStr.substring(4, 6));
|
const month = parseInt(dateStr.substring(4, 6));
|
||||||
const day = parseInt(dateStr.substring(6, 8));
|
const day = parseInt(dateStr.substring(6, 8));
|
||||||
const hour = parseInt(dateStr.substring(8, 10)) || 0;
|
const hour = parseInt(dateStr.substring(8, 10)) || 0;
|
||||||
const minute = parseInt(dateStr.substring(10, 12)) || 0;
|
const minute = parseInt(dateStr.substring(10, 12)) || 0;
|
||||||
const second = parseInt(dateStr.substring(12, 14)) || 0;
|
const second = parseInt(dateStr.substring(12, 14)) || 0;
|
||||||
|
|
||||||
// Create date object (month is 0-indexed)
|
// Create date object (month is 0-indexed)
|
||||||
date = new Date(year, month - 1, day, hour, minute, second);
|
date = new Date(year, month - 1, day, hour, minute, second);
|
||||||
} else {
|
} else {
|
||||||
// Try parsing as regular date string
|
// Try parsing as regular date string
|
||||||
date = new Date(dateString);
|
date = new Date(dateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNaN(date.getTime())) {
|
if (isNaN(date.getTime())) {
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
||||||
|
|
||||||
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
|
||||||
} catch {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||||
|
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user