mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-10 02:07:05 +02:00
Simplify timestamp comparisons
This commit is contained in:
parent
389c7c6ec1
commit
c305b6c7e3
7 changed files with 14 additions and 14 deletions
|
@ -121,7 +121,7 @@ type ListensList []Listen
|
|||
func (l ListensList) NewerThan(t time.Time) ListensList {
|
||||
result := make(ListensList, 0, len(l))
|
||||
for _, item := range l {
|
||||
if item.ListenedAt.Unix() > t.Unix() {
|
||||
if item.ListenedAt.After(t) {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func (l ListensList) Len() int {
|
|||
}
|
||||
|
||||
func (l ListensList) Less(i, j int) bool {
|
||||
return l[i].ListenedAt.Unix() < l[j].ListenedAt.Unix()
|
||||
return l[j].ListenedAt.After(l[i].ListenedAt)
|
||||
}
|
||||
|
||||
func (l ListensList) Swap(i, j int) {
|
||||
|
@ -147,7 +147,7 @@ func (l LovesList) Len() int {
|
|||
}
|
||||
|
||||
func (l LovesList) Less(i, j int) bool {
|
||||
return l[i].Created.Unix() < l[j].Created.Unix()
|
||||
return l[j].Created.After(l[i].Created)
|
||||
}
|
||||
|
||||
func (l LovesList) Swap(i, j int) {
|
||||
|
@ -190,7 +190,7 @@ type ImportResult struct {
|
|||
|
||||
// Sets LastTimestamp to newTime, if newTime is newer than LastTimestamp
|
||||
func (i *ImportResult) UpdateTimestamp(newTime time.Time) {
|
||||
if newTime.Unix() > i.LastTimestamp.Unix() {
|
||||
if newTime.After(i.LastTimestamp) {
|
||||
i.LastTimestamp = newTime
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue