Fix bug in date comparison (#842)

This commit is contained in:
JT 2022-01-24 16:55:45 -05:00 committed by GitHub
parent 988a873466
commit 6e44012a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -886,9 +886,7 @@ impl PartialOrd for Value {
(Value::Float { val: lhs, .. }, Value::Float { val: rhs, .. }) => {
compare_floats(*lhs, *rhs)
}
(Value::Date { val: lhs, .. }, Value::Date { val: rhs, .. }) => {
lhs.date().to_string().partial_cmp(&rhs.date().to_string())
}
(Value::Date { val: lhs, .. }, Value::Date { val: rhs, .. }) => lhs.partial_cmp(rhs),
(Value::String { val: lhs, .. }, Value::String { val: rhs, .. }) => {
lhs.partial_cmp(rhs)
}

View File

@ -161,3 +161,8 @@ fn divide_duration() -> TestResult {
fn divide_filesize() -> TestResult {
run_test(r#"4mb / 4mb"#, "1")
}
#[test]
fn date_comparison() -> TestResult {
run_test(r#"(date now) < ((date now) + 2min)"#, "true")
}