Compare commits
3 Commits
c76364c8b4
...
b621a3af66
Author | SHA1 | Date | |
---|---|---|---|
doryan | b621a3af66 | ||
doryan | f9a6c9645b | ||
doryan | da5edc1aac |
|
@ -11,7 +11,7 @@ pub enum TimeMetrics {
|
|||
impl TimeMetrics {
|
||||
pub fn from(metric: impl Into<&'static str>, duration: i64) -> Self {
|
||||
match metric.into() {
|
||||
"min" | "minutes" | "minute" | "минута" | "минуты" | "минут" | "мин" => {
|
||||
"m" | "min" | "minutes" | "minute" | "минута" | "минуты" | "минут" | "мин" | "м" => {
|
||||
Self::Minutes(duration)
|
||||
}
|
||||
"h" | "hours" | "hour" | "час" | "часов" | "ч" => Self::Hours(duration),
|
||||
|
@ -21,7 +21,7 @@ impl TimeMetrics {
|
|||
"w" | "weeks" | "week" | "недель" | "недели" | "неделя" | "н" => {
|
||||
Self::Weeks(duration)
|
||||
}
|
||||
"m" | "months" | "month" | "месяц" | "месяца" | "месяцев" | "мес" => {
|
||||
"M" | "months" | "month" | "месяц" | "месяца" | "месяцев" | "мес" | "М" => {
|
||||
Self::Mounths(duration)
|
||||
}
|
||||
_ => Self::Days(duration),
|
||||
|
|
|
@ -10,7 +10,7 @@ pub type ExtractedDuration = (NaiveDateTime, String, i64);
|
|||
|
||||
pub fn get_duration(time: TimeValues) -> ExtractedDuration {
|
||||
let time_duration = time.0.extract();
|
||||
let unmute_date = unrestrict_date(time_duration);
|
||||
let unmute_date = unrestrict_date(time);
|
||||
let postfix = CountableTime::from_value(time_duration)
|
||||
.get_postfix(time.0)
|
||||
.unwrap();
|
||||
|
|
|
@ -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