@@ -354,6 +354,37 @@ def test_cell_date_custom_format(
354
354
assert cell .value == dt .date (2017 , 10 , 25 )
355
355
assert cell .number_format == "dd/mm/yyyy"
356
356
357
+ def test_cell_time_default_format (self , style : XLSXStyle , worksheet : Worksheet ):
358
+ f = XLSXDateField (
359
+ key = "dt" ,
360
+ value = "09:10:11" ,
361
+ field = TimeField (),
362
+ style = style ,
363
+ mapping = "" ,
364
+ cell_style = style ,
365
+ )
366
+ cell = f .cell (worksheet , 1 , 1 )
367
+ assert isinstance (cell , Cell )
368
+ assert cell .value == dt .time (9 , 10 , 11 )
369
+ assert cell .number_format == "h:mm:ss"
370
+
371
+ def test_cell_time_custom_format (
372
+ self , style : XLSXStyle , worksheet : Worksheet , settings
373
+ ):
374
+ settings .DRF_EXCEL_TIME_FORMAT = "hh - mm - ss"
375
+ f = XLSXDateField (
376
+ key = "dt" ,
377
+ value = "09h 10m 11s" ,
378
+ field = TimeField (format = "%Hh %Mm %Ss" ),
379
+ style = style ,
380
+ mapping = "" ,
381
+ cell_style = style ,
382
+ )
383
+ cell = f .cell (worksheet , 1 , 1 )
384
+ assert isinstance (cell , Cell )
385
+ assert cell .value == dt .time (9 , 10 , 11 )
386
+ assert cell .number_format == "hh - mm - ss"
387
+
357
388
358
389
class TestXLSXListField :
359
390
def test_cell_default_separator (self , style : XLSXStyle , worksheet : Worksheet ):
0 commit comments