Skip to content

Commit a9d0fa3

Browse files
Merge pull request #634 from SELab-2/fix-assignment-dates
[Frontend] - Fix assignment dates
2 parents 68635a4 + 8a95555 commit a9d0fa3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

frontend/src/app/components/create-assignment/create-assignment.component.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export class CreateAssignmentComponent implements OnInit {
8686

8787
create(): void {
8888
const newAssignment: NewAssignment | null = this.extractFormValues();
89-
9089
if (newAssignment) {
9190
this.assignmentService.createAssignment(newAssignment).subscribe((response) => {
9291

@@ -131,11 +130,26 @@ export class CreateAssignmentComponent implements OnInit {
131130
const extraInstructions = this.createForm.get('extraInstructions')?.value;
132131

133132
if (classId && startDate && deadline) {
133+
// Make this safe date so converting to UTC doesn't change the day
134+
// This can be done in a beter way and should be done in the future, but for now this fix works
135+
const safeStart = new Date(
136+
startDate.getFullYear(),
137+
startDate.getMonth(),
138+
startDate.getDate(),
139+
12, 0, 0
140+
);
141+
142+
const safeDeadline = new Date(
143+
deadline.getFullYear(),
144+
deadline.getMonth(),
145+
deadline.getDate(),
146+
12, 0, 0
147+
);
134148
return {
135149
classId,
136150
learningPathId: this.learningPathId,
137-
startDate,
138-
deadline,
151+
startDate: safeStart,
152+
deadline: safeDeadline,
139153
extraInstructions,
140154
name
141155
};

0 commit comments

Comments
 (0)