Completed
Push — master ( 7858c3...314b6e )
by Mathieu
13s queued 11s
created

DateUtilsAdapter.getCurrentDateToISOString   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import {Injectable} from '@nestjs/common';
2
import {
3
  format as fnsFormat,
4
  isWeekend as fnsIsWeekend,
5
  getDaysInMonth as fnsGetDaysInMonth
6
} from 'date-fns';
7
import {IDateUtils} from 'src/Application/IDateUtils';
8
9
@Injectable()
10
export class DateUtilsAdapter implements IDateUtils {
11
  constructor(private readonly date: Date = new Date()) {}
12
13
  public format(date: Date, format: string): string {
14
    return fnsFormat(date, format);
15
  }
16
17
  public getDaysInMonth(date: Date): number {
18
    return fnsGetDaysInMonth(date);
19
  }
20
21
  public isWeekend(date: Date): boolean {
22
    return fnsIsWeekend(date);
23
  }
24
25
  public getCurrentDate(): Date {
26
    return this.date;
27
  }
28
29
  public getCurrentDateToISOString(): string {
30
    return this.date.toISOString();
31
  }
32
}
33