This is an automated email from the ASF dual-hosted git repository.

wongoo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git


The following commit(s) were added to refs/heads/master by this push:
     new f0ac0a6  upgrade go to v1.17 to fix issue #348 (#352)
f0ac0a6 is described below

commit f0ac0a67b3e1e3e9b71131ffd1d2466b65875883
Author: tiltwind(斜风) <[email protected]>
AuthorDate: Fri Feb 24 21:24:20 2023 +0800

    upgrade go to v1.17 to fix issue #348 (#352)
---
 .github/workflows/github-actions.yml |  2 +-
 date.go                              |  6 +++---
 date_test.go                         | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/github-actions.yml 
b/.github/workflows/github-actions.yml
index 132f03e..0e304f5 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -19,7 +19,7 @@ jobs:
         os:
           - ubuntu-latest
         go_version:
-          - 1.13
+          - 1.17
         jdk_version:
           - 1.8
     env:
diff --git a/date.go b/date.go
index 0b5329a..4fa6b25 100644
--- a/date.go
+++ b/date.go
@@ -42,12 +42,12 @@ func encDateInMs(b []byte, i interface{}) []byte {
                return append(b, BC_NULL)
        }
        b = append(b, BC_DATE)
-       return append(b, PackInt64(vi.UnixNano()/1e6)...)
+       return append(b, PackInt64(vi.UnixMilli())...)
 }
 
-func encDateInMimute(b []byte, v time.Time) []byte {
+func encDateInMinute(b []byte, v time.Time) []byte {
        b = append(b, BC_DATE_MINUTE)
-       return append(b, PackInt32(int32(v.UnixNano()/60e9))...)
+       return append(b, PackInt32(int32(v.Unix()/60))...)
 }
 
 /////////////////////////////////////////
diff --git a/date_test.go b/date_test.go
index f0a8b6f..2954ffc 100644
--- a/date_test.go
+++ b/date_test.go
@@ -66,6 +66,22 @@ func TestEncDate(t *testing.T) {
        d = NewDecoder(e.Buffer())
        res, err = d.Decode()
        t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err)
+       assert.Equal(t, tz.Local(), res)
+}
+
+func TestEncDateIssue348(t *testing.T) {
+       e := NewEncoder()
+       v := "2914-02-09 06:15:23"
+       tz, _ := time.Parse("2006-01-02 15:04:05", v)
+       e.Encode(tz)
+       if len(e.Buffer()) == 0 {
+               t.Fail()
+       }
+
+       d := NewDecoder(e.Buffer())
+       res, err := d.Decode()
+       t.Logf("decode(%s, %s) = %v, %v\n", v, tz.Local(), res, err)
+       assert.Equal(t, tz.Local(), res)
 }
 
 func testDateFramework(t *testing.T, method string, expected time.Time) {

Reply via email to