aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-05-27 10:55:57 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2022-05-27 10:55:57 -0700
commit3c9b1dcdf40474396a3b035d548417b84a123164 (patch)
tree08efd3a26e0bfe69c083c664ba4fd1eef0641358
parent61c272e101b6f0444c7b2a666b0b5e828ba6db03 (diff)
Simplify news article timestamping
-rw-r--r--hotline/news.go23
-rw-r--r--hotline/transaction_handlers.go2
2 files changed, 1 insertions, 24 deletions
diff --git a/hotline/news.go b/hotline/news.go
index 7a5c30c..a6b8372 100644
--- a/hotline/news.go
+++ b/hotline/news.go
@@ -5,7 +5,6 @@ import (
"crypto/rand"
"encoding/binary"
"sort"
- "time"
)
type ThreadedNews struct {
@@ -250,25 +249,3 @@ func (s *Server) GetNewsCatByPath(paths []string) map[string]NewsCategoryListDat
}
return cats
}
-
-// News article date field contains this structure:
-// Year 2
-// Milliseconds 2 (seriously?)
-// Seconds 4
-func NewsDate() []byte {
- t := time.Now()
- ms := []byte{0, 0}
- seconds := []byte{0, 0, 0, 0}
-
- year := []byte{0, 0}
- binary.BigEndian.PutUint16(year, uint16(t.Year()))
-
- yearStart := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.Local)
-
- binary.BigEndian.PutUint32(seconds, uint32(t.Sub(yearStart).Seconds()))
-
- date := append(year, ms...)
- date = append(date, seconds...)
-
- return date
-}
diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go
index 5aa6984..2c5a930 100644
--- a/hotline/transaction_handlers.go
+++ b/hotline/transaction_handlers.go
@@ -1140,7 +1140,7 @@ func HandlePostNewsArt(cc *ClientConn, t *Transaction) (res []Transaction, err e
newArt := NewsArtData{
Title: string(t.GetField(fieldNewsArtTitle).Data),
Poster: string(cc.UserName),
- Date: NewsDate(),
+ Date: toHotlineTime(time.Now()),
PrevArt: []byte{0, 0, 0, 0},
NextArt: []byte{0, 0, 0, 0},
ParentArt: append([]byte{0, 0}, t.GetField(fieldNewsArtID).Data...),