1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: bug in same day comparison

This commit is contained in:
Ferdinand Mütsch
2022-07-02 00:28:56 +02:00
parent a0f69a371f
commit c5da5e4622
2 changed files with 13 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package services
import (
"github.com/duke-git/lancet/v2/datetime"
"github.com/duke-git/lancet/v2/mathutil"
"github.com/muety/wakapi/config"
"github.com/muety/wakapi/models"
@@ -60,7 +61,7 @@ func (srv *DurationService) Get(from, to time.Time, user *models.User, filters *
continue
}
sameDay := d1.Time.T().Day() == latest.Time.T().Day()
sameDay := datetime.BeginOfDay(d1.Time.T()) == datetime.BeginOfDay(latest.Time.T())
dur := time.Duration(mathutil.Min(
int64(d1.Time.T().Sub(latest.Time.T().Add(latest.Duration))),
int64(HeartbeatDiffThreshold),