From 222c2dc33edde6be1b8c1a76afb25ff06aa84117 Mon Sep 17 00:00:00 2001 From: "Stefan J. Betz" Date: Sat, 28 Sep 2024 20:53:19 +0200 Subject: [PATCH] parse long and short dates in index files --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c1dd097..141084a 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,8 @@ import ( ) const FILENAME = "index.txt" -const TIMEFORMAT = "060102150405Z" +const TIMEFORMAT_SHORT = "060102150405Z" +const TIMEFORMAT_LONG = "20060102150405Z" const ( CERT_STATUS = iota CERT_EXPIRED @@ -32,7 +33,11 @@ type Certificates struct { } func (c Certificates) parse_time(timestring string) (*time.Time, error) { - date, err := time.Parse(TIMEFORMAT, timestring) // TODO: Short and Long Timeformat + date, err := time.Parse(TIMEFORMAT_SHORT, timestring) + if err == nil { + return &date, nil + } + date, err = time.Parse(TIMEFORMAT_LONG, timestring) if err != nil { return nil, err }