You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usecrate::ms_converter::ms_into_time;let value = ms_into_time("1d").unwrap();assert_eq!(value.as_millis(),86400000)
Convert milliseconds into human-like time string
usecrate::ms_converter::{get_duration_by_postfix,DAY};let value = get_duration_by_postfix(DAYasi64," day").unwrap();assert_eq!(value,"1 day")
Convert milliseconds into human-like time string without postfix
usecrate::ms_converter::{get_max_possible_duration,DAY};let value = get_max_possible_duration(DAYasi64).unwrap();assert_eq!(value,"1d")
Convert milliseconds into long human-like time string without postfix
usecrate::ms_converter::{get_max_possible_duration_long,WEEK};let value = get_max_possible_duration_long(2*WEEKasi64).unwrap();assert_eq!(value,"14 days")// Max possible period is a day
Supported time strings
Years:years, year, yrs, yr, y
Weeks:weeks, week, w
Days:days, day, d
Hours:hours, hour, hrs, hr, h
Minutes:minutes, minute, mins, min, m
Seconds:seconds, second, secs, sec, s
Milliseconds:milliseconds, millisecond, msecs, msec, ms and empty postfix
Performance
You can check the performance diff between ms_converter and ms libraries here.
Also, the macro has no time in the runtime! It will be converted into the const value.