photosite/dist/fix.js

32 lines
866 B
JavaScript
Raw Permalink Normal View History

2024-12-21 06:04:22 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const log_1 = require("./log");
const db_1 = require("./db");
async function fixDates() {
const log = (0, log_1.createLog)('fixDates');
const db = new db_1.DB();
let rows;
let parts;
let d;
try {
rows = await db.getAll();
}
catch (err) {
log.error(err);
}
for (let row of rows) {
parts = row.name.split('_');
d = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2]));
row.created = +d;
try {
await db.update(row, ['created']);
log.info(`Updated row ${row.id}: created == ${row.created}`);
}
catch (err) {
log.error('Error updating row', err);
}
}
}
fixDates();
//# sourceMappingURL=fix.js.map