diff options
| author | Shulhan <ms@kilabit.info> | 2020-10-08 19:21:42 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2020-10-08 19:21:42 +0700 |
| commit | ecaec9debf531309bc1f0d21633aabe490dfbb96 (patch) | |
| tree | 53b14fb247ec2d1406c22c6b7825080f12acd5aa /filehtml.go | |
| parent | 396d45eee46ad4dcf33c224053e79373cf881f77 (diff) | |
| download | ciigo-ecaec9debf531309bc1f0d21633aabe490dfbb96.tar.xz | |
all: check for zero last updated when unpacking adoc metadata
If the date is zero ("0001-01-01 ...") reset it to empty string and
do not render it on HTML output.
Diffstat (limited to 'filehtml.go')
| -rw-r--r-- | filehtml.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/filehtml.go b/filehtml.go index c3f06e6..dc4384d 100644 --- a/filehtml.go +++ b/filehtml.go @@ -8,7 +8,9 @@ import ( "fmt" "html/template" "strings" + "time" + "github.com/bytesparadise/libasciidoc/pkg/configuration" "github.com/bytesparadise/libasciidoc/pkg/types" ) @@ -90,4 +92,16 @@ func (fhtml *fileHTML) unpackAdocMetadata(doc types.Document, md types.Metadata) fhtml.Metadata[k] = fmt.Sprintf("%v", v) } } + + if len(fhtml.Date) == 0 { + return + } + + dt, err := time.Parse(configuration.LastUpdatedFormat, fhtml.Date) + if err == nil { + if dt.IsZero() { + fhtml.Date = "" + } + return + } } |
