-
Notifications
You must be signed in to change notification settings - Fork 0
/
ord.go
53 lines (43 loc) · 960 Bytes
/
ord.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
package vtime
// Min returns the minimum of given times.
// If no times are given, it returns the current time.
func Min(tt ...Time) Time {
if len(tt) == 0 {
return Now()
}
m := tt[0]
for i := 1; i < len(tt); i++ {
if tt[i].Unix < m.Unix {
m = tt[i]
}
if tt[i].Unix == m.Unix && tt[i].Nano < m.Nano {
m = tt[i]
}
}
return m
}
// Max returns the maximum of given times.
// If no times are given, it returns the current time.
func Max(tt ...Time) Time {
if len(tt) == 0 {
return Now()
}
m := tt[0]
for i := 1; i < len(tt); i++ {
if tt[i].Unix > m.Unix {
m = tt[i]
}
if tt[i].Unix == m.Unix && tt[i].Nano > m.Nano {
m = tt[i]
}
}
return m
}
// Equal returns true if t is equal to u.
func (v Time) Equal(u Time) bool {
return v.Unix == u.Unix && v.Nano == u.Nano
}
// Equal returns true if t is equal to u.
func (v Date) Equal(u Date) bool {
return v.Year == u.Year && v.Month == u.Month && v.Day == u.Day
}