Skip to content

Instantly share code, notes, and snippets.

@jayme-github
Last active February 4, 2020 16:20
Show Gist options
  • Save jayme-github/1f22326fba03ea365e223bd1f7c184c7 to your computer and use it in GitHub Desktop.
Save jayme-github/1f22326fba03ea365e223bd1f7c184c7 to your computer and use it in GitHub Desktop.
LibreOffice/Excel handle dates different than you might think...
import math
import datetime
secs_per_day = 24 * 60 * 60
def SOMECALCFUNC(datefloat):
# date comes as float from libreoffice where the integer part is the number
# of days since 1899-12-30 and the decimal part is the time as fraction of
# day.
timefrac, days = math.modf(datefloat)
dt = datetime.datetime(1899, 12, 30) + datetime.timedelta(days=days, seconds=timefrac * secs_per_day)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment