Skip to content

Instantly share code, notes, and snippets.

@RobBlackwell
Created May 19, 2018 18:31
Show Gist options
  • Save RobBlackwell/913b129d8d91e72e9879b20cb38fd529 to your computer and use it in GitHub Desktop.
Save RobBlackwell/913b129d8d91e72e9879b20cb38fd529 to your computer and use it in GitHub Desktop.
const MATLAB_EPOCH = Dates.DateTime(-0001,12,31)
"""
datenum(d::Dates.DateTime)
Converts a Julia DateTime to a MATLAB style DateNumber.
MATLAB represents time as DateNumber, a double precision floating
point number being the the number of days since January 0, 0000
Example
datenum(now())
"""
function datenum(d::Dates.DateTime)
Dates.value(d - MATLAB_EPOCH) /(1000 * 60 * 60 * 24)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment