Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local test date since backend can't handle UTC #776 #778

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/shared/services/courses-rest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/app/shared/services/courses-rest.service.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -107,7 +108,7 @@ export class CoursesRestService extends RestService<typeof Course> {
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,
Expand Down Expand Up @@ -136,7 +137,7 @@ export class CoursesRestService extends RestService<typeof Course> {
{
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,
Expand Down
Loading