Skip to content

Commit ba4ccee

Browse files
committed
ftime 添加获取时间戳
1 parent a3b3019 commit ba4ccee

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

types/ftime/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func (t Time) MarshalJSON() ([]byte, error) {
99
switch UsedFormatType {
1010
case TIMESTAMP:
11-
return json.Marshal(t.timestamp())
11+
return json.Marshal(t.Timestamp())
1212
case TEXT:
1313
return json.Marshal(t.formatText())
1414
default:

types/ftime/mongo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func (t Time) MarshalBSONValue() (bsontype.Type, []byte, error) {
1212
var dst []byte
1313
switch UsedFormatType {
1414
case TIMESTAMP:
15-
dst = bsoncore.AppendInt64(dst, t.timestamp())
15+
dst = bsoncore.AppendInt64(dst, t.Timestamp())
1616
return bsontype.Int64, dst, nil
1717
case TEXT:
1818
dst = bsoncore.AppendString(dst, string(t.formatText()))

types/ftime/sql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func (t *Time) Scan(value interface{}) error {
2525
func (t Time) Value() (driver.Value, error) {
2626
switch UsedFormatType {
2727
case TIMESTAMP:
28-
return t.timestamp(), nil
28+
return t.Timestamp(), nil
2929
case TEXT:
3030
return t.formatText(), nil
3131
default:
32-
return t.timestamp(), nil
32+
return t.Timestamp(), nil
3333
}
3434

3535
}

types/ftime/time.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func (t Time) formatText() []byte {
9797
return b
9898
}
9999

100-
func (t Time) timestamp() int64 {
100+
// Timestamp 时间戳
101+
func (t Time) Timestamp() int64 {
101102
var ts int64
102103

103104
if t.T().IsZero() {

0 commit comments

Comments
 (0)