Skip to content

Commit

Permalink
Rename SubSecondRound to SubsecRound
Browse files Browse the repository at this point in the history
Per review request.
  • Loading branch information
dekellum committed Mar 5, 2018
1 parent 08b7e0b commit 449d727
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ pub use date::{Date, MIN_DATE, MAX_DATE};
pub use datetime::{DateTime, SecondsFormat};
#[cfg(feature = "rustc-serialize")] pub use datetime::rustc_serialize::TsSeconds;
pub use format::{ParseError, ParseResult};
pub use round::SubSecondRound;
pub use round::SubsecRound;

/// A convenience module appropriate for glob imports (`use chrono::prelude::*;`).
pub mod prelude {
Expand All @@ -419,7 +419,7 @@ pub mod prelude {
#[doc(no_inline)] pub use {NaiveDate, NaiveTime, NaiveDateTime};
#[doc(no_inline)] pub use Date;
#[doc(no_inline)] pub use {DateTime, SecondsFormat};
#[doc(no_inline)] pub use SubSecondRound;
#[doc(no_inline)] pub use SubsecRound;
}

// useful throughout the codebase
Expand Down
10 changes: 5 additions & 5 deletions src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ use oldtime::Duration;
/// behavior in Chrono display formatting. Either can be used to guarantee
/// equality (e.g. for testing) when round-tripping through a lower precision
/// format.
pub trait SubSecondRound {
pub trait SubsecRound {
/// Return a copy rounded to the specified number of subsecond digits. With
/// 9 or more digits, self is returned unmodified. Halfway values are
/// rounded up (away from zero).
///
/// # Example
/// ``` rust
/// # use chrono::{DateTime, SubSecondRound, Timelike, TimeZone, Utc};
/// # use chrono::{DateTime, SubsecRound, Timelike, TimeZone, Utc};
/// let dt = Utc.ymd(2018, 1, 11).and_hms_milli(12, 0, 0, 154);
/// assert_eq!(dt.round_subsecs(2).nanosecond(), 150_000_000);
/// assert_eq!(dt.round_subsecs(1).nanosecond(), 200_000_000);
Expand All @@ -30,15 +30,15 @@ pub trait SubSecondRound {
///
/// # Example
/// ``` rust
/// # use chrono::{DateTime, SubSecondRound, Timelike, TimeZone, Utc};
/// # use chrono::{DateTime, SubsecRound, Timelike, TimeZone, Utc};
/// let dt = Utc.ymd(2018, 1, 11).and_hms_milli(12, 0, 0, 154);
/// assert_eq!(dt.trunc_subsecs(2).nanosecond(), 150_000_000);
/// assert_eq!(dt.trunc_subsecs(1).nanosecond(), 100_000_000);
/// ```
fn trunc_subsecs(self, digits: u16) -> Self;
}

impl<T> SubSecondRound for T
impl<T> SubsecRound for T
where T: Timelike + Add<Duration, Output=T> + Sub<Duration, Output=T>
{
fn round_subsecs(self, digits: u16) -> T {
Expand Down Expand Up @@ -88,7 +88,7 @@ fn span_for_digits(digits: u16) -> u32 {
mod tests {
use Timelike;
use offset::{FixedOffset, TimeZone, Utc};
use super::SubSecondRound;
use super::SubsecRound;

#[test]
fn test_round() {
Expand Down

0 comments on commit 449d727

Please sign in to comment.