changeset 7659:4ab2488ab2b4

datenum: allow vector inputs in any orientation
author Bill Denny
date Thu, 27 Mar 2008 15:17:53 -0400
parents 1ce6460aebdf
children 5f6e11567f70
files scripts/ChangeLog scripts/time/datenum.m
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Mar 27 15:14:10 2008 -0400
+++ b/scripts/ChangeLog	Thu Mar 27 15:17:53 2008 -0400
@@ -1,5 +1,7 @@
 2008-03-27  Bill Denney  <bill@denney.ws>
 
+	* time/datenum.m: Allow vector inputs in any orientation.
+
 	* strings/validatestring.m: New function.
 	* strings/Makefile.in (SOURCES): Add it to the list.
 
--- a/scripts/time/datenum.m	Thu Mar 27 15:14:10 2008 -0400
+++ b/scripts/time/datenum.m	Thu Mar 27 15:17:53 2008 -0400
@@ -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);