From cc435043060dec17966eddea9cd5b931d62e8ddc Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 16 Apr 2024 12:28:14 +0300 Subject: [PATCH] [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). --- .../landing-utils/entity-metadata.component.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/landingPages/landing-utils/entity-metadata.component.ts b/landingPages/landing-utils/entity-metadata.component.ts index 4060446c..d27eb26e 100644 --- a/landingPages/landing-utils/entity-metadata.component.ts +++ b/landingPages/landing-utils/entity-metadata.component.ts @@ -89,7 +89,7 @@ import {RouterHelper} from "../../utils/routerHelper.class"; - {{status}} + {{status}} (M{{calcCurrentMonth}}) {{date | date: 'dd MMM yyyy': 'UTC'}} @@ -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; + } } \ No newline at end of file