POSIXTIME Current POSIX time using low level utilities. Syntax: T = POSIXTIME() Description: T = POSIXTIME() returns the current POSIX time: the number of seconds since 1970-01-01 00:00:00 UTC, not counting the effects of leap seconds. Notes: This function provides a compatibility interface for MATLAB and Octave, computing the POSIX time using lower level tools available in each system: In Octave, through the built-in interface to the ANSI C function TIME. In MATLAB, through a mex file interface to the ANSI C function TIME. Examples: t = posixtime() datestr(posixtime2utc(t)) datestr(now()) See also: POSIXTIME2UTC UTC2POSIXTIME Authors: Joan Pau Beltran <joanpau.beltran@socib.cat>
0001 function t = posixtime() 0002 %POSIXTIME Current POSIX time using low level utilities. 0003 % 0004 % Syntax: 0005 % T = POSIXTIME() 0006 % 0007 % Description: 0008 % T = POSIXTIME() returns the current POSIX time: the number of seconds since 0009 % 1970-01-01 00:00:00 UTC, not counting the effects of leap seconds. 0010 % 0011 % Notes: 0012 % This function provides a compatibility interface for MATLAB and Octave, 0013 % computing the POSIX time using lower level tools available in each system: 0014 % In Octave, through the built-in interface to the ANSI C function TIME. 0015 % In MATLAB, through a mex file interface to the ANSI C function TIME. 0016 % 0017 % Examples: 0018 % t = posixtime() 0019 % datestr(posixtime2utc(t)) 0020 % datestr(now()) 0021 % 0022 % See also: 0023 % POSIXTIME2UTC 0024 % UTC2POSIXTIME 0025 % 0026 % Authors: 0027 % Joan Pau Beltran <joanpau.beltran@socib.cat> 0028 0029 % Copyright (C) 2013-2016 0030 % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 0031 % <http://www.socib.es> 0032 % 0033 % This program is free software: you can redistribute it and/or modify 0034 % it under the terms of the GNU General Public License as published by 0035 % the Free Software Foundation, either version 3 of the License, or 0036 % (at your option) any later version. 0037 % 0038 % This program is distributed in the hope that it will be useful, 0039 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0040 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0041 % GNU General Public License for more details. 0042 % 0043 % You should have received a copy of the GNU General Public License 0044 % along with this program. If not, see <http://www.gnu.org/licenses/>. 0045 0046 error(nargchk(0, 0, nargin, 'struct')); 0047 0048 % Consider making the variable persistent 0049 % (the needed emptiness check may be more expensive than the existence check). 0050 ISOCTAVE = exist('OCTAVE_VERSION','builtin'); 0051 0052 if ISOCTAVE 0053 t = time(); 0054 else 0055 error('glider_toolbox:posixtime:MissingMexFile', ... 0056 'Missing required mex file.'); 0057 end 0058 0059 end