From b621a3af66bba9632feac08ca04fea3057d48a16 Mon Sep 17 00:00:00 2001 From: doryan Date: Tue, 18 Jun 2024 18:34:10 +0400 Subject: [PATCH] fix(unrestrict_date): stupid mistake that doesn't let return unrestrict date in any of TimeMetric enumeration except Days --- src/utils/general/unrestrict_date.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils/general/unrestrict_date.rs b/src/utils/general/unrestrict_date.rs index 0b1a9e6..0f66171 100644 --- a/src/utils/general/unrestrict_date.rs +++ b/src/utils/general/unrestrict_date.rs @@ -1,6 +1,15 @@ use chrono::{Duration, Local, NaiveDateTime}; +use crate::types::{enums::time_metrics::TimeMetrics, TimeValues}; + #[inline] -pub fn unrestrict_date(days: i64) -> NaiveDateTime { - Local::now().naive_utc() + Duration::days(days) +pub fn unrestrict_date(duration: TimeValues) -> NaiveDateTime { + let mute_duration = match duration.0 { + TimeMetrics::Minutes(min) => Duration::minutes(min), + TimeMetrics::Hours(hrs) => Duration::hours(hrs), + TimeMetrics::Days(day) => Duration::days(day), + TimeMetrics::Weeks(wks) => Duration::weeks(wks), + TimeMetrics::Mounths(mon) => Duration::weeks(mon * 4), + }; + Local::now().naive_utc() + mute_duration }