pub fn encode_time<W>(mut to: W, time: NaiveTime) -> IoResult<usize>
where
    W: Write,
{
    // HH(MM(SS(.F{1,6})?)?)?

    let h = time.hour();
    let m = time.minute();
    let s = time.second();
    let f = time.nanosecond();

    match (h, m, s, f) {
        (h, 0, 0, 0) => {
            write!(to, "{:02}", h,)?;
            Ok(2)
        }
        (h, m, 0, 0) => {
            write!(to, "{:02}{:02}", h, m)?;
            Ok(4)
        }
        (h, m, s, 0) => {
            write!(to, "{:02}{:02}{:02}", h, m, s)?;
            Ok(6)
        }
        // 10ths of seconds
        (h, m, s, f) if f % 100_000_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:01}", h, m, s, f / 100_000_000)?;
            Ok(8)
        }
        // milliseconds
        (h, m, s, f) if f % 1_000_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:03}", h, m, s, f / 1_000_000)?;
            Ok(10)
        }
        // 10ths of microseconds
        (h, m, s, f) if f % 10_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:05}", h, m, s, f / 10_000)?;
            Ok(12)
        }
        // maximum precision
        _ => {
            write!(to, "{:02}{:02}{:02}.{:06}", h, m, s, f / 1_000)?;
            Ok(13)
        }
    }
}
/** Encode a single time value in accordance to the DICOM Time (TM)
 * value representation.
 */
Encode a single time value in accordance to the DICOM Time (TM)
value representation.
Encode a single time value in accordance to the DICOM Time ( TM ) value representation .
pub fn encode_time<W>(mut to: W, time: NaiveTime) -> IoResult<usize>
where
    W: Write,
{
    // HH(MM(SS(.F{1,6})?)?)?
    let h = time.hour();
    let m = time.minute();
    let s = time.second();
    let f = time.nanosecond();
    match (h, m, s, f) {
        (h, 0, 0, 0) => {
            write!(to, "{:02}", h,)?;
            Ok(2)
        }
        (h, m, 0, 0) => {
            write!(to, "{:02}{:02}", h, m)?;
            Ok(4)
        }
        (h, m, s, 0) => {
            write!(to, "{:02}{:02}{:02}", h, m, s)?;
            Ok(6)
        }
        // 10ths of seconds
        (h, m, s, f) if f % 100_000_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:01}", h, m, s, f / 100_000_000)?;
            Ok(8)
        }
        // milliseconds
        (h, m, s, f) if f % 1_000_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:03}", h, m, s, f / 1_000_000)?;
            Ok(10)
        }
        // 10ths of microseconds
        (h, m, s, f) if f % 10_000 == 0 => {
            write!(to, "{:02}{:02}{:02}.{:05}", h, m, s, f / 10_000)?;
            Ok(12)
        }
        // maximum precision
        _ => {
            write!(to, "{:02}{:02}{:02}.{:06}", h, m, s, f / 1_000)?;
            Ok(13)
        }
    }
}
pub fn encode_time < W > ( mut to : W , time : NaiveTime ) -> IoResult < usize > where W : Write , { // HH(MM(SS(.F{1,6})?)?)? let h = time . hour ( ) ; let m = time . minute ( ) ; let s = time . second ( ) ; let f = time . nanosecond ( ) ; match ( h , m , s , f ) { ( h , 0 , 0 , 0 ) => { write ! ( to " " h ) ? ; Ok ( 2 ) } ( h , m , 0 , 0 ) => { write ! ( to " " h m ) ? ; Ok ( 4 ) } ( h , m , s , 0 ) => { write ! ( to " " h m s ) ? ; Ok ( 6 ) } // 10ths of seconds ( h , m , s , f ) if f % 100_000_000 == 0 => { write ! ( to " " h m s f 100_000_000 ) ? ; Ok ( 8 ) } // milliseconds ( h , m , s , f ) if f % 1_000_000 == 0 => { write ! ( to " " h m s f 1_000_000 ) ? ; Ok ( 10 ) } // 10ths of microseconds ( h , m , s , f ) if f % 10_000 == 0 => { write ! ( to " " h m s f 10_000 ) ? ; Ok ( 12 ) } // maximum precision _ => { write ! ( to " " h m s f 1_000 ) ? ; Ok ( 13 ) } } }
Encode a single time value in accordance to the DICOM Time (TM)
 value representation.
Encode a single time value in accordance to the DICOM Time ( TM ) value representation .
to
W
time
NaiveTime
to
W
time
NaiveTime