I am trying to implement a calendar using bootstrap-calendar which requires event times in Unix times as milliseconds.
The dateFormat template function casts a timestamp string to a time.Time then returns the string representation according to the layout provided. Is it possible to cast a timestamp to a time.Time without formatting it so I can use the fields and functions on the type?
eg. .Params.eventstart.sec to get the sec field of the time.Time type
or .Params.eventstart.Unix to call the Unix function
If .Params.eventstart.Unix fails it must mean that evenstart isn’t really a proper date. You should have a look at your config format of choice for a solution to that (TOML, JSON, YAML).
That’s what I am asking though. .Params.eventstart is a timestamp, a string in the front matter. What I’m asking for is a way to cast it to a time.Time struct using template functions because I can’t find a way to do it.
On a side note, I just realised Javascript/ECMAscript standards use a time value of Unix time in milliseconds. It would be nice if Go provided a UnixMilli() natively to save converting between Unix() or UnixNano().