Last active
February 4, 2020 16:20
-
-
Save jayme-github/1f22326fba03ea365e223bd1f7c184c7 to your computer and use it in GitHub Desktop.
LibreOffice/Excel handle dates different than you might think...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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