@@ -305,6 +305,29 @@ func TestSetCellValue(t *testing.T) {
305
305
assert .NoError (t , err )
306
306
assert .Equal (t , expected , val )
307
307
}
308
+ // Test set cell value with time duration
309
+ for val , expected := range map [time.Duration ]string {
310
+ time .Hour * 21 + time .Minute * 51 + time .Second * 44 : "21:51:44" ,
311
+ time .Hour * 21 + time .Minute * 50 : "21:50" ,
312
+ time .Hour * 24 + time .Minute * 51 + time .Second * 44 : "24:51:44" ,
313
+ time .Hour * 24 + time .Minute * 50 : "24:50:00" ,
314
+ } {
315
+ assert .NoError (t , f .SetCellValue ("Sheet1" , "A1" , val ))
316
+ val , err := f .GetCellValue ("Sheet1" , "A1" )
317
+ assert .NoError (t , err )
318
+ assert .Equal (t , expected , val )
319
+ }
320
+ // Test set cell value with time
321
+ for val , expected := range map [time.Time ]string {
322
+ time .Date (2024 , time .October , 1 , 0 , 0 , 0 , 0 , time .UTC ): "Oct-24" ,
323
+ time .Date (2024 , time .October , 10 , 0 , 0 , 0 , 0 , time .UTC ): "10-10-24" ,
324
+ time .Date (2024 , time .October , 10 , 12 , 0 , 0 , 0 , time .UTC ): "10/10/24 12:00" ,
325
+ } {
326
+ assert .NoError (t , f .SetCellValue ("Sheet1" , "A1" , val ))
327
+ val , err := f .GetCellValue ("Sheet1" , "A1" )
328
+ assert .NoError (t , err )
329
+ assert .Equal (t , expected , val )
330
+ }
308
331
}
309
332
310
333
func TestSetCellValues (t * testing.T ) {
@@ -314,7 +337,7 @@ func TestSetCellValues(t *testing.T) {
314
337
315
338
v , err := f .GetCellValue ("Sheet1" , "A1" )
316
339
assert .NoError (t , err )
317
- assert .Equal (t , v , "12/31/10 00:00 " )
340
+ assert .Equal (t , v , "12-31-10 " )
318
341
319
342
// Test date value lower than min date supported by Excel
320
343
err = f .SetCellValue ("Sheet1" , "A1" , time .Date (1600 , time .December , 31 , 0 , 0 , 0 , 0 , time .UTC ))
0 commit comments