gluon/src/utils/general/expiration_date.rs

16 lines
578 B
Rust

use chrono::{Duration, Local, NaiveDateTime};
use crate::types::{enums::time_metrics::TimeMetrics, TimeValues};
#[inline]
pub fn expiration_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
}