Skip to content

Commit

Permalink
Prefer checked variants in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed May 16, 2023
1 parent 13b9f5f commit f774318
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,19 @@ pub enum SecondsFormat {
/// the time.
///
/// Timezone-aware calculations on a [`DateTime`] can be done with:
/// - [`Sub<DateTime>`] to get a [`Duration`](struct.Duration.html) with the difference between two
/// datetimes.
/// - [`Add<Duration>`] to add a [`Duration`](struct.Duration.html) of an absolute number of
/// - [`signed_duration_since`](#method.signed_duration_since) to get a [`Duration`](
/// struct.Duration.html) with the difference between two datetimes.
/// - [`checked_add_signed`](#method.checked_add_signed) and
/// [`checked_sub_signed`](#method.checked_sub_signed) to add/subtract an absolute number of
/// seconds, minutes, hours, etc.
/// - [`Add<Days>`] to add a number of [`Days`], keeping the same local time. This method may panic
/// if the resulting time would not exist, prefer [`checked_add_days`](#method.checked_add_days).
/// - [`Add<Months>`] to add a number of [`Months`], keeping the same local time. See the preferred
/// [`checked_add_months`](#method.checked_add_months) method for implementation details.
/// - [`checked_add_days`](#method.checked_add_days) and [`checked_sub_days`](
/// #method.checked_sub_days) to add/subtract a number of [`Days`], keeping the same local time.
/// - [`checked_add_months`](#method.checked_add_months) and [`checked_sub_months`](
/// #method.checked_sub_months) to add/subtract a number of [`Months`]. If the day would be out of
/// range for the resulting month, the last day for that month is used.
///
/// The same functionality is also available with implementations of [`Add`] and [`Sub`]. Note that
/// these may panic if the resulting time would not exist in the local timezone, or on overflow.
///
/// ## Change the timezone
///
Expand Down
3 changes: 2 additions & 1 deletion src/offset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ pub trait Offset: Sized + Clone + fmt::Debug {
///
/// ## Example
///
/// ```
#[cfg_attr(not(feature = "clock"), doc = "```ignore")]
#[cfg_attr(feature = "clock", doc = "```rust")]
/// use chrono::{LocalResult, Offset, TimeZone};
/// use chrono::{FixedOffset, Local, NaiveDate, NaiveDateTime};
///
Expand Down

0 comments on commit f774318

Please sign in to comment.