Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openpyxl
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 233
    • Issues 233
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • openpyxl
  • openpyxl
  • Issues
  • #674
Closed
Open
Created Sep 09, 2016 by Bitbucket Importer@bitbucket_importerOwner

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:
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking