Skip to content

Commit

Permalink
fix parsing of time.Time
Browse files Browse the repository at this point in the history
  • Loading branch information
NoBypass committed Sep 5, 2024
1 parent 2c5cc82 commit adbc513
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import (
"time"
)

func isTime(ts any) bool {
switch ts.(type) {
case time.Time, time.Duration:
return true
default:
return false
}
}

func parseTimes(ts any) any {
switch ts.(type) {
case time.Time:
Expand Down
6 changes: 4 additions & 2 deletions parse_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (

func parseVars(vars map[string]any) map[string]any {
for k, v := range vars {
if isStruct(v) {
if isTime(v) {
vars[k] = parseTimes(v)
} else if isStruct(v) {
vars[k] = structToMap(v)
} else {
vars[k] = parseTimes(v)
vars[k] = v
}
}

Expand Down

0 comments on commit adbc513

Please # to comment.