Expose inner values from formatting wrappers (#18)

This commit is contained in:
Moritz Gunz 2021-01-13 16:16:57 +01:00 committed by GitHub
parent 669473d260
commit 5cb9614ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -240,6 +240,13 @@ pub fn format_rfc3339_nanos(system_time: SystemTime) -> Rfc3339Timestamp {
Rfc3339Timestamp(system_time, Precision::Nanos) Rfc3339Timestamp(system_time, Precision::Nanos)
} }
impl Rfc3339Timestamp {
/// Returns a reference to the [`SystemTime`][] that is being formatted.
pub fn get_ref(&self) -> &SystemTime {
&self.0
}
}
impl fmt::Display for Rfc3339Timestamp { impl fmt::Display for Rfc3339Timestamp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::Precision::*; use self::Precision::*;

View File

@ -285,6 +285,13 @@ fn item(f: &mut fmt::Formatter, started: &mut bool, name: &str, value: u32)
Ok(()) Ok(())
} }
impl FormattedDuration {
/// Returns a reference to the [`Duration`][] that is being formatted.
pub fn get_ref(&self) -> &Duration {
&self.0
}
}
impl fmt::Display for FormattedDuration { impl fmt::Display for FormattedDuration {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let secs = self.0.as_secs(); let secs = self.0.as_secs();