-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse.go
60 lines (48 loc) · 2.33 KB
/
parse.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
package timekit
import (
"time"
)
// ParseMmDd return time.Time with '01-02' format value,others location is default value.
func ParseMmDd(dStr string) (time.Time, error) {
return time.ParseInLocation(MmDd, dStr, time.Local)
}
// ParseYyyyMm return time.Time with '2006-01' format value,others location is default value.
func ParseYyyyMm(dStr string) (time.Time, error) {
return time.ParseInLocation(YyyyMm, dStr, time.Local)
}
// ParseYyyyMmDd return time.Time with '2006-01-02' format value,others location is default value.
func ParseYyyyMmDd(dStr string) (time.Time, error) {
return time.ParseInLocation(YyyyMmDd, dStr, time.Local)
}
// ParseMmDdHhMm return time.Time with '01-02 15:04' format value,others location is default value.
func ParseMmDdHhMm(dStr string) (time.Time, error) {
return time.ParseInLocation(MmDdHhMm, dStr, time.Local)
}
// ParseMmDdHhMmSs return time.Time with '01-02 15:04:05' format value,others location is default value.
func ParseMmDdHhMmSs(dStr string) (time.Time, error) {
return time.ParseInLocation(MmDdHhMmSs, dStr, time.Local)
}
// ParseMmDdHhMmSsSss return time.Time with '01-02 15:04:05.000' format value,others location is default value.
func ParseMmDdHhMmSsSss(dStr string) (time.Time, error) {
return time.ParseInLocation(MmDdHhMmSsSss, dStr, time.Local)
}
// ParseYyyyMmDdHhMm return time.Time with '2006-01-02 15:04' format value,others location is default value.
func ParseYyyyMmDdHhMm(dStr string) (time.Time, error) {
return time.ParseInLocation(YyyyMmDdHhMm, dStr, time.Local)
}
// ParseYyyyMmDdHhMmSs return time.Time with '2006-01-02 15:04:05' format value,others location is default value.
func ParseYyyyMmDdHhMmSs(dStr string) (time.Time, error) {
return time.ParseInLocation(YyyyMmDdHhMmSs, dStr, time.Local)
}
// ParseYyyyMmDdHhMmSsSss return time.Time with '2006-01-02 15:04:05.000' format value,others location is default value.
func ParseYyyyMmDdHhMmSsSss(dStr string) (time.Time, error) {
return time.ParseInLocation(YyyyMmDdHhMmSsSss, dStr, time.Local)
}
// ParseTimestampUnix return time.Time by parse timeUnix seconds.
func ParseTimestampUnix(timeUnix int64) time.Time {
return time.Unix(timeUnix, 0)
}
// ParseTimestampUnixMilli return time.Time by parse timeUnixMilli milliseconds.
func ParseTimestampUnixMilli(timeUnixMilli int64) time.Time {
return time.UnixMilli(timeUnixMilli)
}