ui: Fix doc tests (#3989)
There were a ton of doc tests that weren't compiling in the `ui` crate, so this PR fixes them. Release Notes: - N/A
This commit is contained in:
parent
68d0b468f3
commit
684bd530f0
5 changed files with 63 additions and 53 deletions
|
@ -234,28 +234,6 @@ fn distance_string(
|
|||
/// For example, "less than a minute ago", "about 2 hours ago", "3 months from now", etc.
|
||||
///
|
||||
/// Use [`format_distance_from_now`] to compare a NaiveDateTime against now.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `date` - The [`NaiveDateTime`] to compare.
|
||||
/// * `base_date` - The [`NaiveDateTime`] to compare against.
|
||||
/// * `include_seconds` - A boolean. If true, distances less than a minute are more detailed
|
||||
/// * `add_suffix` - A boolean. If true, result indicates if the time is in the past or future
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use chrono::DateTime;
|
||||
/// use ui::utils::format_distance;
|
||||
///
|
||||
/// fn time_between_moon_landings() -> String {
|
||||
/// let date = DateTime::parse_from_rfc3339("1969-07-20T00:00:00Z").unwrap().naive_local();
|
||||
/// let base_date = DateTime::parse_from_rfc3339("1972-12-14T00:00:00Z").unwrap().naive_local();
|
||||
/// format!("There was {} between the first and last crewed moon landings.", naive_format_distance(date, base_date, false, false))
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Output: `"There was about 3 years between the first and last crewed moon landings."`
|
||||
pub fn format_distance(
|
||||
date: DateTimeType,
|
||||
base_date: NaiveDateTime,
|
||||
|
@ -271,26 +249,6 @@ pub fn format_distance(
|
|||
/// Get the time difference between a date and now as relative human readable string.
|
||||
///
|
||||
/// For example, "less than a minute ago", "about 2 hours ago", "3 months from now", etc.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `datetime` - The [`NaiveDateTime`] to compare with the current time.
|
||||
/// * `include_seconds` - A boolean. If true, distances less than a minute are more detailed
|
||||
/// * `add_suffix` - A boolean. If true, result indicates if the time is in the past or future
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use chrono::DateTime;
|
||||
/// use ui::utils::naive_format_distance_from_now;
|
||||
///
|
||||
/// fn time_since_first_moon_landing() -> String {
|
||||
/// let date = DateTime::parse_from_rfc3339("1969-07-20T00:00:00Z").unwrap().naive_local();
|
||||
/// format!("It's been {} since Apollo 11 first landed on the moon.", naive_format_distance_from_now(date, false, false))
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Output: `It's been over 54 years since Apollo 11 first landed on the moon.`
|
||||
pub fn format_distance_from_now(
|
||||
datetime: DateTimeType,
|
||||
include_seconds: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue