fix date timezone
This commit is contained in:
+27
-11
@@ -1485,13 +1485,29 @@ downloadBtn.addEventListener('click', () => {
|
||||
const now = new Date();
|
||||
const pad = n => String(n).padStart(2, '0');
|
||||
const ts = `${now.getFullYear()}${pad(now.getMonth()+1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
||||
const link = document.createElement('a');
|
||||
link.download = `camera-spec-card-${ts}.jpg`;
|
||||
link.href = canvas.toDataURL('image/jpeg', 0.92);
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
const filename = `camera-spec-card-${ts}.jpg`;
|
||||
|
||||
canvas.toBlob(blob => {
|
||||
if (!blob) {
|
||||
const link = document.createElement('a');
|
||||
link.download = filename;
|
||||
link.href = canvas.toDataURL('image/jpeg', 0.92);
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
return;
|
||||
}
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.download = filename;
|
||||
link.href = url;
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
}, 'image/jpeg', 0.92);
|
||||
});
|
||||
|
||||
function getFileType(file) {
|
||||
@@ -1698,7 +1714,7 @@ function buildMetaFromRaw(exif) {
|
||||
const parts = exif.DateTimeOriginal.split(' ');
|
||||
if (parts[0]) {
|
||||
const parsed = new Date(parts[0].replace(/:/g, '-'));
|
||||
if (!isNaN(parsed)) date = parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
if (!isNaN(parsed)) date = parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });
|
||||
}
|
||||
}
|
||||
return { camera, lensModel, focalLength, aperture, shutter, iso, date };
|
||||
@@ -1923,7 +1939,7 @@ function parseFitsHeader(text) {
|
||||
const dateObs = get('DATE-OBS') || get('DATE');
|
||||
if (dateObs) {
|
||||
const parsed = new Date(dateObs.split('T')[0]);
|
||||
meta.date = isNaN(parsed) ? dateObs : parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
meta.date = isNaN(parsed) ? dateObs : parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });
|
||||
} else {
|
||||
meta.date = null;
|
||||
}
|
||||
@@ -2144,7 +2160,7 @@ function extractMetaFromTiffIfd(ifd) {
|
||||
if (parts[0]) {
|
||||
const d = parts[0].replace(/:/g, '-');
|
||||
const parsed = new Date(d);
|
||||
result.date = isNaN(parsed) ? null : parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
result.date = isNaN(parsed) ? null : parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -2192,7 +2208,7 @@ function extractMeta(exif) {
|
||||
if (parts[0]) {
|
||||
const d = parts[0].replace(/:/g, '-');
|
||||
const parsed = new Date(d);
|
||||
if (!isNaN(parsed)) date = parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
if (!isNaN(parsed)) date = parsed.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' });
|
||||
}
|
||||
}
|
||||
return { camera, lensModel, focalLength, aperture, shutter, iso, date };
|
||||
|
||||
Reference in New Issue
Block a user