From c3a3945ff59cd602ed72a7f2687e71db70a60d95 Mon Sep 17 00:00:00 2001 From: Peleus <245629560@qq.com> Date: Tue, 12 Sep 2023 20:31:11 +0800 Subject: [PATCH] optimize code --- database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database.go b/database.go index e5d18d9a..41419a0e 100644 --- a/database.go +++ b/database.go @@ -10,7 +10,7 @@ import ( func (c *Carbon) Scan(v interface{}) error { value, ok := v.(time.Time) if ok { - *c = Carbon{time: value, loc: time.Local} + *c = CreateFromStdTime(value) return nil } return fmt.Errorf("can not convert %v to carbon", v) @@ -21,5 +21,5 @@ func (c Carbon) Value() (driver.Value, error) { if c.IsZero() { return nil, nil } - return c.time, nil + return c.ToStdTime(), nil }