Fix expirations

This commit is contained in:
jude 2023-08-10 18:25:41 +01:00
parent 0d4a02fb1e
commit 5a386daa9d

View File

@ -238,13 +238,17 @@ async function serialize_reminder(node, mode) {
utc_time = utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"); utc_time = utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss");
} }
expiration_time = luxon.DateTime.fromISO( let expiration = node.querySelector('input[name="expiration"]').value;
node.querySelector('input[name="time"]').value
).setZone("UTC"); if (expiration) {
if (expiration_time.invalid) { expiration_time = luxon.DateTime.fromISO(
return { error: "Expiration provided invalid." }; node.querySelector('input[name="expiration"]').value
} else { ).setZone("UTC");
expiration_time = expiration_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"); if (expiration_time.invalid) {
return { error: "Expiration provided invalid." };
} else {
expiration_time = expiration_time.toFormat("yyyy-LL-dd'T'HH:mm:ss");
}
} }
} }
@ -429,7 +433,7 @@ function deserialize_reminder(reminder, frame, mode) {
timeInput.value = localTime.toFormat("yyyy-LL-dd'T'HH:mm:ss"); timeInput.value = localTime.toFormat("yyyy-LL-dd'T'HH:mm:ss");
if (reminder["expires"]) { if (reminder["expires"]) {
let expiresInput = frame.querySelector('input[name="time"]'); let expiresInput = frame.querySelector('input[name="expiration"]');
let expiresTime = luxon.DateTime.fromISO(reminder["expires"], { let expiresTime = luxon.DateTime.fromISO(reminder["expires"], {
zone: "UTC", zone: "UTC",
}).setZone(timezone); }).setZone(timezone);