Skip to content

Commit

Permalink
fix: remove seconds, milliseconds and nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed May 30, 2024
1 parent 09f1a5f commit ccf88e2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,20 @@ pub fn compare_dates(event_date: &str, now: &OffsetDateTime) -> Option<EventDate
let event_date = OffsetDateTime::parse(event_date, &Rfc3339)
.unwrap_or_else(|e| panic!("Cannot parse date {e}"))
.replace_minute(0)
.unwrap_or_else(|_| panic!("Cannot replace minutes from event date"));
.unwrap_or_else(|_| panic!("Cannot replace minutes from event date"))
.replace_second(0)
.unwrap_or_else(|_| panic!("Cannot replace seconds from event date"))
.replace_millisecond(0)
.unwrap_or_else(|_| panic!("Cannot replace milliseconds from event date"))
.replace_nanosecond(0)
.unwrap_or_else(|_| panic!("Cannot replace nanoseconds from event date"));
let now = now
.replace_second(0)
.unwrap_or_else(|_| panic!("Cannot replace seconds from event date"))
.replace_millisecond(0)
.unwrap_or_else(|_| panic!("Cannot replace milliseconds from event date"))
.replace_nanosecond(0)
.unwrap_or_else(|_| panic!("Cannot replace nanoseconds from event date"));
let days = event_date.checked_sub(Duration::days(3)).unwrap();
let hours = event_date.checked_sub(Duration::hours(1)).unwrap();

Expand Down

0 comments on commit ccf88e2

Please sign in to comment.