From 2976f7bbd72e482546f6e00f4a7dd01d94cb11c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tiltwind=28=E6=96=9C=E9=A3=8E=29?= <116183822+tiltwind@users.noreply.github.com> Date: Fri, 24 Feb 2023 21:24:47 +0800 Subject: [PATCH] upgrade go to v1.17 to fix issue #348 for 2.0 branch (#353) * mark array types deprecated (#347) * mark array types deprected * mark array types deprecated * Update README.md change readme title * upgrade go to v1.17 to fix issue #348 --------- Co-authored-by: Xin.Zh --- .github/workflows/github-actions.yml | 2 +- README.md | 2 +- date.go | 6 +++--- date_test.go | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 132f03e4..0e304f57 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/README.md b/README.md index d1867f23..0323622e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gohessian +# dubbo-go-hessian2 [![Build Status](https://travis-ci.org/apache/dubbo-go-hessian2.png?branch=master)](https://travis-ci.org/apache/dubbo-go-hessian2) [![codecov](https://codecov.io/gh/apache/dubbo-go-hessian2/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go-hessian2) diff --git a/date.go b/date.go index 0b5329aa..4fa6b259 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 f0a8b6f3..2954ffc6 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) {