Compare commits
No commits in common. "b621a3af66bba9632feac08ca04fea3057d48a16" and "c76364c8b4b8ca536153150e917917230719c99d" have entirely different histories.
b621a3af66
...
c76364c8b4
|
@ -11,7 +11,7 @@ pub enum TimeMetrics {
|
||||||
impl TimeMetrics {
|
impl TimeMetrics {
|
||||||
pub fn from(metric: impl Into<&'static str>, duration: i64) -> Self {
|
pub fn from(metric: impl Into<&'static str>, duration: i64) -> Self {
|
||||||
match metric.into() {
|
match metric.into() {
|
||||||
"m" | "min" | "minutes" | "minute" | "минута" | "минуты" | "минут" | "мин" | "м" => {
|
"min" | "minutes" | "minute" | "минута" | "минуты" | "минут" | "мин" => {
|
||||||
Self::Minutes(duration)
|
Self::Minutes(duration)
|
||||||
}
|
}
|
||||||
"h" | "hours" | "hour" | "час" | "часов" | "ч" => Self::Hours(duration),
|
"h" | "hours" | "hour" | "час" | "часов" | "ч" => Self::Hours(duration),
|
||||||
|
@ -21,7 +21,7 @@ impl TimeMetrics {
|
||||||
"w" | "weeks" | "week" | "недель" | "недели" | "неделя" | "н" => {
|
"w" | "weeks" | "week" | "недель" | "недели" | "неделя" | "н" => {
|
||||||
Self::Weeks(duration)
|
Self::Weeks(duration)
|
||||||
}
|
}
|
||||||
"M" | "months" | "month" | "месяц" | "месяца" | "месяцев" | "мес" | "М" => {
|
"m" | "months" | "month" | "месяц" | "месяца" | "месяцев" | "мес" => {
|
||||||
Self::Mounths(duration)
|
Self::Mounths(duration)
|
||||||
}
|
}
|
||||||
_ => Self::Days(duration),
|
_ => Self::Days(duration),
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub type ExtractedDuration = (NaiveDateTime, String, i64);
|
||||||
|
|
||||||
pub fn get_duration(time: TimeValues) -> ExtractedDuration {
|
pub fn get_duration(time: TimeValues) -> ExtractedDuration {
|
||||||
let time_duration = time.0.extract();
|
let time_duration = time.0.extract();
|
||||||
let unmute_date = unrestrict_date(time);
|
let unmute_date = unrestrict_date(time_duration);
|
||||||
let postfix = CountableTime::from_value(time_duration)
|
let postfix = CountableTime::from_value(time_duration)
|
||||||
.get_postfix(time.0)
|
.get_postfix(time.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
use chrono::{Duration, Local, NaiveDateTime};
|
use chrono::{Duration, Local, NaiveDateTime};
|
||||||
|
|
||||||
use crate::types::{enums::time_metrics::TimeMetrics, TimeValues};
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unrestrict_date(duration: TimeValues) -> NaiveDateTime {
|
pub fn unrestrict_date(days: i64) -> NaiveDateTime {
|
||||||
let mute_duration = match duration.0 {
|
Local::now().naive_utc() + Duration::days(days)
|
||||||
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