bugGNU Octave - Bugs: bug #41286, datestr() returns wrong results if...

 
 

bug #41286: datestr() returns wrong results if one of input params is int32

Submitter:  Elmar Leson <el77>
Submitted:  Mon 20 Jan 2014 02:33:15 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  el77 Open/Closed:  * Closed
Release:  * 3.6.4 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 20 Jan 2014 07:50:29 PM UTC, comment #1: 

Thanks for your report. However, I'm marking this as invalid because the date functions have been intentionally modified to only accept double arguments. In particular, your example in Octave 3.8.0 now shows:


octave:1> dat = datenum (int32 (2014), 1, 20);
error: datenum: all inputs must be of class double
error: called from:
error:   /usr/share/octave/3.8.0/m/time/datenum.m at line 114, column 5
octave:2> dat = datenum (2014, 1, 20);
octave:3> datestr (int32 (dat));
error: datenum: all inputs must be of class double
error: called from:
error:   /usr/share/octave/3.8.0/m/time/datenum.m at line 114, column 5
error: evaluating argument list element number 1
error:   /usr/share/octave/3.8.0/m/time/datestr.m at line 235, column 10


So that pushes the issue back on the caller to make sure the arguments are of the correct type. This was fixed for Matlab compatibility, see bug #36587.

If you can show that this is not Matlab compatible behavior, please follow up to this report and I'll reopen, but it looks like Octave 3.8.0 is now doing the right thing in this case.

Mike Miller <mtmiller>
Group Member
Mon 20 Jan 2014 02:33:15 PM UTC, original submission:  

I got wrong results with datestr(). Was hard to find, because the input date of datest() was generated by datenum(). But if one of the input parameters of datenum() is of int32 format, the function returns int32. That doesn't work with datestr().

dat = datenum(2014,01,20)
datestr(dat,29)

> 2014-01-20


works correctly. But
dat = datenum(int32(2014),01,20) or
dat = datenum(2014,int32(01),20) or
dat = datenum(2014,01,int32(20))
datestr(dat,29)

> 2014-02--9 % day is negative!!!

is out of range.

My request: datestr must work with all integer formats.

Current workaround:
datestr(double(dat),29)

Elmar Leson <el77>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by el77 (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-20 mtmiller Item GroupIncorrect Result Matlab Compatibility
        StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code