Skip to content

Commit

Permalink
refactor(services/importer): fn to parse a date string
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Dec 12, 2024
1 parent 479b994 commit 2a1f439
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/services/importer/src/hevy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ pub async fn import(
.unwrap_or_default(),
});
}
let start_time =
NaiveDateTime::parse_from_str(&first_exercise.start_time, "%d %b %Y, %H:%M").unwrap();
let end_time =
NaiveDateTime::parse_from_str(&first_exercise.end_time, "%d %b %Y, %H:%M").unwrap();
let start_time = parse_date_string(&first_exercise.start_time);
let end_time = parse_date_string(&first_exercise.end_time);
completed.push(ImportCompletedItem::Workout(UserWorkoutInput {
assets: None,
supersets: vec![],
Expand All @@ -174,3 +172,7 @@ pub async fn import(
);
Ok(ImportResult { failed, completed })
}

fn parse_date_string(input: &str) -> NaiveDateTime {
NaiveDateTime::parse_from_str(&input, "%d %b %Y, %H:%M").unwrap()
}

0 comments on commit 2a1f439

Please sign in to comment.