mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 07:08:06 +00:00
Fixed date comparison with string date #1537
This commit is contained in:
parent
915ab69922
commit
88a6b20ba5
@ -3,7 +3,6 @@ package yqlib
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v3"
|
yaml "gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@ -80,7 +79,7 @@ func compareScalars(context Context, prefs compareTypePref, lhs *yaml.Node, rhs
|
|||||||
|
|
||||||
isDateTime := lhs.Tag == "!!timestamp"
|
isDateTime := lhs.Tag == "!!timestamp"
|
||||||
// if the lhs is a string, it might be a timestamp in a custom format.
|
// if the lhs is a string, it might be a timestamp in a custom format.
|
||||||
if lhsTag == "!!str" && context.GetDateTimeLayout() != time.RFC3339 {
|
if lhsTag == "!!str" {
|
||||||
_, err := parseDateTime(context.GetDateTimeLayout(), lhs.Value)
|
_, err := parseDateTime(context.GetDateTimeLayout(), lhs.Value)
|
||||||
isDateTime = err == nil
|
isDateTime = err == nil
|
||||||
}
|
}
|
@ -21,6 +21,13 @@ var compareOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[k], (!!bool)::true\n",
|
"D0, P[k], (!!bool)::true\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
expression: `"2022-01-30T15:53:09Z" > "2020-01-30T15:53:09Z"`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (!!bool)::true\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: "a: 5\nb: 4",
|
document: "a: 5\nb: 4",
|
Loading…
Reference in New Issue
Block a user