[develop | DONE | ADDED]: Added method get calcCurrentMonth() to calculate and display current month of the project life, if status is on going (project has started and not yet ended).

This commit is contained in:
Konstantina Galouni 2024-04-16 12:28:14 +03:00
parent eeb63a2de9
commit cc43504306
1 changed files with 15 additions and 1 deletions

View File

@ -89,7 +89,7 @@ import {RouterHelper} from "../../utils/routerHelper.class";
</ng-container>
</span>
<ng-container *ngIf="status">
<span>{{status}}</span>
<span>{{status}} <ng-container *ngIf="currentDate <= endDate && currentDate >= startDate">(M{{calcCurrentMonth}})</ng-container></span>
</ng-container>
<ng-container *ngIf="date">
<span>{{date | date: 'dd MMM yyyy': 'UTC'}}</span>
@ -364,4 +364,18 @@ export class EntityMetadataComponent {
this.projectsModal.open();
}
}
public get calcCurrentMonth() {
let currentDate = new Date(this.currentDate);
let startDate = new Date(this.startDate);
var months;
months = (currentDate.getFullYear() - startDate.getFullYear()) * 12;
months -= startDate.getMonth();
months += currentDate.getMonth();
if(startDate.getDate() > currentDate.getDate()) {
months--;
}
return months <= 0 ? 0 : months+1;
}
}