From 3713310beb4c758d9032406f2982964915f35fe0 Mon Sep 17 00:00:00 2001 From: Hinton Date: Tue, 19 Sep 2023 17:37:45 +0200 Subject: [PATCH] Change to parse --- .../src/secrets_manager/projects/project_response.rs | 11 ++++++++--- .../src/secrets_manager/secrets/secret_response.rs | 11 ++++++++--- crates/bitwarden/src/util.rs | 5 ----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/bitwarden/src/secrets_manager/projects/project_response.rs b/crates/bitwarden/src/secrets_manager/projects/project_response.rs index 8fcace5940..b8c82806b0 100644 --- a/crates/bitwarden/src/secrets_manager/projects/project_response.rs +++ b/crates/bitwarden/src/secrets_manager/projects/project_response.rs @@ -8,7 +8,6 @@ use crate::{ client::encryption_settings::EncryptionSettings, crypto::{Decryptable, EncString}, error::{Error, Result}, - util::parse_date, }; #[derive(Serialize, Deserialize, Debug, JsonSchema)] @@ -39,8 +38,14 @@ impl ProjectResponse { organization_id, name, - creation_date: parse_date(&response.creation_date.ok_or(Error::MissingFields)?)?, - revision_date: parse_date(&response.revision_date.ok_or(Error::MissingFields)?)?, + creation_date: response + .creation_date + .ok_or(Error::MissingFields)? + .parse()?, + revision_date: response + .revision_date + .ok_or(Error::MissingFields)? + .parse()?, }) } } diff --git a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs index ebe1d9cc33..a7fe49200e 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs @@ -10,7 +10,6 @@ use crate::{ client::encryption_settings::EncryptionSettings, crypto::{Decryptable, EncString}, error::{Error, Result}, - util::parse_date, }; #[derive(Serialize, Deserialize, Debug, JsonSchema)] @@ -81,8 +80,14 @@ impl SecretResponse { value, note, - creation_date: parse_date(&response.creation_date.ok_or(Error::MissingFields)?)?, - revision_date: parse_date(&response.revision_date.ok_or(Error::MissingFields)?)?, + creation_date: response + .creation_date + .ok_or(Error::MissingFields)? + .parse()?, + revision_date: response + .revision_date + .ok_or(Error::MissingFields)? + .parse()?, }) } } diff --git a/crates/bitwarden/src/util.rs b/crates/bitwarden/src/util.rs index c99c2fafba..65d4e777c8 100644 --- a/crates/bitwarden/src/util.rs +++ b/crates/bitwarden/src/util.rs @@ -51,11 +51,6 @@ pub fn decode_token(token: &str) -> Result { Ok(serde_json::from_slice(&decoded)?) } -/// Parse a date in RFC3339 format -pub(crate) fn parse_date(date: &str) -> Result> { - Ok(DateTime::parse_from_rfc3339(date)?.with_timezone(&Utc)) -} - #[cfg(test)] mod tests { #[test]