@paroicms/internal-server-lib
Version:
Common utilitaries for the paroicms server.
17 lines • 575 B
JavaScript
export function sqliteDateTime(date) {
const dt = typeof date === "string" ? new Date(date) : date;
// SQLite expects the date in the format 'YYYY-MM-DD HH:MM:SS'
return dt.toISOString().slice(0, 19).replace("T", " ");
}
export function parseSqliteDateTime(val) {
if (!val)
return;
if (typeof val === "number")
return new Date(val);
if (typeof val === "string") {
const gmtDt = `${val.substring(0, 10)}T${val.substring(11, 19)}Z`;
return new Date(gmtDt);
}
return val;
}
//# sourceMappingURL=sqlite-utils.js.map