summary refs log tree commit diff stats
path: root/registry/fetch.go
diff options
context:
space:
mode:
Diffstat (limited to 'registry/fetch.go')
-rw-r--r--registry/fetch.go15
1 files changed, 7 insertions, 8 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) {