go-jira / jira

simple jira command line client in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage of the dateFormat template function

DBX12 opened this issue · comments

commented

What I want to achieve:

I want to show the date and time in the format 02.01.2006 15:04

What I tried:

Using this template:

{{- if .fields.customfield_11221 -}}
  {{- cell .fields.customfield_11221 | dateFormat "02.01.2006 15:04" -}}
{{- else -}}
  {{- cell "<None>" -}}
{{- end -}}

An example value of the field .fields.customfield_11221 rendered without the dateFormat function looks like this 2021-06-01T10:30:00.000+0200.

What I get:

ERROR Invalid Usage: template: gojira:15:41: executing "gojira" at <dateFormat "02.01.2006 15:04">: error calling dateFormat: parsing time "" as "2006-01-02T15:04:05.000-0700": cannot parse "" as "2006"

The question

How do I use the dateFormat template function correctly?

I'd like to second this and extend scope. It's not clear how to use templates and how should figure this out. There is no link to documentation. Bundled templates use "age" function for instance:
{{ .fields.created | age }}
but where does it come from? Is it from golang template engine? Is it from go-jira extensions? What are the other functions that I can use? Googling for "golang templates age" does not provide useful results.