Time 0 is loaded incorrectly
Created originally on Bitbucket by YuriS
Date with internal value 0
is loaded as datetime(1899, 12, 30, 0, 0)
, which actually corresponds to -1
.
#!python
import datetime
import openpyxl
wb = openpyxl.Workbook()
ws = wb.create_sheet('test')
ws['A1'] = datetime.time(0, 0)
wb.save('time-test.xlsx')
wb = openpyxl.load_workbook('time-test.xlsx')
ws = wb.get_sheet_by_name('test')
print ws['A1'].internal_value, ws['A1'].value
The results is 0 1899-12-30 00:00:00
.
I believe it should rather be time(0, 0)
and the following lines in openpyxl.utils.datetime.from_excel
if 1 < value < 60 and offset == CALENDAR_WINDOWS_1900:
if 0 < abs(value) < 1:
should be changed to
if 1 <= value < 60 and offset == CALENDAR_WINDOWS_1900:
if 0 <= abs(value) < 1: