paper-xlsxAPI referenceutils.datetime
openpyxl.utils.datetime
paper-xlsx 0.2.1 API reference
Manage Excel date weirdness.
CALENDAR_MAC_1904
attributeCALENDAR_MAC_1904= MAC_EPOCHCALENDAR_WINDOWS_1900
attributeCALENDAR_WINDOWS_1900= WINDOWS_EPOCHISO_DURATION
attributeISO_DURATION= re.compile('PT((?P<hours>\\d+)H)?((?P<minutes>\\d+)M)?((?P<seconds>\\d+(\\.\\d{1,3})?)S)?')ISO_FORMAT
attributeISO_FORMAT= '%Y-%m-%dT%H:%M:%SZ'ISO_REGEX
attributeISO_REGEX= re.compile('\n(?P<date>(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2}))?T?\n(?P<time>(?P<hour>\\d{2}):(?P<minute>\\d{2})(:(?P<second>\\d{2})(?P<microsecond>\\.\\d{1,3})?)?)?Z?', re.VERBOSE)MAC_EPOCH
attributeMAC_EPOCH= datetime.datetime(1904, 1, 1)SECS_PER_DAY
attributeSECS_PER_DAY= 86400WINDOWS_EPOCH
attributeWINDOWS_EPOCH= datetime.datetime(1899, 12, 30)days_to_time
funcdays_to_time(value)paramvaluefrom_ISO8601
funcfrom_ISO8601(formatted_string)Convert from a timestamp string to a datetime object. According to 18.17.4 in the specification the following ISO 8601 formats are supported.
Dates B.1.1 and B.2.1 Times B.1.2 and B.2.2 Datetimes B.1.3 and B.2.3
There is no concept of timedeltas in the specification, but Excel writes them (in strict OOXML mode), so these are also understood.
paramformatted_stringfrom_excel
funcfrom_excel(value, epoch=WINDOWS_EPOCH, timedelta=False)Convert Excel serial to Python datetime
paramvalueparamepoch= WINDOWS_EPOCHparamtimedelta= Falsetime_to_days
functime_to_days(value)Convert a time value to fractions of day
paramvaluetimedelta_to_days
functimedelta_to_days(value)Convert a timedelta value to fractions of a day
paramvalueto_ISO8601
functo_ISO8601(dt)Convert from a datetime to a timestamp string.
paramdtto_excel
functo_excel(dt, epoch=WINDOWS_EPOCH)Convert Python datetime to Excel serial
paramdtparamepoch= WINDOWS_EPOCH