Skip to content

Commit 3ec742a

Browse files
committed
Merge pull request #7075 from filmor/patch-1
Fix Xl(sx|wt)Writer always using date_format even if a datetime is supplied.
2 parents f851b57 + 8d381f4 commit 3ec742a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ Bug Fixes
478478
- Bug in ``Float64Index.isin()`` where containing ``nan`` s would make indices
479479
claim that they contained all the things (:issue:`7066`).
480480
- Bug in ``DataFrame.boxplot`` where it failed to use the axis passed as the ``ax`` argument (:issue:`3578`)
481+
- Bug in the ``XlsxWriter`` and ``XlwtWriter`` implementations that resulted in datetime columns being formatted without the time (:issue:`7075`)
481482

482483
pandas 0.13.1
483484
-------------

pandas/io/excel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0):
661661
num_format_str = None
662662
if isinstance(cell.val, datetime.datetime):
663663
num_format_str = self.datetime_format
664-
if isinstance(cell.val, datetime.date):
664+
elif isinstance(cell.val, datetime.date):
665665
num_format_str = self.date_format
666666

667667
stylekey = json.dumps(cell.style)
@@ -782,7 +782,7 @@ def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0):
782782
num_format_str = None
783783
if isinstance(cell.val, datetime.datetime):
784784
num_format_str = self.datetime_format
785-
if isinstance(cell.val, datetime.date):
785+
elif isinstance(cell.val, datetime.date):
786786
num_format_str = self.date_format
787787

788788
stylekey = json.dumps(cell.style)

0 commit comments

Comments
 (0)