From f7b409f1140addd508c626b1e80f0f8de52a5639 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 30 Aug 2023 11:24:01 +0200 Subject: use a NaiveDate in data model, it serializes to string (iso 8601 format) --- src/api/s3/lifecycle.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/api') diff --git a/src/api/s3/lifecycle.rs b/src/api/s3/lifecycle.rs index 48265870..278cf26d 100644 --- a/src/api/s3/lifecycle.rs +++ b/src/api/s3/lifecycle.rs @@ -270,12 +270,11 @@ impl Expiration { (Some(_), Some(_)) => Err("cannot have both and in "), (None, None) => Err(" must contain either or "), (Some(days), None) => Ok(GarageLifecycleExpiration::AfterDays(days.0 as usize)), - (None, Some(date)) => { - if date.0.parse::().is_err() { - return Err("Invalid expiration "); - } - Ok(GarageLifecycleExpiration::AtDate(date.0)) - } + (None, Some(date)) => date + .0 + .parse::() + .map(GarageLifecycleExpiration::AtDate) + .map_err(|_| "Invalid expiration "), } } @@ -285,9 +284,9 @@ impl Expiration { days: Some(IntValue(*days as i64)), at_date: None, }, - GarageLifecycleExpiration::AtDate(days) => Expiration { + GarageLifecycleExpiration::AtDate(date) => Expiration { days: None, - at_date: Some(Value::from(days.as_str())), + at_date: Some(Value(date.to_string())), }, } } -- cgit v1.2.3