1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 06:32:28 +08:00

feat:add AddYear func (#96)

Co-authored-by: leitao <leitao@kezaihui.com>
This commit is contained in:
tlei995
2023-05-18 10:14:23 +08:00
committed by GitHub
parent 82cb86b35c
commit aa8e0d5c12
3 changed files with 34 additions and 0 deletions

View File

@@ -7,6 +7,19 @@ import (
"github.com/duke-git/lancet/v2/internal"
)
func TestAddYear(t *testing.T) {
assert := internal.NewAssert(t, "TestAddDay")
now := time.Now()
after2Years := AddYear(now, 1)
diff1 := after2Years.Sub(now)
assert.Equal(float64(8760), diff1.Hours())
before2Years := AddYear(now, -1)
diff2 := before2Years.Sub(now)
assert.Equal(float64(-8760), diff2.Hours())
}
func TestAddDay(t *testing.T) {
assert := internal.NewAssert(t, "TestAddDay")