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