mirror of
https://github.com/danbulant/nushell
synced 2026-05-20 21:08:34 +00:00
added the ability to compare time units like 1hr < 2hr (#3845)
This commit is contained in:
parent
d54d7cc431
commit
e4c282f0a6
1 changed files with 5 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ pub enum CompareValues {
|
|||
String(String, String),
|
||||
Date(DateTime<FixedOffset>, DateTime<FixedOffset>),
|
||||
DateDuration(DateTime<FixedOffset>, BigInt),
|
||||
TimeDuration(BigInt, BigInt),
|
||||
Booleans(bool, bool),
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +105,7 @@ impl CompareValues {
|
|||
right.cmp(left)
|
||||
}
|
||||
CompareValues::Booleans(left, right) => left.cmp(right),
|
||||
CompareValues::TimeDuration(left, right) => left.cmp(right),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -174,6 +176,9 @@ pub fn coerce_compare_primitive(
|
|||
(String(left), FilePath(right)) => {
|
||||
CompareValues::String(left.clone(), right.as_path().display().to_string())
|
||||
}
|
||||
(Duration(left), Duration(right)) => {
|
||||
CompareValues::TimeDuration(left.clone(), right.clone())
|
||||
}
|
||||
_ => return Err((left.type_name(), right.type_name())),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue