You've already forked parse_datetime
mirror of
https://github.com/uutils/parse_datetime.git
synced 2026-06-10 16:13:15 -07:00
e9b8f7a43e
Replace hand-rolled format_offset_colon / format_for_assert helpers with the new Display impls. Replace local expect_in_range_datetime test helpers with ParsedDateTime::expect_in_range().
30 lines
867 B
Rust
30 lines
867 B
Rust
// For the full copyright and license information, please view the LICENSE
|
|
// file that was distributed with this source code.
|
|
|
|
use std::env;
|
|
|
|
use jiff::Zoned;
|
|
use parse_datetime::{parse_datetime, parse_datetime_at_date};
|
|
|
|
pub fn check_absolute(input: &str, expected: &str) {
|
|
env::set_var("TZ", "UTC0");
|
|
|
|
let parsed = match parse_datetime(input) {
|
|
Ok(v) => v,
|
|
Err(e) => panic!("Failed to parse date from value '{input}': {e}"),
|
|
};
|
|
|
|
assert_eq!(parsed.to_string(), expected, "Input value: {input}");
|
|
}
|
|
|
|
pub fn check_relative(now: Zoned, input: &str, expected: &str) {
|
|
env::set_var("TZ", "UTC0");
|
|
|
|
let parsed = match parse_datetime_at_date(now, input) {
|
|
Ok(v) => v,
|
|
Err(e) => panic!("Failed to parse date from value '{input}': {e}"),
|
|
};
|
|
|
|
assert_eq!(parsed.to_string(), expected, "Input value: {input}");
|
|
}
|