Completed
Push — master ( e5af60...2118df )
by Mathieu
23s queued 13s
created

server/src/Application/Common/MonthDate.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 27
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 22
mnd 0
bc 0
fnc 2
dl 0
loc 27
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A MonthDate.getLastDay 0 7 1
A MonthDate.getFirstDay 0 12 1
1
import { lastDayOfMonth } from 'date-fns';
2
3
export class MonthDate {
4
  constructor(public readonly year: number, public readonly month: number) {}
5
6
  getFirstDay(): Date {
7
    const date = new Date();
8
    date.setFullYear(this.year);
9
    date.setMonth(this.month - 1);
10
    date.setHours(0);
11
    date.setMinutes(0);
12
    date.setSeconds(0);
13
    date.setMilliseconds(0);
14
    date.setDate(1);
15
16
    return date;
17
  }
18
19
  getLastDay(): Date {
20
    const date = new Date();
21
    date.setFullYear(this.year);
22
    date.setMonth(this.month - 1);
23
24
    return lastDayOfMonth(date);
25
  }
26
}
27