Function sip2::util::sip_date

source ·
pub fn sip_date(iso_date: &str) -> Result<String, Error>
Expand description

Translate an iso8601-ish to SIP format

NOTE: Evergreen/Postgres dates are not parseable here, because PG does not use colons in its timezone offsets. You have to use something like this instead: DateTime::parse_from_str(pg_iso_date, “%Y-%m-%dT%H:%M:%S%z”)

use sip2::util;

let date_op = util::sip_date("1996-12-19T16:39:57-08:00");
assert_eq!(date_op.is_ok(), true);

let result = date_op.unwrap();
assert_eq!(result, "19961219    163957");

let date_op2 = util::sip_date("YARP!");
assert_eq!(date_op2.is_err(), true);