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
//! Ordinal formatting (English).
//!
//! Use this module to render English ordinal markers like `1st`, `2nd`, `3rd`,
//! `4th`, ..., with the standard teen exceptions.
//!
//! # Quick start
//!
//! ```rust
//! use humfmt::ordinal;
//!
//! assert_eq!(ordinal(1).to_string(), "1st");
//! assert_eq!(ordinal(21).to_string(), "21st");
//! assert_eq!(ordinal(11).to_string(), "11th");
//! assert_eq!(ordinal(-1).to_string(), "-1st");
//! ```
//!
//! # Edge case behaviour
//!
//! | Input | Output |
//! |---:|---|
//! | `1` | `"1st"` |
//! | `2` | `"2nd"` |
//! | `3` | `"3rd"` |
//! | `4` | `"4th"` |
//! | `11` | `"11th"` |
//! | `12` | `"12th"` |
//! | `13` | `"13th"` |
//! | `21` | `"21st"` |
//! | `42` | `"42nd"` |
//! | `103` | `"103rd"` |
//! | `111` | `"111th"` |
//! | `-1` | `"-1st"` |
//! | `0` | `"0th"` |
pub use OrdinalDisplay;
pub use OrdinalLike;
/// Creates a human-readable ordinal formatter.
///
/// # Examples
///
/// ```rust
/// assert_eq!(humfmt::ordinal(1).to_string(), "1st");
/// assert_eq!(humfmt::ordinal(23).to_string(), "23rd");
/// ```
/// Returns the English ordinal suffix for a given non-negative integer.
///
/// Used internally and exposed for users who want just the suffix
/// without the value (e.g. for custom rendering pipelines).
///
/// # Examples
///
/// ```rust
/// assert_eq!(humfmt::ordinal::ordinal_suffix(1), "st");
/// assert_eq!(humfmt::ordinal::ordinal_suffix(11), "th");
/// assert_eq!(humfmt::ordinal::ordinal_suffix(22), "nd");
/// ```