octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Many Date Functions


From: Bill Denney
Subject: Re: Many Date Functions
Date: Fri, 01 Feb 2008 21:12:59 -0500
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

John W. Eaton wrote:
I applied this patch and checked it in along with a few small changes
to keep the style consistent with most of the rest of Octave.
Sorry for the style differences on the first set. Here is another patch to allow datenum to take vector inputs with either orientation (and it may work for matrices now, too).

Have a good day,

Bill

scripts/ChangeLog:

2008-02-01  Bill Denney  <address@hidden>

   * time/datenum.m: allow vector inputs in any orientation.
Index: datenum.m
===================================================================
RCS file: /cvs/octave/scripts/time/datenum.m,v
retrieving revision 1.7
diff -u -r1.7 datenum.m
--- datenum.m   12 Oct 2007 21:27:29 -0000      1.7
+++ datenum.m   2 Feb 2008 01:57:21 -0000
@@ -1,4 +1,4 @@
-## Copyright (C) 2006, 2007 Paul Kienzle
+## Copyright (C) 2006, 2007, 2008 Paul Kienzle
 ##
 ## This file is part of Octave.
 ##
@@ -99,7 +99,7 @@
   Y += fix ((M-14)/12);
 
   ## Lookup number of days since start of the current year.
-  D += monthstart (mod (M-1,12) + 1) + 60;
+  D += reshape (monthstart (mod (M-1,12) + 1), size (D)) + 60;
 
   ## Add number of days to the start of the current year. Correct
   ## for leap year every 4 years except centuries not divisible by 400.
@@ -120,7 +120,13 @@
 %!assert(datenum([2001,5,19;1417,6,12]), [730990;517712])
 %!assert(datenum(2001,5,19,12,21,3.5), 730990+part, eps)
 %!assert(datenum([1417,6,12,12,21,3.5]), 517712+part, eps)
+## Test vector inputs
 %!test
 %! t = [2001,5,19,12,21,3.5; 1417,6,12,12,21,3.5];
 %! n = [730990; 517712] + part;
 %! assert(datenum(t), n, 2*eps);
+## Make sure that the vectors can have either orientation
+%!test
+%! t = [2001,5,19,12,21,3.5; 1417,6,12,12,21,3.5]';
+%! n = [730990 517712] + part;
+%! assert(datenum(t(1,:), t(2,:), t(3,:), t(4,:), t(5,:), t(6,:)), n, 2*eps);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]