Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Fix Invalid Date in admin System Settings list by serializing setting timestamps as ISO strings and guarding the date formatter

Murtaza Nasir67ce2c8a1f90
diff --git a/src/models/system.py b/src/models/system.py
index a3aae988..b13cfb7e 100644
--- a/src/models/system.py
+++ b/src/models/system.py
@@ -28,8 +28,12 @@ class SystemSetting(db.Model):
'value': self.value,
'description': self.description,
'setting_type': self.setting_type,
- 'created_at': self.created_at,
- 'updated_at': self.updated_at
+ # ISO 8601 strings (naive UTC) so the frontend parses them the same
+ # way as every other timestamp. Returning raw datetimes makes Flask
+ # emit RFC-1123 HTTP-date strings, which the client's parser cannot
+ # read (it rendered as "Invalid Date").
+ 'created_at': self.created_at.isoformat() if self.created_at else None,
+ 'updated_at': self.updated_at.isoformat() if self.updated_at else None
}
@staticmethod
diff --git a/templates/admin.html b/templates/admin.html
index 22acbb86..08de010e 100644
--- a/templates/admin.html
+++ b/templates/admin.html
@@ -2720,6 +2720,9 @@ Summarization Instructions:
const formatDate = (dateString) => {
if (!dateString) return t('adminDashboard.never');
const date = parseInstant(dateString);
+ // Guard against unparseable input so we never render the
+ // literal "Invalid Date Invalid Date".
+ if (isNaN(date.getTime())) return t('adminDashboard.never');
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
};