Passed
Push — master ( ccc043...918b18 )
by Serhii
03:34 queued 01:49
created

tests.getLastDayOfMonth   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
ccs 1
cts 1
cp 1
crap 1
nop 1
1
package tests
2
3
import (
4
	"time"
5
)
6
7
const (
8
	second time.Duration = time.Second
9
	minute time.Duration = time.Minute
10
	hour   time.Duration = time.Hour
11
	day    time.Duration = hour * 24
12
	week   time.Duration = day * 7
13
	month  time.Duration = day * 30
14
	year   time.Duration = day * 365
15
)
16
17
func subTime(duration time.Duration) time.Time {
18 1
	return time.Now().Add(-duration)
19
}
20
21
func subSeconds(duration time.Duration) time.Time {
22 1
	return subTime(second * duration)
23
}
24
25
func subMinutes(duration time.Duration) time.Time {
26 1
	return subTime(minute * duration)
27
}
28
29
func subHours(duration time.Duration) time.Time {
30 1
	return subTime(hour * duration)
31
}
32
33
func subDays(duration time.Duration) time.Time {
34 1
	return subTime(day * duration)
35
}
36
37
func subWeeks(duration time.Duration) time.Time {
38 1
	return subTime(week * duration)
39
}
40
41
func subMonths(duration time.Duration) time.Time {
42 1
	return subTime(month * duration)
43
}
44
45
func subYears(duration time.Duration) time.Time {
46 1
	return subTime(year * duration)
47
}
48