fix(unrestrict_date): stupid mistake that doesn't let return unrestrict date in any of TimeMetric enumeration except Days
This commit is contained in:
parent
f9a6c9645b
commit
b621a3af66
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue