Skip to content

Commit

Permalink
Fixed date comparison with string date #1537
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed Feb 2, 2023
1 parent 915ab69 commit 88a6b20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -3,7 +3,6 @@ package yqlib
import (
"fmt"
"strconv"
"time"

yaml "gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -80,7 +79,7 @@ func compareScalars(context Context, prefs compareTypePref, lhs *yaml.Node, rhs

isDateTime := lhs.Tag == "!!timestamp"
// 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)
isDateTime = err == nil
}
Expand Down
Expand Up @@ -21,6 +21,13 @@ var compareOperatorScenarios = []expressionScenario{
"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,
document: "a: 5\nb: 4",
Expand Down

0 comments on commit 88a6b20

Please sign in to comment.