diff options
author | xuri <xuri.me@gmail.com> | 2021-11-24 00:09:35 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-11-24 00:09:35 +0800 |
commit | 7907650a97115dbb771c7b977c5f260a1ff1cc65 (patch) | |
tree | cfaa9bc1b49cadcf7981dab332b3069cfcaf4bb4 /cell_test.go | |
parent | 9561976074eb3f8260845735bf6028a5d5f3bd71 (diff) |
This closes #1069, support time zone location when set cell value
Diffstat (limited to 'cell_test.go')
-rw-r--r-- | cell_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cell_test.go b/cell_test.go index f699c05..e49212f 100644 --- a/cell_test.go +++ b/cell_test.go @@ -178,6 +178,24 @@ func TestSetCellBool(t *testing.T) { assert.EqualError(t, f.SetCellBool("Sheet1", "A", true), `cannot convert cell "A" to coordinates: invalid cell name "A"`) } +func TestSetCellTime(t *testing.T) { + date, err := time.Parse(time.RFC3339Nano, "2009-11-10T23:00:00Z") + assert.NoError(t, err) + for location, expected := range map[string]string{ + "America/New_York": "40127.75", + "Asia/Shanghai": "40128.291666666664", + "Europe/London": "40127.958333333336", + "UTC": "40127.958333333336", + } { + timezone, err := time.LoadLocation(location) + assert.NoError(t, err) + _, b, isNum, err := setCellTime(date.In(timezone)) + assert.NoError(t, err) + assert.Equal(t, true, isNum) + assert.Equal(t, expected, b) + } +} + func TestGetCellValue(t *testing.T) { // Test get cell value without r attribute of the row. f := NewFile() |