diff --git a/src/infrastructure/db.rs b/src/infrastructure/db.rs index 6c4ab7c..a33aa55 100644 --- a/src/infrastructure/db.rs +++ b/src/infrastructure/db.rs @@ -140,7 +140,9 @@ impl Db { task.position }; - // Preserve existing created_at if the task already exists + // Preserve existing created_at if the task already exists. + // For new tasks from API, use updated_at as created_at proxy + // (Google Tasks API does not provide a creation timestamp). let created_at = task.created_at.unwrap_or_else(|| { conn.query_row( "SELECT created_at FROM tasks WHERE id = ?1", @@ -149,6 +151,7 @@ impl Db { ) .ok() .and_then(|s| NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S").ok()) + .or_else(|| task.updated_at) .unwrap_or_else(|| chrono::Utc::now().naive_utc()) });