This is the file:
num = datenum([1970, 1, 1, 0, 0, sec]);
No mex/Java/other silliness required.
Dan (2021). Seconds UTC to Matlab Datenum (https://www.mathworks.com/matlabcentral/fileexchange/37805-seconds-utc-to-matlab-datenum), MATLAB Central File Exchange. Retrieved .
OK, I see that the author doesn't actually claim that the code converts time zones.
However UTC is *not* defined as 'seconds since Jan-1-1970'; that is Unix time (approximately). This is a great function for that purpose, and I'd gladly give it 5 stars if the description were accurate!
This function converts Unix time (also called 'POSIX time') to a datenum. It does not convert between Coordinated Universal Time (UTC) and the date as reported by Matlab.
Doing the latter requires knowledge of the system's local time zone and daylight savings rules (thus the reason other functions make calls to libraries provided by Java, etc.)
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!