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

 
 

bug #47026: datenum on Matlab accepts a date number

Submitter:  Richard <crobar>
Submitted:  Sat 30 Jan 2016 11:47:08 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  1 - Later Item Group:  Undocumented Matlab
Status:  Wont Fix Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 22 Nov 2021 03:30:15 AM UTC, comment #7: 

I decided that this is undocmunted Matlab that isn't worth copying.  Closing report.

Rik <rik5>
Group administrator
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>
Group 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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-22 rik5 Item GroupMatlab Compatibility Undocumented Matlab
        StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    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.13-cf05.
    Corresponding source code