diff --git a/spacetimedb/src/lib.rs b/spacetimedb/src/lib.rs index 711fc98..941981b 100644 --- a/spacetimedb/src/lib.rs +++ b/spacetimedb/src/lib.rs @@ -539,10 +539,17 @@ pub fn mark_synced(ctx: &ReducerContext, ids: Vec) -> Result<(), String> { /// Parse en PG-tekststreng ("2026-03-15 23:57:11.677139+00") til SpacetimeDB Timestamp. fn parse_timestamp(s: &str) -> Option { if s.is_empty() { return None; } - // Prøv standard ISO-parse først, deretter PG-formater - let dt = s.parse::>() + // PG returnerer "+00" som offset — chrono krever "+00:00" + let normalized = if s.ends_with("+00") { + format!("{}:00", s) + } else { + s.to_string() + }; + let dt = chrono::DateTime::parse_from_str(&normalized, "%Y-%m-%d %H:%M:%S%.f%:z") + .or_else(|_| chrono::DateTime::parse_from_str(&normalized, "%Y-%m-%d %H:%M:%S%:z")) .map(|d| d.to_utc()) .or_else(|_| { + // Fallback: uten timezone chrono::NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M:%S%.f") .or_else(|_| chrono::NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M:%S")) .map(|naive| naive.and_utc())