This file is indexed.

/usr/share/octave/packages/financial-0.4.0/isbusday.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
## Copyright (C) 2008 Bill Denney <bill@denney.ws>
##
## 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} {r =} isbusday (refdate)
## @deftypefnx {Function File} {r =} isbusday (refdate, holiday)
## @deftypefnx {Function File} {r =} isbusday (refdate, holiday, weekend)
##
## Return true if the @var{refdate} is a business date @var{refdate}.
## @var{holiday} is a vector of datenums that defines the holidays
## observed (the holidays function is used if not given). @var{weekend}
## defines the days of the week that should be considered weekends;
## [1 0 0 0 0 0 1] (default) indicates that Sunday and Saturday are
## weekends.
##
## @seealso{holidays, lbusdate, busdate, fbusdate}
## @end deftypefn

function mask = isbusday (rd, hol=[], wkend=[])

  if ~ isnumeric (rd)
	rd = datenum (rd);
  endif
  if isempty (hol)
    ## Get all possible holidays that could affect the output.
    hol = holidays (min(rd), max(rd));
  end
  if isempty (wkend)
    wkend = [1 0 0 0 0 0 1];
  elseif numel (wkend) ~= 7
    error ("wkend must have 7 elements")
  elseif nargin > 3
    print_usage ();
  endif

  mask = reshape (wkend (weekday (rd)), size (rd));
  if ~ isempty (hol)
    ## Is it a holiday?
    mask = mask | ismember(rd, hol);
  endif
  mask = ~mask;
endfunction

## Tests
## A normal day
%!assert(isbusday(datenum(2008,1,2)), true())
## A holiday
%!assert(isbusday(datenum(2008,1,1)), false())
%!assert(isbusday(datenum(2008,1,1), []), false())
## A weekend
%!assert(isbusday(datenum(2008,2,2)), false())
## An alternate holiday
%!assert(isbusday(datenum(2008,1,2), datenum(2008,1,2)), false())
## An alternate weekend
%!assert(isbusday(datenum(2008,1,2), [], zeros(1,7)), true())
%!assert(isbusday(datenum(2008,1,2), [], ones(1,7)), false())
## A vector
%!assert(isbusday([datenum(2008,1,2) datenum(2008,2,2)]), [true() false()])
## A vector in the other direction
%!assert(isbusday([datenum(2008,1,2);datenum(2008,2,2)]), [true();false()])