Skip to content

Commit

Permalink
[knf] Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Apr 29, 2024
1 parent b6a74be commit e432d67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions knf/knf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"

"github.com/essentialkaos/ek/v12/knf/value"
"github.com/essentialkaos/ek/v12/sliceutil"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -719,6 +720,8 @@ func (c *Config) Is(name string, value any) bool {
return c.GetTS(name).Unix() == t.Unix()
case *time.Location:
return fmt.Sprint(c.GetTZ(name)) == fmt.Sprint(t)
case []string:
return sliceutil.IsEqual(c.GetL(name), t)
}

return false
Expand Down
1 change: 1 addition & 0 deletions knf/knf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ func (s *KNFSuite) TestIs(c *check.C) {
c.Assert(Is("file-mode:test1", os.FileMode(0644)), check.Equals, true)
c.Assert(Is("duration:test2", time.Minute), check.Equals, true)
c.Assert(Is("timestamp:test2", time.Unix(1709629048, 0)), check.Equals, true)
c.Assert(Is("list:test2", []string{"Test1", "Test2"}), check.Equals, true)

l, _ := time.LoadLocation("Europe/Zurich")
c.Assert(Is("timezone:test1", l), check.Equals, true)
Expand Down

0 comments on commit e432d67

Please sign in to comment.