1
0
mirror of https://github.com/writeas/writefreely synced 2025-01-05 20:47:30 +01:00

Merge pull request #241 from writeas/post-time-fix

fixes imported post times
This commit is contained in:
Matt Baer 2020-02-09 10:23:15 -05:00 committed by GitHub
commit 6d3803bfe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,13 +42,16 @@
</select>
</label>
<script>
// timezone offset in seconds
const tzOffsetSec = new Date().getTimezoneOffset() * 60;
const fileInput = document.getElementById('fileInput');
const fileDates = document.getElementById('fileDates');
fileInput.addEventListener('change', (e) => {
const files = e.target.files;
let dateMap = {};
for (let file of files) {
dateMap[file.name] = file.lastModified / 1000;
// convert from milliseconds to seconds and adjust for tz
dateMap[file.name] = Math.round(file.lastModified / 1000) + tzOffsetSec;
}
fileDates.value = JSON.stringify(dateMap);
})