summary refs log tree commit diff stats
path: root/cache/index.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-13 22:43:45 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-13 22:43:45 -0400
commit9f141b4a31c5c94275d5010cc92e9631237ab0d8 (patch)
tree1e662f56f9859e70bc2571346f43c4f3820287eb /cache/index.go
parentdf79157454391a17bb9276cf44d9141d1a29b8f6 (diff)
downloadgetwtxt-9f141b4a31c5c94275d5010cc92e9631237ab0d8.tar.gz
recording user addition date in time.Time and RFC3339
Diffstat (limited to 'cache/index.go')
-rw-r--r--cache/index.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cache/index.go b/cache/index.go
index e0a3dd0..641e6dc 100644
--- a/cache/index.go
+++ b/cache/index.go
@@ -1,5 +1,10 @@
 package cache
 
+import (
+	"log"
+	"time"
+)
+
 // NewUserIndex returns a new instance of a user index
 func NewUserIndex() *UserIndex {
 	return &UserIndex{}
@@ -7,8 +12,12 @@ func NewUserIndex() *UserIndex {
 
 // AddUser inserts a new user into the index. The *Data struct only contains the nickname.)
 func (index UserIndex) AddUser(nick string, url string) {
+	rfc3339date, err := time.Now().MarshalText()
+	if err != nil {
+		log.Printf("Error formatting user add time as RFC3339: %v\n", err)
+	}
 	imutex.Lock()
-	index[url] = &Data{nick: nick}
+	index[url] = &Data{nick: nick, date: time.Now(), apidate: rfc3339date}
 	imutex.Unlock()
 }