Module jiff

Source
Expand description

Utilies to convert back and forth between jiff’s data structures and the hl7-parser ones All implementations here are implemented as TryFrom and From traits between the TimeStamp struct and various chrono types. This allows for easy conversion between the two types. The TryFrom implementations will return an error if the conversion is not possible, such as if the date or time components are invalid. The From implementations will always succeed and will set missing components to zero or the epoch if necessary.

View the TimeStamp struct’s documentation for more information on exactly which traits are implemented.

§Examples

use hl7_parser::datetime::{TimeStamp, TimeStampOffset};
use jiff::civil::{date, time, datetime};

let timestamp = TimeStamp {
   year: 2021,
   month: Some(1),
   day: Some(1),
   hour: Some(12),
   minute: Some(0),
   second: Some(0),
   microsecond: Some(0),
   offset: None,
};

let datetime = datetime(2021, 1, 1, 12, 0, 0, 0);
assert_eq!(TimeStamp::from(datetime), timestamp);