From ab9c579765e32416a2ef5ef73dddeccc0ed0e78f Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Tue, 16 May 2023 20:30:23 +0200 Subject: [PATCH] #16: Setting end date automatically if end date is before start --- src/app/components/event/event.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/components/event/event.component.ts b/src/app/components/event/event.component.ts index b75d656..b70213a 100644 --- a/src/app/components/event/event.component.ts +++ b/src/app/components/event/event.component.ts @@ -46,7 +46,6 @@ export class EventComponent implements OnInit { // Check required fields if( this.isNullOrBlank(this.event.name) || - this.isNullOrBlank(this.event.createdBy) || this.event.startDateTime == undefined || this.event.endDateTime == undefined ) { @@ -96,6 +95,14 @@ export class EventComponent implements OnInit { this.event.startDateTime.setMinutes(newTime.getMinutes()); this.event.startDateTime.setSeconds(0); } + + // Set end date accordingly if behind start date + if(this.event) { + if(this.event.endDateTime < this.event.startDateTime) { + this.newEndDate = this.serializeDate(this.event.startDateTime); + this.newEndTime = this.serializeTime(this.event.startDateTime); + } + } } setEndDateTime() {