src/Application/Common/MonthDate.ts   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 15
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
A MonthDate.getFirstDay 0 3 1
A MonthDate.getLastDay 0 4 1
1
import { lastDayOfMonth, format } from 'date-fns';
2
3
export class MonthDate {
4
  constructor(public readonly year: number, public readonly month: number) {}
5
6
  getFirstDay(): Date {
7
    return new Date(`${this.year}-${String(this.month).padStart(2, '0')}-01`);
8
  }
9
10
  getLastDay(): Date {
11
    const localDate = lastDayOfMonth(this.getFirstDay());
12
    return new Date(format(localDate, 'yyyy-MM-dd'));
13
  }
14
}
15