| 1 |
// For the full copyright and license information, please view the LICENSE |
| 2 |
// file that was distributed with this source code. |
| 3 |
|
| 4 |
use std::env; |
| 5 |
|
| 6 |
use jiff::Zoned; |
| 7 |
use parse_datetime::{parse_datetime, parse_datetime_at_date}; |
| 8 |
|
| 9 |
pub fn check_absolute(input: &str, expected: &str) { |
| 10 |
env::set_var("TZ", "UTC0"); |
| 11 |
|
| 12 |
let parsed = match parse_datetime(input) { |
| 13 |
Ok(v) => v, |
| 14 |
Err(e) => panic!("Failed to parse date from value '{input}': {e}"), |
| 15 |
}; |
| 16 |
|
| 17 |
assert_eq!(parsed.to_string(), expected, "Input value: {input}"); |
| 18 |
} |
| 19 |
|
| 20 |
pub fn check_relative(now: Zoned, input: &str, expected: &str) { |
| 21 |
env::set_var("TZ", "UTC0"); |
| 22 |
|
| 23 |
let parsed = match parse_datetime_at_date(now, input) { |
| 24 |
Ok(v) => v, |
| 25 |
Err(e) => panic!("Failed to parse date from value '{input}': {e}"), |
| 26 |
}; |
| 27 |
|
| 28 |
assert_eq!(parsed.to_string(), expected, "Input value: {input}"); |
| 29 |
} |