20 lines
481 B
TypeScript
20 lines
481 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import * as moment from 'moment';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class DateUtilsService {
|
|
public static addDaysToDate(days: number, date: Date): Date {
|
|
return moment(date).add(days, 'days').toDate();
|
|
}
|
|
|
|
public static diffInDays(dateLeft: Date, dateRight: Date): number {
|
|
return moment(dateLeft).diff(moment(dateRight));
|
|
}
|
|
|
|
public static formatDate(date): string {
|
|
return moment(date).format('yyyy-MM-dd');
|
|
}
|
|
}
|