From 02561a6a45959f34bbd73d3c84995cff2a40d922 Mon Sep 17 00:00:00 2001 From: Mathis Hofer Date: Thu, 9 Jan 2025 09:29:08 +0100 Subject: [PATCH] Use local test date since backend can't handle UTC #776 --- src/app/shared/services/courses-rest.service.spec.ts | 4 ++-- src/app/shared/services/courses-rest.service.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/shared/services/courses-rest.service.spec.ts b/src/app/shared/services/courses-rest.service.spec.ts index 4028f4238..20a9ce42a 100644 --- a/src/app/shared/services/courses-rest.service.spec.ts +++ b/src/app/shared/services/courses-rest.service.spec.ts @@ -174,7 +174,7 @@ describe("CoursesRestService", () => { isEqual(req.body, { Tests: [ { - Date: new Date("2022-02-09T00:00:00"), + Date: "2022-02-09T00:00:00", Designation: "designation", Weight: 33, IsPointGrading: false, @@ -215,7 +215,7 @@ describe("CoursesRestService", () => { { Id: testId, Designation: "updated designation", - Date: new Date("2022-02-09T00:00:00"), + Date: "2022-02-09T00:00:00", Weight: 33, IsPointGrading: false, MaxPoints: null, diff --git a/src/app/shared/services/courses-rest.service.ts b/src/app/shared/services/courses-rest.service.ts index d9c3f67d8..6603d89f3 100644 --- a/src/app/shared/services/courses-rest.service.ts +++ b/src/app/shared/services/courses-rest.service.ts @@ -1,5 +1,6 @@ import { HttpClient } from "@angular/common/http"; import { Inject, Injectable } from "@angular/core"; +import { format, startOfDay } from "date-fns"; import * as t from "io-ts"; import { Observable, map, of, switchMap, throwError } from "rxjs"; import { @@ -107,7 +108,7 @@ export class CoursesRestService extends RestService { const body = { Tests: [ { - Date: date, + Date: format(startOfDay(date), "yyyy-MM-dd'T'HH:mm:ss"), // The backend cannot handle correct ISO date strings in UTC, so use a pseudo date string in local timezone Designation: designation, Weight: weight, IsPointGrading: isPointGrading, @@ -136,7 +137,7 @@ export class CoursesRestService extends RestService { { Id: id, Designation: designation, - Date: date, + Date: format(startOfDay(date), "yyyy-MM-dd'T'HH:mm:ss"), // The backend cannot handle correct ISO date strings in UTC, so use a pseudo date string in local timezone Weight: weight, IsPointGrading: isPointGrading, MaxPoints: maxPoints,