/usr/share/octave/packages/financial-0.4.0/daysact.m is in octave-financial 0.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ## Copyright (C) 2007 David Bateman
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} daysact (@var{d1})
## @deftypefnx {Function File} {} daysact (@var{d1}, @var{d2})
## Calculates the number of days between two dates. If the second date is not
## given, calculate the number of days since 1-Jan-0000. The variables @var{d1}
## and @var{d2} can either be strings or an @var{n}-row string matrix. If both
## @var{d1} and @var{d2} are string matrices, then the number of rows must
## match. An example of the use of @code{daysact} is
##
## @example
## @group
## daysact ("01-Jan-2007", ["10-Jan-2007"; "23-Feb-2007"; "23-Jul-2007"])
## @result{} 9
## 53
## 203
## @end group
## @end example
## @seealso{datenum}
## @end deftypefn
function days = daysact (d1, d2)
if (nargin == 1)
nr = size (d1, 1);
if (nr != 1)
days = zeros (nr,1);
for i = 1 : nr
days (i) = datenum (d1 (i,:));
endfor
else
days = datenum(d1);
endif
elseif (nargin == 2)
nr1 = size (d1, 1);
nr2 = size (d2, 1);
if (nr1 != nr2 && nr1 != 1 && nr2 != 1)
error ("daysact: size mismatch");
endif
if (nr1 == 1 && nr2 == 1)
days = datenum (d2) - datenum(d1);
elseif (nr1 == 1)
days = zeros (nr2, 1);
for i = 1 : nr2
days(i) = datenum (d2 (i,:)) - datenum (d1);
endfor
elseif (nr2 == 1)
days = zeros (nr1, 1);
for i = 1 : nr1
days(i) = datenum (d2) - datenum (d1 (i,:));
endfor
else
days = zeros (nr1, 1);
for i = 1 : nr1
days(i) = datenum (d2 (i, :)) - datenum (d1 (i,:));
endfor
endif
else
print_usage();
endif
endfunction
%!assert (daysact ("01-Jan-2007", ["10-Jan-2007"; "23-Feb-2007"; "23-Jul-2007"]),[9;53;203])
|