fixes in ux
This commit is contained in:
@@ -204,7 +204,23 @@ pub fn normalize_timestamp(value: &str) -> String {
|
||||
return timestamp.with_timezone(&Utc).to_rfc3339();
|
||||
}
|
||||
|
||||
for format in ["%Y-%m-%d %H:%M:%S%.f%:z", "%Y-%m-%d %H:%M:%S%.f%#z"] {
|
||||
// PostgreSQL renders TEXT timestamps as e.g. `2026-07-20 14:32:10.123456+00`.
|
||||
// RFC 3339 requires `T` and a colon in the numeric offset.
|
||||
let mut postgres = value.replacen(' ', "T", 1);
|
||||
if postgres.len() >= 3 {
|
||||
let offset_start = postgres.len() - 3;
|
||||
let offset = &postgres[offset_start..];
|
||||
if (offset.starts_with('+') || offset.starts_with('-'))
|
||||
&& offset[1..].chars().all(|character| character.is_ascii_digit())
|
||||
{
|
||||
postgres.push_str(":00");
|
||||
}
|
||||
}
|
||||
if let Ok(timestamp) = DateTime::parse_from_rfc3339(&postgres) {
|
||||
return timestamp.with_timezone(&Utc).to_rfc3339();
|
||||
}
|
||||
|
||||
for format in ["%Y-%m-%d %H:%M:%S%.f%:z", "%Y-%m-%dT%H:%M:%S%.f%:z"] {
|
||||
if let Ok(timestamp) = DateTime::parse_from_str(value, format) {
|
||||
return timestamp.with_timezone(&Utc).to_rfc3339();
|
||||
}
|
||||
@@ -216,6 +232,7 @@ pub fn normalize_timestamp(value: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
// Existing rows should still be readable even if they were stored without a zone.
|
||||
value.to_string()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user