comparison scripts/time/addtodate.m @ 8664:e07e93c04080

style fixes
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 10:56:23 -0500
parents d448ac8a4874
children eb63fbe60fab
comparison
equal deleted inserted replaced
8663:4238f2600a17 8664:e07e93c04080
32 if (nargin != 3) 32 if (nargin != 3)
33 print_usage (); 33 print_usage ();
34 elseif (! (ischar (f) && rows (f) == 1)) 34 elseif (! (ischar (f) && rows (f) == 1))
35 ## FIXME: enhance the function so that it works with cellstrs of the 35 ## FIXME: enhance the function so that it works with cellstrs of the
36 ## same size as the output. 36 ## same size as the output.
37 error ("addtodate: f must be a single row character string.") 37 error ("addtodate: f must be a single row character string");
38 endif 38 endif
39 39
40 if (numel (d) == 1 && numel (q) > 1) 40 if (numel (d) == 1 && numel (q) > 1)
41 ## expand d to the size of q if d only has one element to make 41 ## expand d to the size of q if d only has one element to make
42 ## addition later eaiser. 42 ## addition later eaiser.
67 endif 67 endif
68 elseif (any (strcmpi ({"day" "hour" "minute" "second"}, f))) 68 elseif (any (strcmpi ({"day" "hour" "minute" "second"}, f)))
69 mult = struct ("day", 1, "hour", 1/24, "minute", 1/1440, "second", 1/86400); 69 mult = struct ("day", 1, "hour", 1/24, "minute", 1/1440, "second", 1/86400);
70 d += q.*mult.(f); 70 d += q.*mult.(f);
71 else 71 else
72 error ("addtodate: Invalid time unit: %s", f) 72 error ("addtodate: Invalid time unit: %s", f);
73 endif 73 endif
74 74
75 endfunction 75 endfunction
76 76
77 ## tests 77 ## tests