bugGNU Octave - Bugs: bug #47026, datenum on Matlab accepts a date...

 
 

bug #47026: datenum on Matlab accepts a date number

Submitted by:  Richard <crobar>
Submitted on:  Sat 30 Jan 2016 11:47:08 PM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  1 - Later Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Sat 19 Jan 2019 06:58:35 AM UTC, comment #6: 

Here's a patch that does this if you choose to do so: file #46027

@spandey: For making Octave changesets in Mercurial, I find it easiest to:

  • Update to the default branch and do a pull to get the latest changes.
  • Switch to a new branch for my new work with a name based on the topic.
  • Commit the change as a single commit.
  • Export the changeset using `hg export <commit>`. For example, this one was:

$ hg export 26588 >~/Downloads/datenum-pass-through-numeric-row-vectors.patch

Andrew Janke <apjanke>
Sat 12 Mar 2016 10:12:20 PM UTC, comment #5: 

Sorry, being a newbie in mercurial ,I seriously messed up my first patch .
these two file make the patch for the given bug.
patch:
https://savannah.gnu.org/bugs/download.php?file_id=36612.
update-patch
https://savannah.gnu.org/bugs/download.php?file_id=36614.

SatyamPandey <spandey>
Sat 12 Mar 2016 10:03:44 PM UTC, comment #4: 

if matlab is given

(file #36614)

SatyamPandey <spandey>
Mon 01 Feb 2016 08:38:00 AM UTC, comment #3: 

Fair enough, in my case it was convenient for implementing a dateadd function. Just means adding an extra if clause.

Richard <crobar>
Sun 31 Jan 2016 11:45:25 PM UTC, comment #2: 

This looks like undocumented Matlab behavior.  See official documentation at http://www.mathworks.com/help/matlab/ref/datenum.html.  We usually don't bother to try and follow the undocumented stuff since it could change at any point in the future.  Also, I don't think it's so bad to warn if the user is likely to be calling a function in an incorrect manner.

Rik <rik5>
Project Administrator
Sat 30 Jan 2016 11:55:25 PM UTC, comment #1: 

Looks like it just returns any numeric vector passed in except a 6 element one:

>> datenum (now ())

ans =

   736.3600e+003

>> datenum (0)

ans =

     0.0000e+000

>> datenum (-8)

ans =

    -8.0000e+000

>> datenum (nan)

ans =

             NaN

>> datenum (inf)

ans =

             Inf

>> datenum (int32(1))

ans =

           1

>> datenum ({1})
Error using datenum (line 178)
DATENUM failed.

Caused by:
    Error using datevec (line 103)
    The input to DATEVEC was not an array of strings.

178     throw(newExc);

>> datenum ([1,2])

ans =

     1.0000e+000     2.0000e+000

>> datenum ([1,2,3])

ans =

   400.0000e+000

>> datenum ([1,2,3,4])

ans =

     1.0000e+000     2.0000e+000     3.0000e+000     4.0000e+000

>> datenum ([1,2,3,4,5])

ans =

     1.0000e+000     2.0000e+000     3.0000e+000     4.0000e+000     5.0000e+000

>> datenum ([1,2,3,4,5,6])

ans =

   400.1702e+000

>> datenum ([1,2,3,4,5,6,7])

ans =

     1.0000e+000     2.0000e+000     3.0000e+000     4.0000e+000     5.0000e+000     6.0000e+000     7.0000e+000

>> datenum ([1,2,3,4,5,6,7,9])

ans =

     1.0000e+000     2.0000e+000     3.0000e+000     4.0000e+000     5.0000e+000     6.0000e+000     7.0000e+000     9.0000e+000

Richard <crobar>
Sat 30 Jan 2016 11:47:08 PM UTC, original submission:  

In Matlab a date number is a valid input to datenum, on Octave it is an error:

Matlab

>> datenum (now ())

ans =

   736.3600e+003

Octave

octave:4> datenum (now ())
error: datenum: expected date vector containing [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND]
error: called from
    datenum at line 109 column 9
stopped in /usr/local/share/octave/4.1.0+/m/time/datenum.m at line 109
109:         error ("datenum: expected date vector containing [YEAR, MONTH, DAY, HOUR, MINUTE, SECOND]");

Richard <crobar>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #46026:  datenum-pass-through-scalar-numerics.patch added by apjanke (1KiB - application/octet-stream)
file #36614:  47026_1.diff added by spandey (1KiB - text/x-patch - update-patch)
file #36612:  47026.diff added by spandey (6KiB - text/x-patch - I have tried to make datenum function similar to matlab. Hope it works.Thisi i the )

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by apjanke (Updated the item)
  • -email is unavailable- added by spandey (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-01-19 apjanke Attached File- => Added datenum-pass-through-numeric-row-vectors.patch, #46027
    2019-01-19 apjanke Attached File- => Added datenum-pass-through-scalar-numerics.patch, #46026
    2016-03-12 spandey Attached File- => Added 47026_1.diff, #36614
    2016-03-12 spandey Attached File- => Added 47026.diff, #36612
    2016-01-31 rik5 Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 1 - Later
        StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.5