diff --git a/Backend/models/booking_test.go b/Backend/models/booking_test.go index c5f3e67..d344e40 100644 --- a/Backend/models/booking_test.go +++ b/Backend/models/booking_test.go @@ -13,35 +13,35 @@ var testBookingType = models.BookingType{ var testBookings8hrs = []models.Booking{{ CardUID: "aaaa-aaaa", CheckInOut: 1, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), + Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC), BookingType: testBookingType, }, { CardUID: "aaaa-aaaa", CheckInOut: 2, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:00")), + Timestamp: time.Date(2025, 01, 01, 16, 0, 0, 0, time.UTC), BookingType: testBookingType, }} var testBookings6hrs = []models.Booking{{ CardUID: "aaaa-aaaa", CheckInOut: 1, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), + Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC), BookingType: testBookingType, }, { CardUID: "aaaa-aaaa", CheckInOut: 2, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 14:00")), + Timestamp: time.Date(2025, 01, 01, 14, 0, 0, 0, time.UTC), BookingType: testBookingType, }} var testBookings10hrs = []models.Booking{{ CardUID: "aaaa-aaaa", CheckInOut: 1, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), + Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC), BookingType: testBookingType, }, { CardUID: "aaaa-aaaa", CheckInOut: 2, - Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 18:00")), + Timestamp: time.Date(2025, 01, 01, 18, 0, 0, 0, time.UTC), BookingType: testBookingType, }} diff --git a/Backend/models/workDay.go b/Backend/models/workDay.go index 299bf8f..974696e 100644 --- a/Backend/models/workDay.go +++ b/Backend/models/workDay.go @@ -85,7 +85,7 @@ func (d *WorkDay) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (w func getWorkPause(d *WorkDay) (work, pause time.Duration) { //if today calc, else take from db - if helper.IsSameDate(d.Date(), time.Now()) { + if d.workTime == 0 && d.pauseTime == 0 && len(d.Bookings) > 0 { return calcWorkPause(d.Bookings) } else { return d.workTime, d.pauseTime diff --git a/Backend/models/workDay_test.go b/Backend/models/workDay_test.go index 9ad0e6d..a3fe7be 100644 --- a/Backend/models/workDay_test.go +++ b/Backend/models/workDay_test.go @@ -16,10 +16,10 @@ func CatchError[T any](val T, err error) T { } var testWorkDay = models.WorkDay{ - Day: CatchError(time.Parse(time.DateOnly, "2025-01-01")), + Day: time.Date(2025, 01, 01, 0, 0, 0, 0, time.Local), Bookings: testBookings8hrs, - TimeFrom: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")), - TimeTo: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:30")), + TimeFrom: time.Date(2025, 01, 01, 8, 0, 0, 0, time.Local), + TimeTo: time.Date(2025, 01, 01, 16, 30, 0, 0, time.Local), } func TestWorkdayWorktimeDay(t *testing.T) {