1
0
mirror of https://github.com/bspeice/dtparse synced 2024-11-14 09:58:09 -05:00
dtparse/tests/parse.rs

30 lines
656 B
Rust
Raw Normal View History

2018-05-13 16:18:45 -04:00
extern crate chrono;
extern crate dtparse;
use chrono::DateTime;
use chrono::NaiveDate;
use chrono::NaiveDateTime;
2018-05-15 00:50:14 -04:00
use chrono::NaiveTime;
use chrono::Utc;
2018-05-13 16:18:45 -04:00
use dtparse::parse;
macro_rules! ymd_test {
2018-05-15 00:50:14 -04:00
($date:expr, $year:expr, $month:expr, $day:expr) => {
2018-05-13 16:18:45 -04:00
let nd = NaiveDate::from_ymd($year, $month, $day);
let nt = NaiveTime::from_hms(0, 0, 0);
let dt = NaiveDateTime::new(nd, nt);
let utc_dt = DateTime::from_utc(dt, Utc);
let parsed = parse($date);
println!("{:?}", parsed);
assert!(parsed == Ok(utc_dt));
};
}
#[test]
fn test_basic() {
ymd_test!("2014 January 19", 2014, 1, 19);
2018-05-15 00:50:14 -04:00
}