Files
SkydiveLogs/Front/skydivelogs-app/src/services/date.service.ts
Sébastien André 53ff769188 Ajout d'un système de cache des
requêtes HTTP
2019-11-19 22:42:43 +01:00

27 lines
726 B
TypeScript

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;
}
}