I have a set of data files in json format. Each one contains a published field in the JSON syntax, the date is represented as a string in RFC3339 format, viz:
"published": "2018-05-09T20:21:51+01:00"
I have tried to use this date in my data templates, showing just the Y-M-D, but
{{ dateFormat "2006-02-01" .published }}
Errors out with:
<dateFormat "2006-01-...>: error calling dateFormat: unable to cast false of type bool to Time
I am aware that I need to convert the string from .published to a time.Time item, I just don’t know where or how to do that. I’ve checked here and on github, but am now at a loss. I know the template is getting the string value, as if I just put {{ .published }} in, that comes up perfectly, but is not acceptable.
It works with frontmatter values, but it doesn’t work with $.Site.Data values.
There’s an old github issue where @bep says that “that isn’t a date, its a string”; but there’s no information there on how to cast that string from a data file into a date.
JSON, YAML etc. has date types. They are not qouted. If you quoute the value, it is a string and you need to convert it from a string to a date (using the date func).