diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-04-17 11:45:04 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-04-17 11:45:04 -0600 |
commit | 3d75da2eab0d8932ae67fc8e638050c58b159d3a (patch) | |
tree | 60bebbe5f0029e783844e3d82088eaae1ccc6181 /cmd | |
parent | bd8e981124f68ed5dc724f432796d05177faa714 (diff) |
imworkingon: Include more precise timestamps
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/generate/imworkingon.html.tmpl | 4 | ||||
-rw-r--r-- | cmd/generate/main.go | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/cmd/generate/imworkingon.html.tmpl b/cmd/generate/imworkingon.html.tmpl index b73c2d8..d34f141 100644 --- a/cmd/generate/imworkingon.html.tmpl +++ b/cmd/generate/imworkingon.html.tmpl @@ -40,8 +40,8 @@ <a href="#tag-{{ $tag }}">#{{ $tag }}</a> {{/* */}} {{- end }} </div> - <div class="contrib-submitted">Submitted: {{ $contrib.SubmittedAt.Format "2006-01-02" }}</div> - <div class="contrib-updated">{{ if not $contrib.LastUpdatedAt.IsZero }}Last updated: {{ $contrib.LastUpdatedAt.Format "2006-01-02" }}{{ end }}</div> + <div class="contrib-submitted">Submitted: {{ timeTag $contrib.SubmittedAt "2006-01-02" }}</div> + <div class="contrib-updated">{{ if not $contrib.LastUpdatedAt.IsZero }}Last updated: {{ timeTag $contrib.LastUpdatedAt "2006-01-02" }}{{ end }}</div> <div class="contrib-status">Status: {{ $contrib.Status }}</div> <div class="contrib-desc"> {{- $contrib.Desc | md2html }} diff --git a/cmd/generate/main.go b/cmd/generate/main.go index e26120d..7ed67cf 100644 --- a/cmd/generate/main.go +++ b/cmd/generate/main.go @@ -7,6 +7,7 @@ import ( "os" "sort" "strings" + "time" "html/template" @@ -35,6 +36,9 @@ func main() { //go:embed imworkingon.html.tmpl var htmlTmplStr string +var timeTagTmpl = template.Must(template.New("time.tag.tmpl"). + Parse(`<time datetime="{{ .Machine }}" title="{{ .HumanVerbose }}">{{ .HumanPretty }}</time>`)) + func mainWithError() error { contribs, err := ReadContribs("imworkingon/contribs.yml") if err != nil { @@ -63,6 +67,15 @@ func mainWithError() error { tmpl := template.Must(template.New("imworkingon.html.tmpl"). Funcs(template.FuncMap{ + "timeTag": func(ts time.Time, prettyFmt string) (template.HTML, error) { + var out strings.Builder + err := timeTagTmpl.Execute(&out, map[string]string{ + "Machine": ts.Format(time.RFC3339), + "HumanVerbose": ts.Format("2006-01-02 15:04:05Z07:00"), + "HumanPretty": ts.Format(prettyFmt), + }) + return template.HTML(out.String()), err + }, "md2html": MarkdownToHTML, "getUpstream": func(c Contribution) Upstream { // First try any of the documented upstreams. |