-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtime_test.go
More file actions
187 lines (156 loc) · 2.74 KB
/
time_test.go
File metadata and controls
187 lines (156 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package gofaker
import (
"fmt"
"testing"
"time"
)
func ExampleDate() {
Seed(11)
fmt.Println(Date())
// Output: 1977-01-07 04:14:25.685339029 +0000 UTC
}
func BenchmarkDate(b *testing.B) {
for i := 0; i < b.N; i++ {
Date()
}
}
func ExampleDateRange() {
Seed(11)
fmt.Println(DateRange(time.Unix(0, 484633944473634951), time.Unix(0, 1431318744473668209))) // May 10, 1985 years to May 10, 2015
// Output: 2012-02-04 14:10:37.166933216 +0000 UTC
}
func BenchmarkDateRange(b *testing.B) {
for i := 0; i < b.N; i++ {
DateRange(time.Now().AddDate(-30, 0, 0), time.Now())
}
}
func ExampleMonth() {
Seed(11)
fmt.Println(Month())
// Output: January
}
func ExampleWeekDay() {
Seed(11)
fmt.Println(WeekDay())
// Output: Friday
}
func BenchmarkMonth(b *testing.B) {
for i := 0; i < b.N; i++ {
Month()
}
}
func ExampleDay() {
Seed(11)
fmt.Println(Day())
// Output: 12
}
func BenchmarkDay(b *testing.B) {
for i := 0; i < b.N; i++ {
Day()
}
}
func BenchmarkWeekDay(b *testing.B) {
for i := 0; i < b.N; i++ {
WeekDay()
}
}
func ExampleYear() {
Seed(11)
fmt.Println(Year())
// Output: 1977
}
func BenchmarkYear(b *testing.B) {
for i := 0; i < b.N; i++ {
Year()
}
}
func ExampleHour() {
Seed(11)
fmt.Println(Hour())
// Output: 0
}
func BenchmarkHour(b *testing.B) {
for i := 0; i < b.N; i++ {
Hour()
}
}
func ExampleMinute() {
Seed(11)
fmt.Println(Minute())
// Output: 0
}
func BenchmarkMinute(b *testing.B) {
for i := 0; i < b.N; i++ {
Minute()
}
}
func ExampleSecond() {
Seed(11)
fmt.Println(Second())
// Output: 0
}
func BenchmarkSecond(b *testing.B) {
for i := 0; i < b.N; i++ {
Second()
}
}
func ExampleNanoSecond() {
Seed(11)
fmt.Println(NanoSecond())
// Output: 196446360
}
func BenchmarkNanoSecond(b *testing.B) {
for i := 0; i < b.N; i++ {
NanoSecond()
}
}
func ExampleTimeZone() {
Seed(11)
fmt.Println(TimeZone())
// Output: Kaliningrad Standard Time
}
func BenchmarkTimeZone(b *testing.B) {
for i := 0; i < b.N; i++ {
TimeZone()
}
}
func ExampleTimeZoneFull() {
Seed(11)
fmt.Println(TimeZoneFull())
// Output: (UTC+03:00) Kaliningrad, Minsk
}
func BenchmarkTimeZoneFull(b *testing.B) {
for i := 0; i < b.N; i++ {
TimeZoneFull()
}
}
func ExampleTimeZoneAbv() {
Seed(11)
fmt.Println(TimeZoneAbv())
// Output: KST
}
func BenchmarkTimeZoneAbv(b *testing.B) {
for i := 0; i < b.N; i++ {
TimeZoneAbv()
}
}
func ExampleTimeZoneOffset() {
Seed(11)
fmt.Println(TimeZoneOffset())
// Output: 3
}
func BenchmarkTimeZoneOffset(b *testing.B) {
for i := 0; i < b.N; i++ {
TimeZoneOffset()
}
}
func ExampleTimeZoneRegion() {
Seed(11)
fmt.Println(TimeZoneRegion())
// Output: America/Vancouver
}
func BenchmarkTimeZoneRegion(b *testing.B) {
for i := 0; i < b.N; i++ {
TimeZoneRegion()
}
}