[][src]Function ms_converter::get_max_possible_duration_long

pub fn get_max_possible_duration_long(
    milliseconds: i64
) -> Result<String, Error>

Getting human-like time from milliseconds. get_max_possible_duration_long function gets a milliseconds count and returns a max possible string with your time. get_max_possible_duration_long has some limitations maximum of avalable postfixes is a day.

Usage

use crate::ms_converter::{get_max_possible_duration_long, WEEK};

let value = get_max_possible_duration_long(2 * WEEK as i64).unwrap();
assert_eq!(value, "14 days") // Max possible period is a day
use crate::ms_converter::{get_max_possible_duration_long, DAY};

let value = get_max_possible_duration_long(DAY as i64).unwrap();
assert_eq!(value, "1 day")

also you can a pass negative values

use crate::ms_converter::{get_max_possible_duration_long, WEEK};

let value = get_max_possible_duration_long(-2 * WEEK as i64).unwrap();
assert_eq!(value, "-14 days") // Max possible period is a day