Ajout d'un système de cache des

requêtes HTTP
This commit is contained in:
Sébastien André
2019-11-19 22:42:43 +01:00
parent fb2699f974
commit 53ff769188
15 changed files with 257 additions and 164 deletions

View File

@@ -0,0 +1,26 @@
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;
}
}