import { Injectable } from '@angular/core'; @Injectable() export class DateService { private milliSeconInDay: number; constructor() { this.milliSeconInDay = 1000 * 60 * 60 * 24; } public AddDays(currentDate: Date, nbDays: number): Date { const totalMilliSeconds = nbDays * this.milliSeconInDay; const currentTime = currentDate.getTime(); currentDate.setTime(currentTime + totalMilliSeconds); return currentDate; } public DiffBetweenDates(beginDate: Date, endDate: Date): number { const diffInTime = endDate.getTime() - beginDate.getTime(); const diffInDays = Math.round(diffInTime / (1000 * 3600 * 24)); return diffInDays; } }