mirror of
https://gitee.com/openharmony/third_party_rust_humantime
synced 2024-11-23 07:30:19 +00:00
Expose inner values from formatting wrappers (#18)
This commit is contained in:
parent
669473d260
commit
5cb9614ee1
@ -240,6 +240,13 @@ pub fn format_rfc3339_nanos(system_time: SystemTime) -> Rfc3339Timestamp {
|
||||
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 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::Precision::*;
|
||||
|
@ -285,6 +285,13 @@ fn item(f: &mut fmt::Formatter, started: &mut bool, name: &str, value: u32)
|
||||
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 {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let secs = self.0.as_secs();
|
||||
|
Loading…
Reference in New Issue
Block a user