Masterminds / sprig

Useful template functions for Go templates.
http://masterminds.github.io/sprig/
MIT License
4.07k stars 423 forks source link

dateInZone silently fails when it doesn't understand the parameters passed to it #383

Open CameronGo opened 9 months ago

CameronGo commented 9 months ago

I found myself spinning in circles trying to use dateInZone and getting unexpected results before I realized my docker container did not have the tzdata package installed. My issue is that, rather than returning an error or failing, dateInZone always returns the UTC value of the time object. I further discovered that, if you mistakenly pass a time formatted string to dateInZone, instead of returning an error or failing, it returns the value of (now).

For example, on a system without tzdata, ideally this should return an error, but instead returns the value of now in UTC: {{- dateInZone "2006-01-02T15:04:05Z07:00" (now) "America/New_York" -}}

Also, ideally this should return an error because it was passed a string instead of a time object, but instead returns the value of (now) in UTC: {{- dateInZone "2006-01-02T15:04:05Z07:00" "2020-11-23T12:34:31-05:00" "UTC" -}}