about summary refs log tree commit diff stats
path: root/registry
diff options
context:
space:
mode:
Diffstat (limited to 'registry')
-rw-r--r--registry/fetch.go15
-rw-r--r--registry/fetch_test.go11
2 files changed, 7 insertions, 19 deletions
diff --git a/registry/fetch.go b/registry/fetch.go
index 9adf4ec..efa9fcf 100644
--- a/registry/fetch.go
+++ b/registry/fetch.go
@@ -25,7 +25,6 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
-	"regexp"
 	"strings"
 	"sync"
 	"time"
@@ -185,8 +184,13 @@ func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) {
 			return nil, fmt.Errorf("improperly formatted data in twtxt file")
 		}
 
-		normalizedDatestamp := fixTimestamp(columns[0])
-		thetime, err := time.Parse(time.RFC3339, normalizedDatestamp)
+		var thetime time.Time
+		var err error
+		if strings.Contains(columns[0], ".") {
+			thetime, err = time.Parse(time.RFC3339Nano, columns[0])
+		} else {
+			thetime, err = time.Parse(time.RFC3339, columns[0])
+		}
 		if err != nil {
 			erz = append(erz, []byte(fmt.Sprintf("unable to retrieve date: %v\n", err))...)
 		}
@@ -200,11 +204,6 @@ func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) {
 	return timemap, fmt.Errorf("%v", string(erz))
 }
 
-func fixTimestamp(ts string) string {
-	normalizeTimestamp := regexp.MustCompile(`[\+][\d][\d][:][\d][\d]`)
-	return strings.TrimSpace(normalizeTimestamp.ReplaceAllString(ts, "Z"))
-}
-
 // ParseRegistryTwtxt takes output from a remote registry and outputs
 // the accessible user data via a slice of Users.
 func ParseRegistryTwtxt(twtxt []byte) ([]*User, error) {
diff --git a/registry/fetch_test.go b/registry/fetch_test.go
index 4eab2a4..0bf7920 100644
--- a/registry/fetch_test.go
+++ b/registry/fetch_test.go
@@ -273,14 +273,3 @@ var timestampCases = []struct {
 		expected: "2020-01-14T00:19:45.092344Z",
 	},
 }
-
-func Test_fixTimestamp(t *testing.T) {
-	for _, tt := range timestampCases {
-		t.Run(tt.name, func(t *testing.T) {
-			tsout := fixTimestamp(tt.orig)
-			if tsout != tt.expected {
-				t.Errorf("Failed :: %s :: got %s expected %s", tt.name, tsout, tt.expected)
-			}
-		})
-	}
-}