Skip to content

Commit

Permalink
Add back and deprecate old methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Aug 11, 2015
1 parent 999bdec commit e29a62f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libstd/time/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,30 @@ impl Duration {
#[stable(feature = "duration", since = "1.3.0")]
pub fn as_secs(&self) -> u64 { self.secs }

#[deprecated(reason = "renamed to `as_secs`", since = "1.3.0")]
#[unstable(feature = "duration_deprecated")]
/// Returns the number of whole seconds represented by this duration.
///
/// The extra precision represented by this duration is ignored (e.g. extra
/// nanoseconds are not represented in the returned value).
pub fn secs(&self) -> u64 { self.as_secs() }

/// Returns the nanosecond precision represented by this duration.
///
/// This method does **not** return the length of the duration when
/// represented by nanoseconds. The returned number always represents a
/// fractional portion of a second (e.g. it is less than one billion).
#[stable(feature = "duration", since = "1.3.0")]
pub fn subsec_nanos(&self) -> u32 { self.nanos }

#[deprecated(reason = "renamed to `subsec_nanos`", since = "1.3.0")]
#[unstable(feature = "duration_deprecated")]
/// Returns the nanosecond precision represented by this duration.
///
/// This method does **not** return the length of the duration when
/// represented by nanoseconds. The returned number always represents a
/// fractional portion of a second (e.g. it is less than one billion).
pub fn extra_nanos(&self) -> u32 { self.subsec_nanos() }
}

impl Add for Duration {
Expand Down

0 comments on commit e29a62f

Please sign in to comment.