From 9ff5307f0d4c6b2cbaf5d1bcf6efd66c56f9d261 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Wed, 24 Jun 2020 23:40:05 -0400 Subject: handling datetime edge case where seconds are missing --- registry/fetch.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/registry/fetch.go b/registry/fetch.go index efa9fcf..630d8f6 100644 --- a/registry/fetch.go +++ b/registry/fetch.go @@ -30,6 +30,8 @@ import ( "time" ) +const rfc3339WithoutSeconds = "2006-01-02T15:04Z07:00" + // GetTwtxt fetches the raw twtxt file data from the user's // provided URL, after validating the URL. If the returned // boolean value is false, the fetched URL is a single user's @@ -188,6 +190,9 @@ func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) { var err error if strings.Contains(columns[0], ".") { thetime, err = time.Parse(time.RFC3339Nano, columns[0]) + } else if strings.Count(columns[0], ":") == 2 { + // this means they're probably not including seconds into the datetime + thetime, err = time.Parse(rfc3339WithoutSeconds, columns[0]) } else { thetime, err = time.Parse(time.RFC3339, columns[0]) } -- cgit 1.4.1-2-gfad0