forked from jinzhu/now
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
103 lines (79 loc) · 2.13 KB
/
main.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
95
96
97
98
99
100
101
102
103
// Package now is a time toolkit for golang.
//
// More details README here: https://github.com/jinzhu/now
//
// import "github.com/jinzhu/now"
//
// now.BeginningOfMinute() // 2013-11-18 17:51:00 Mon
// now.BeginningOfDay() // 2013-11-18 00:00:00 Mon
// now.EndOfDay() // 2013-11-18 23:59:59.999999999 Mon
package now
import "time"
var FirstDayMonday bool
var TimeFormats = []string{"1/2/2006", "1/2/2006 15:4:5", "2006-1-2 15:4:5", "2006-1-2 15:4", "2006-1-2", "1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST"}
type Now struct {
time.Time
}
func New(t time.Time) *Now {
return &Now{t}
}
func BeginningOfMinute() time.Time {
return New(time.Now()).BeginningOfMinute()
}
func BeginningOfHour() time.Time {
return New(time.Now()).BeginningOfHour()
}
func BeginningOfDay() time.Time {
return New(time.Now()).BeginningOfDay()
}
func BeginningOfWeek() time.Time {
return New(time.Now()).BeginningOfWeek()
}
func BeginningOfMonth() time.Time {
return New(time.Now()).BeginningOfMonth()
}
func BeginningOfQuarter() time.Time {
return New(time.Now()).BeginningOfQuarter()
}
func BeginningOfYear() time.Time {
return New(time.Now()).BeginningOfYear()
}
func EndOfMinute() time.Time {
return New(time.Now()).EndOfMinute()
}
func EndOfHour() time.Time {
return New(time.Now()).EndOfHour()
}
func EndOfDay() time.Time {
return New(time.Now()).EndOfDay()
}
func EndOfWeek() time.Time {
return New(time.Now()).EndOfWeek()
}
func EndOfMonth() time.Time {
return New(time.Now()).EndOfMonth()
}
func EndOfQuarter() time.Time {
return New(time.Now()).EndOfQuarter()
}
func EndOfYear() time.Time {
return New(time.Now()).EndOfYear()
}
func Monday() time.Time {
return New(time.Now()).Monday()
}
func Sunday() time.Time {
return New(time.Now()).Sunday()
}
func EndOfSunday() time.Time {
return New(time.Now()).EndOfSunday()
}
func Parse(strs ...string) (time.Time, error) {
return New(time.Now()).Parse(strs...)
}
func MustParse(strs ...string) time.Time {
return New(time.Now()).MustParse(strs...)
}
func Between(time1, time2 string) bool {
return New(time.Now()).Between(time1, time2)
}