From b772eb66f2862fbecd6c9fd024381299baaabb66 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 21 Nov 2016 11:33:09 -0500 Subject: better time formatting/markup --- crtsh-pem2html.go | 25 +++++++++++++++++++------ tls-pem2html.go | 23 ++++++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/crtsh-pem2html.go b/crtsh-pem2html.go index 63249c3..f856ffb 100644 --- a/crtsh-pem2html.go +++ b/crtsh-pem2html.go @@ -28,8 +28,10 @@ func handleBool(ok bool, str string, a ...interface{}) { var tmpl = template.Must(template.New("pem2html"). Funcs(template.FuncMap{ - "red": red, - "green": green, + "red": red, + "green": green, + "time": fTime, + "datetime": fDateTime, }).Parse(` @@ -74,6 +76,9 @@ var tmpl = template.Must(template.New("pem2html"). height: 100%; color: black; } + time .time { + display: none + } @@ -81,7 +86,7 @@ var tmpl = template.Must(template.New("pem2html"). @@ -92,9 +97,9 @@ var tmpl = template.Must(template.New("pem2html"). {{range $cert := .certs}} - - - + + + @@ -104,6 +109,14 @@ var tmpl = template.Must(template.New("pem2html"). `)) +func fTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("")) +} + +func fDateTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("")) +} + func getNow() time.Time { stat, err := os.Stdin.Stat() if err == nil { diff --git a/tls-pem2html.go b/tls-pem2html.go index be93b44..6cecbf6 100644 --- a/tls-pem2html.go +++ b/tls-pem2html.go @@ -28,8 +28,10 @@ func handleBool(ok bool, str string, a ...interface{}) { var tmpl = template.Must(template.New("pem2html"). Funcs(template.FuncMap{ - "red": red, - "green": green, + "red": red, + "green": green, + "time": fTime, + "datetime": fDateTime, }).Parse(` @@ -77,6 +79,9 @@ var tmpl = template.Must(template.New("pem2html"). height: 100%; color: black; } + time .time { + display: none + } @@ -84,7 +89,7 @@ var tmpl = template.Must(template.New("pem2html").
-

CT log (Updated {{.now.Local.Format "2006-01-02 15:04:05"}})

+

CT log (Updated {{.now | datetime}})

Logged
{{$cert.Updated.Local.Format "2006-01-02 15:04:05"}}{{$cert.X509.NotBefore.Local.Format "2006-01-02"}}{{$cert.X509.NotAfter.Local.Format "2006-01-02"}}{{$cert.Updated | datetime}}{{$cert.X509.NotBefore | time}}{{$cert.X509.NotAfter | time}} {{$cert.X509.Subject.CommonName}} {{$cert.X509.Issuer.Organization}}
@@ -94,8 +99,8 @@ var tmpl = template.Must(template.New("pem2html"). {{range $cert := .certs}} - - + + @@ -105,6 +110,14 @@ var tmpl = template.Must(template.New("pem2html"). `)) +func fTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("")) +} + +func fDateTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("")) +} + func getNow() time.Time { stat, err := os.Stdin.Stat() if err == nil { -- cgit v1.1-4-g5e80
-

Live Certs (Updated {{.now.Local.Format "2006-01-02 15:04:05"}})

+

Live Certs (Updated {{.now | datetime}})

NotBefore
{{$cert.X509.NotBefore.Local.Format "2006-01-02"}}{{$cert.X509.NotAfter.Local.Format "2006-01-02"}}{{$cert.X509.NotBefore | time}}{{$cert.X509.NotAfter | time}} {{$cert.X509.Subject.CommonName | html}} {{$cert.Socket | html}}