Skip to content

Commit

Permalink
parse long and short dates in index files
Browse files Browse the repository at this point in the history
  • Loading branch information
encbladexp committed Sep 28, 2024
1 parent fb35167 commit 222c2dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 222c2dc

Please sign in to comment.