I am trying to implement a calendar using bootstrap-calendar which requires event times in Unix times as milliseconds.
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?
.Params.eventstart.sec to get the sec field of the
.Params.eventstart.Unix to call the Unix function
I can only find references to
You gen get to any time.Time attribute and func that is exported (i.e. starts with capital letter), e.g.:
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.
If I remember correctly, we have no func for that … but I would make it “not to be a string in front matter”.
That said, I would welcome a
time template func (name in line with int and string funcs).
Yeah I’ve been playing around with YAML tags but it has made no difference
start: !!timestamp 2016-05-28T10:30:00.00+10:00
end: !!timestamp 2016-05-28T14:30:00.00+10:00
+1 for the time func, though I may have stuffed up the merge request
I think the Go people have bigger time struggles than to worry about converting between nano and milliseconds, see:
This is the 5th time or something in a week that Apple has delayed the 1.7 Go release by changing the Gettimeofday syscall…