-
Notifications
You must be signed in to change notification settings - Fork 10
/
time.go
75 lines (68 loc) · 1.67 KB
/
time.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
package ydb
import (
"time"
"github.com/yandex-cloud/ydb-go-sdk/v2/internal"
)
// Deprecated: Use standard time.Time instead
// This type will be removed at next major release
type Time time.Time
// func (t Time) String() string {
// return time.Time(t).String()
// }
func (t Time) Date() uint32 {
return internal.MarshalDate(time.Time(t))
}
func (t Time) Datetime() uint32 {
return internal.MarshalDatetime(time.Time(t))
}
func (t Time) Timestamp() uint64 {
return internal.MarshalTimestamp(time.Time(t))
}
func (t Time) TzDate() string {
return internal.MarshalTzDate(time.Time(t))
}
func (t Time) TzDatetime() string {
return internal.MarshalTzDatetime(time.Time(t))
}
func (t Time) TzTimestamp() string {
return internal.MarshalTzTimestamp(time.Time(t))
}
func (t *Time) FromDate(x uint32) error {
*t = Time(internal.UnmarshalDate(x))
return nil
}
func (t *Time) FromDatetime(x uint32) error {
*t = Time(internal.UnmarshalDatetime(x))
return nil
}
func (t *Time) FromTimestamp(x uint64) error {
*t = Time(internal.UnmarshalTimestamp(x))
return nil
}
func (t *Time) FromTzDate(x string) error {
v, err := internal.UnmarshalTzDate(x)
if err == nil {
*t = Time(v)
}
return err
}
func (t *Time) FromTzDatetime(x string) error {
v, err := internal.UnmarshalTzDatetime(x)
if err == nil {
*t = Time(v)
}
return err
}
func (t *Time) FromTzTimestamp(x string) error {
v, err := internal.UnmarshalTzTimestamp(x)
if err == nil {
*t = Time(v)
}
return err
}
// Deprecated: Use standard time.Time instead
// This type will be removed at next major release
type Duration time.Duration
func (d Duration) Interval() int64 {
return internal.DurationToMicroseconds(time.Duration(d))
}