about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-06-24 23:40:05 -0400
committerBen Morrison <ben@gbmor.dev>2020-06-24 23:40:05 -0400
commit9ff5307f0d4c6b2cbaf5d1bcf6efd66c56f9d261 (patch)
tree3c66b0c291fbb6b15dcfbcfadf1cb8f7586f7a1b
parent72d297aef47f42c0f7e2f25d86d5ec4de4390f95 (diff)
downloadgetwtxt-9ff5307f0d4c6b2cbaf5d1bcf6efd66c56f9d261.tar.gz
handling datetime edge case where seconds are missing
-rw-r--r--registry/fetch.go5
1 files changed, 5 insertions, 0 deletions
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])
 		}