Skip to content

Commit

Permalink
feat udte
Browse files Browse the repository at this point in the history
  • Loading branch information
sansan88 committed Sep 14, 2023
1 parent 0e1a0bc commit 7040290
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<ion-modal [keepContentsMounted]="true">
<ng-template>
<ion-datetime presentation="time" id="timeFrom" value="{{training.timeFrom}}" [(ngModel)]="training.timeFrom"></ion-datetime>
<ion-datetime presentation="time" id="timeFrom" minuteValues="0,5,10,15,20,25,30,35,40,45,50,55" value="{{training.timeFrom}}" [(ngModel)]="training.timeFrom"></ion-datetime>
</ng-template>
</ion-modal>
</ion-item>
Expand All @@ -69,7 +69,7 @@

<ion-modal [keepContentsMounted]="true">
<ng-template>
<ion-datetime presentation="time" id="timeTo" value="{{training.timeTo}}" [(ngModel)]="training.timeTo"></ion-datetime>
<ion-datetime presentation="time" id="timeTo" minuteValues="0,5,10,15,20,25,30,35,40,45,50,55" value="{{training.timeTo}}" [(ngModel)]="training.timeTo"></ion-datetime>
</ng-template>
</ion-modal>
</ion-item>
Expand Down
44 changes: 33 additions & 11 deletions src/app/pages/training/training-create/training-create.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,41 @@ export class TrainingCreatePage implements OnInit {

async createTraining() {
//Set Hours/Minutes of endDate to TimeFrom of training
const calculatedDate = new Date(this.training.endDate);
calculatedDate.setHours(new Date(this.training.timeFrom).getHours());
calculatedDate.setMinutes(new Date(this.training.timeFrom).getMinutes());
calculatedDate.setSeconds(0);
calculatedDate.setMilliseconds(0);
this.training.endDate = calculatedDate.toISOString();

console.log(`Start Date before calculation: ${this.training.startDate}`);
const calculatedStartDate = new Date(this.training.startDate);
calculatedDate.setHours(new Date(this.training.timeFrom).getHours());
calculatedDate.setMinutes(new Date(this.training.timeFrom).getMinutes());
calculatedDate.setSeconds(0);
calculatedDate.setMilliseconds(0);
calculatedStartDate.setHours(new Date(this.training.timeFrom).getHours());
calculatedStartDate.setMinutes(new Date(this.training.timeFrom).getMinutes());
calculatedStartDate.setSeconds(0);
calculatedStartDate.setMilliseconds(0);
this.training.startDate = calculatedStartDate.toISOString();
console.log(`Start Date after calculation: ${this.training.startDate}`);

console.log(`End Date before calculation: ${this.training.endDate}`);
const calcualtedEndDate = new Date(this.training.endDate);
calcualtedEndDate.setHours(new Date(this.training.timeFrom).getHours());
calcualtedEndDate.setMinutes(new Date(this.training.timeFrom).getMinutes());
calcualtedEndDate.setSeconds(0);
calcualtedEndDate.setMilliseconds(0);
this.training.endDate = calcualtedEndDate.toISOString();
console.log(`End Date after calculation: ${this.training.endDate}`);

const calculatedTimeFrom = new Date(this.training.timeFrom);
calculatedTimeFrom.setDate(new Date(this.training.startDate).getDate());
calculatedTimeFrom.setMonth(new Date(this.training.startDate).getMonth());
calculatedTimeFrom.setFullYear(new Date(this.training.startDate).getFullYear());
calculatedTimeFrom.setSeconds(0);
calculatedTimeFrom.setMilliseconds(0);
this.training.timeFrom = calculatedTimeFrom.toISOString();

const calculatedTimeTo = new Date(this.training.timeTo);
calculatedTimeTo.setDate(new Date(this.training.startDate).getDate());
calculatedTimeTo.setMonth(new Date(this.training.startDate).getMonth());
calculatedTimeTo.setFullYear(new Date(this.training.startDate).getFullYear());
calculatedTimeTo.setSeconds(0);
calculatedTimeTo.setMilliseconds(0);
this.training.timeTo = calculatedTimeTo.toISOString();

delete this.training.attendees;

this.trainingService.setCreateTraining(this.training, this.user);
return this.modalCtrl.dismiss({}, "confirm");
Expand Down

0 comments on commit 7040290

Please sign in to comment.