humanise
This module contains a bunch of shortcuts to the time
and bytes
modules for directly “humanising” and formatting a number (Float
or Int
) to a String
.
For more control (e.g. return time.Time
or bytes.Bytes
instead of a String
, use the given unit instead of the most optimal one), look at the time
or bytes
modules.
Functions
pub fn bytes_float(from n: Float) -> String
Format n bytes as a Float
, converting to a more optimal unit if possible.
pub fn bytes_int(from n: Int) -> String
Format n bytes as an Int
, converting to a more optimal unit if possible.
pub fn days_float(from n: Float) -> String
Format n days as a Float
, converting to a more optimal unit if possible.
pub fn days_int(from n: Int) -> String
Format n days as an Int
, converting to a more optimal unit if possible.
pub fn gigabytes_float(from n: Float) -> String
Format n gigabytes as a Float
, converting to a more optimal unit if possible.
pub fn gigabytes_int(from n: Int) -> String
Format n gigabytes as an Int
, converting to a more optimal unit if possible.
pub fn hours_float(from n: Float) -> String
Format n hours as a Float
, converting to a more optimal unit if possible.
pub fn hours_int(from n: Int) -> String
Format n hours as an Int
, converting to a more optimal unit if possible.
pub fn kilobytes_float(from n: Float) -> String
Format n kilobytes as a Float
, converting to a more optimal unit if possible.
pub fn kilobytes_int(from n: Int) -> String
Format n kilobytes as an Int
, converting to a more optimal unit if possible.
pub fn megabytes_float(from n: Float) -> String
Format n megabytes as a Float
, converting to a more optimal unit if possible.
pub fn megabytes_int(from n: Int) -> String
Format n megabytes as an Int
, converting to a more optimal unit if possible.
pub fn microseconds_float(from n: Float) -> String
Format n microseconds as a Float
, converting to a more optimal unit if possible.
pub fn microseconds_int(from n: Int) -> String
Format n microseconds as an Int
, converting to a more optimal unit if possible.
pub fn milliseconds_float(from n: Float) -> String
Format n milliseconds as a Float
, converting to a more optimal unit if possible.
pub fn milliseconds_int(from n: Int) -> String
Format n milliseconds as an Int
, converting to a more optimal unit if possible.
pub fn seconds_float(from n: Float) -> String
Format n seconds as a Float
, converting to a more optimal unit if possible.
pub fn seconds_int(from n: Int) -> String
Format n seconds as an Int
, converting to a more optimal unit if possible.
pub fn terabytes_float(from n: Float) -> String
Format n terabytes as a Float
, converting to a more optimal unit if possible.
pub fn terabytes_int(from n: Int) -> String
Format n terabytes as an Int
, converting to a more optimal unit if possible.
pub fn weeks_float(from n: Float) -> String
Format n weeks as a Float
, converting to a more optimal unit if possible.