#[cfg(test)] mod tests { use df_helper::datetime::{date, datetime, timestamp}; use df_helper::datetime::timer::Timer; #[test] fn datetime() { let mut ttt = Timer::start("s"); let result = datetime::datetime(false); println!("{}", result); let result = datetime::datetime(true); println!("{}", result); let result = datetime::to_date("2022-08-14 15:11:00"); assert_eq!(result, "2022-08-14"); let result = datetime::to_time("2022-08-14 15:11:00"); assert_eq!(result, "15:11:00"); let result = datetime::to_timestamp("2022-08-14 00:00:00", "s"); assert_eq!(result, 1660406400); let result = datetime::to_timestamp("2022-08-14 00:00:00", "ms"); assert_eq!(result, 1660406400000); let result = datetime::to_timestamp("2022-08-14 00:00:00", "us"); assert_eq!(result, 1660406400); ttt.end(false); let result = datetime::to_gmt(); println!("{}",result); } #[test] fn date() { let mut ttt = Timer::start("ms"); let result = date::date(false); println!("{}", result); let result = date::date(true); println!("{}", result); let result = date::to_timestamp("2022-08-14", "s"); assert_eq!(result, 1660406400); let result = date::to_timestamp("2022-08-14", "ms"); assert_eq!(result, 1660406400000); ttt.end(true); } #[test] fn timestamp() { let mut ttt = Timer::start("us"); let result = timestamp::timestamp("s"); println!("{}", result); let result = timestamp::timestamp("ms"); println!("{}", result); let result = timestamp::timestamp("us"); println!("{}", result); let result = timestamp::to_date(1660406400); assert_eq!(result, "2022-08-14"); let result = timestamp::to_datetime(1660406400); assert_eq!(result, "2022-08-14 00:00:00"); ttt.end(true); Timer::sleep(1); } }