-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdate.go
71 lines (64 loc) · 908 Bytes
/
date.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
package kitgo
import (
"time"
)
//-------------------------------------
//
// Date is ext time object
//
//-------------------------------------
type Date struct {
t time.Time
}
//
//
// NewDate default time is now
//
//
func NewDate() *Date {
d := &Date{
t: time.Now(),
}
return d
}
//
//
// Second return second value
//
//
func (d *Date) Second(second int) int {
if second != 0 {
d.t = d.t.Add(time.Duration(second) * time.Second)
}
return d.t.Second()
}
//
//
// Hour return hour value
//
//
func (d *Date) Hour(hour int) int {
if hour != 0 {
d.t = d.t.Add(time.Duration(hour) * time.Hour)
}
return d.t.Hour()
}
//
//
// Day return day value
//
//
func (d *Date) Minute(m int) int {
if m != 0 {
d.t = d.t.Add(time.Duration(m) * time.Minute)
}
return d.t.Minute()
}
//
//
// Format return format date
//
//
func (d *Date) Format(f string) string {
return d.t.Format(f)
}