Uses Unix milliseconds support from standard Go lib

This commit is contained in:
Deluan
2024-05-11 19:50:30 -04:00
parent ec68d69d56
commit 30ae468dc1
6 changed files with 10 additions and 43 deletions
+2 -3
View File
@@ -13,7 +13,6 @@ import (
"github.com/navidrome/navidrome/server/public"
"github.com/navidrome/navidrome/server/subsonic/filter"
"github.com/navidrome/navidrome/server/subsonic/responses"
"github.com/navidrome/navidrome/utils"
"github.com/navidrome/navidrome/utils/req"
)
@@ -45,7 +44,7 @@ func (api *Router) getArtistIndex(r *http.Request, mediaFolderId int, ifModified
var indexes model.ArtistIndexes
ms, _ := strconv.ParseInt(l, 10, 64)
lastModified := utils.ToTime(ms)
lastModified := time.UnixMilli(ms)
if lastModified.After(ifModifiedSince) {
indexes, err = api.ds.Artist(ctx).GetIndex()
if err != nil {
@@ -56,7 +55,7 @@ func (api *Router) getArtistIndex(r *http.Request, mediaFolderId int, ifModified
res := &responses.Indexes{
IgnoredArticles: conf.Server.IgnoredArticles,
LastModified: utils.ToMillis(lastModified),
LastModified: lastModified.UnixMilli(),
}
res.Index = make([]responses.Index, len(indexes))
+3 -5
View File
@@ -6,13 +6,11 @@ import (
"net/http"
"time"
"github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/core/scrobbler"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/server/events"
"github.com/navidrome/navidrome/tests"
"github.com/navidrome/navidrome/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@@ -49,9 +47,9 @@ var _ = Describe("MediaAnnotationController", func() {
It("submit all scrobbles with respective times", func() {
time1 := time.Now().Add(-20 * time.Minute)
t1 := utils.ToMillis(time1)
t1 := time1.UnixMilli()
time2 := time.Now().Add(-10 * time.Minute)
t2 := utils.ToMillis(time2)
t2 := time2.UnixMilli()
r := newGetRequest("id=12", "id=34", fmt.Sprintf("time=%d", t1), fmt.Sprintf("time=%d", t2))
_, err := router.Scrobble(r)