diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-06-25 00:01:10 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-06-25 00:01:10 -0400 |
commit | 525f339c80d6e8662d5a981bcecd3910dbe5987a (patch) | |
tree | fd20407bc7e0d34fc69c1f1cd253d6814f691560 /registry/fetch.go | |
parent | 9ff5307f0d4c6b2cbaf5d1bcf6efd66c56f9d261 (diff) | |
download | getwtxt-525f339c80d6e8662d5a981bcecd3910dbe5987a.tar.gz |
dealing with time is hard v0.4.15
Diffstat (limited to 'registry/fetch.go')
-rw-r--r-- | registry/fetch.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/registry/fetch.go b/registry/fetch.go index 630d8f6..07578b8 100644 --- a/registry/fetch.go +++ b/registry/fetch.go @@ -186,11 +186,23 @@ func ParseUserTwtxt(twtxt []byte, nickname, urlKey string) (TimeMap, error) { return nil, fmt.Errorf("improperly formatted data in twtxt file") } + noSeconds := false + count := strings.Count(columns[0], ":") + + if strings.Contains(columns[0], "Z") { + split := strings.Split(columns[0], "Z") + if len(split[1]) > 0 && count == 2 { + noSeconds = true + } + } else if count == 2 { + noSeconds = true + } + var thetime time.Time var err error if strings.Contains(columns[0], ".") { thetime, err = time.Parse(time.RFC3339Nano, columns[0]) - } else if strings.Count(columns[0], ":") == 2 { + } else if noSeconds { // this means they're probably not including seconds into the datetime thetime, err = time.Parse(rfc3339WithoutSeconds, columns[0]) } else { |