1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
//---------------------------------------------------------------------------------------------------- Use
use crate::{
int::Int,
unsigned::Unsigned,
float::Float,
percent::Percent,
runtime::Runtime,
date::Date,
};
//---------------------------------------------------------------------------------------------------- Constants
/// The locale numbers are formatted in (English). This looks like: `1,000`
const LOCALE: num_format::Locale = num_format::Locale::en;
/// Returned when encountering a [`f32::NAN`] or [`f64::NAN`]
pub const NAN: &str = "NaN";
/// Returned when encountering an `INFINITY` variant of an `f32/f64`.
pub const INFINITY: &str = "∞";
/// Returned when using [`Int::zero`] or [`Unsigned::zero`]
pub const ZERO: &str = "0";
/// Returned when using an `*::unknown()` function
pub const UNKNOWN: &str = "???";
/// Returned when using [`Float::unknown`]
pub const UNKNOWN_FLOAT: &str = "?.???";
/// Returned when using [`Percent::unknown`]
pub const UNKNOWN_PERCENT: &str = "?.??%";
/// Returned when using [`Runtime::unknown`]
pub const UNKNOWN_RUNTIME: &str = "?:??";
/// UTF-8 byte encoding of [`UNKNOWN_DATE`], aka: `?:??`
///
/// ```rust
/// # use readable::*;
/// assert!(UNKNOWN_RUNTIME.as_bytes()[..4] == UNKNOWN_RUNTIME_BUFFER[..4]);
/// ```
pub const UNKNOWN_RUNTIME_BUFFER: [u8; 8] = [63, 58, 63, 63, 0, 0, 0, 0];
/// Returned when using [`Date::unknown`]
pub const UNKNOWN_DATE: &str = "????-??-??";
/// UTF-8 byte encoding of [`UNKNOWN_DATE`], aka: `????-??-??`
///
/// ```rust
/// # use readable::*;
/// assert!(UNKNOWN_DATE.as_bytes() == UNKNOWN_DATE_BUFFER);
/// ```
pub const UNKNOWN_DATE_BUFFER: [u8; 10] = [63, 63, 63, 63, 45, 63, 63, 45, 63, 63];
/// Returned when using [`Float::zero`]
pub const ZERO_FLOAT: &str = "0.000";
/// Returned when using [`Percent::zero`]
pub const ZERO_PERCENT: &str = "0.00%";
/// Returned when using [`Runtime::zero`]
pub const ZERO_RUNTIME: &str = "0:00";
/// UTF-8 byte encoding of [`ZERO_RUNTIME`]
///
/// ```rust
/// # use readable::*;
/// assert!(ZERO_RUNTIME.as_bytes()[..3] == ZERO_RUNTIME_BUFFER[..3]);
/// ```
pub const ZERO_RUNTIME_BUFFER: [u8; 8] = [48, 58, 48, 48, 0, 0, 0, 0];
/// Returned when using [`Runtime::second`]
pub const SECOND_RUNTIME: &str = "0:01";
/// UTF-8 byte encoding of [`SECOND_RUNTIME`]
///
/// ```rust
/// # use readable::*;
/// assert!(SECOND_RUNTIME.as_bytes()[..4] == SECOND_RUNTIME_BUFFER[..4]);
/// ```
pub const SECOND_RUNTIME_BUFFER: [u8; 8] = [48, 58, 48, 49, 0, 0, 0, 0];
/// Returned when using [`Runtime::minute`]
pub const MINUTE_RUNTIME: &str = "1:00";
/// UTF-8 byte encoding of [`MINUTE_RUNTIME`]
///
/// ```rust
/// # use readable::*;
/// assert!(MINUTE_RUNTIME.as_bytes()[..4] == MINUTE_RUNTIME_BUFFER[..4]);
/// ```
pub const MINUTE_RUNTIME_BUFFER: [u8; 8] = [49, 58, 48, 48, 0, 0, 0, 0];
/// Returned when using [`Runtime::hour`]
pub const HOUR_RUNTIME: &str = "1:00:00";
/// UTF-8 byte encoding of [`HOUR_RUNTIME`]
///
/// ```rust
/// # use readable::*;
/// assert!(HOUR_RUNTIME.as_bytes()[..7] == HOUR_RUNTIME_BUFFER[..7]);
/// ```
pub const HOUR_RUNTIME_BUFFER: [u8; 8] = [49, 58, 48, 48, 58, 48, 48, 0];
/// Returned when calling [`Runtime::zero`]
pub const ZERO_RUNTIME_U32: u32 = 0;
/// Returned when calling [`Runtime::second`]
pub const SECOND_RUNTIME_U32: u32 = 1;
/// Returned when calling [`Runtime::minute`]
pub const MINUTE_RUNTIME_U32: u32 = 60;
/// Returned when calling [`Runtime::hour`]
pub const HOUR_RUNTIME_U32: u32 = 3600;
/// The max input to [`Runtime`] before it overflows and returns [`UNKNOWN_RUNTIME`]
pub const MAX_RUNTIME_U32: u32 = 359999;
/// The text [`Runtime`] will return [`UNKNOWN_RUNTIME`]
pub const MAX_RUNTIME: &str = "99:59:59";
/// UTF-8 byte encoding of [`MAX_RUNTIME`]
///
/// ```rust
/// # use readable::*;
/// assert!(MAX_RUNTIME.as_bytes() == MAX_RUNTIME_BUFFER);
/// ```
pub const MAX_RUNTIME_BUFFER: [u8; 8] = [57, 57, 58, 53, 57, 58, 53, 57];