Last active
August 29, 2015 14:15
-
-
Save gaute/500f0b42f1f167a92420 to your computer and use it in GitHub Desktop.
Convert Microsoft (Excel) timestamp to ISO
This file contains hidden or 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
(defun microsoft-date-to-iso (microsoft-date) | |
(format-time-string "%Y-%m-%d %H:%M:%S%z" (days-to-time (- (string-to-number microsoft-date) 25569)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Microsoft timestamp: 39962.5493055556
39962 is the number of days since December 30, 1899. The fraction part is the elapsed fraction of the day. (0.5 means 12:00, 0.75 means 18:00, etc.)
Emacs' days_to_time converts the number of days since January 1, 1970, including the fraction part.
To convert, we subtract 25569, which is the number of days between 1970-01-01 and 1899-12-30. The fraction part is left alone.
Returned ISO time: 2009-05-29 15:11:00+0200