-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathtesting.go
94 lines (74 loc) · 1.61 KB
/
testing.go
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
package goment
import "time"
type testParseable struct {
dateTime string
parsedTime time.Time
}
func chicagoLocation() *time.Location {
location, _ := time.LoadLocation("America/Chicago")
return location
}
func simpleUnix(ts int64) *Goment {
lib, _ := Unix(ts)
return lib
}
func simpleUnixNano(ts int64) *Goment {
lib, _ := New(ts)
return lib
}
func simpleFormat(date string, format string) *Goment {
lib, _ := New(date, format)
return lib
}
func simpleFormatLocale(date string, format string, localeCode string) *Goment {
lib, _ := New(date, format, localeCode)
return lib
}
func simpleNow() *Goment {
lib, _ := New()
return lib
}
func simple(dateTime DateTime) *Goment {
lib, _ := New(dateTime)
return lib
}
func simpleLocale(dateTime DateTime, localeCode string) *Goment {
lib, _ := New(dateTime)
lib.SetLocale(localeCode)
return lib
}
func simpleTime(time time.Time) *Goment {
lib, _ := New(time)
return lib
}
func simpleString(time string) *Goment {
lib, _ := New(time)
return lib
}
func simpleGoment(g *Goment) *Goment {
lib, _ := New(g)
return lib
}
func dstForYear(year int) *Goment {
start := simple(DateTime{Year: year, Month: 1})
end := simple(DateTime{Year: year + 1, Month: 1})
current := start.Clone()
var last *Goment
for current.IsBefore(end) {
last = current.Clone()
current.Add(24, "hours")
if last.UTCOffset() != current.UTCOffset() {
end = current.Clone()
current = last.Clone()
break
}
}
for current.IsBefore(end) {
last = current.Clone()
current.Add(1, "hour")
if last.UTCOffset() != current.UTCOffset() {
return last
}
}
return &Goment{}
}