bugGNU Octave - Bugs: bug #43181, datenum docstring doesn't mention...

 
 

bug #43181: datenum docstring doesn't mention format string option

Submitted by:  None
Submitted on:  Tue 09 Sep 2014 08:15:57 PM UTC  
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  mreich Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  3.8.1
Operating System:  Other

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)

Wed 10 Sep 2014 01:45:00 PM UTC, comment #7: 

Thanks for the fix.
The added explanation is valuable, particularly since datenum with a format is much faster than without.

m.reich

Anonymous
Wed 10 Sep 2014 12:58:03 PM UTC, comment #6: 

That's a good point, the docstring for datenum should mention the format string option similar to datevec and datestr. I've updated the help for datenum on the stable branch:

http://hg.savannah.gnu.org/hgweb/octave/rev/14bb81940528

Thanks for pointing this out.

Mike Miller <mtmiller>
Project Administrator
Wed 10 Sep 2014 03:36:08 AM UTC, comment #5: 

Thank you again.

The form "days = datenum (datestr, f )", where "f" is a template does indeed work, to my surprise.  That is a  clean solution in my application. Surprise because two of the forms for datestr are "str = datestr (date, f)" and "str = datestr (date, f, p)".   However, no documented form for datenum includes a template variable.  Perhaps the datenum documentation needs an addition.

M.Reich

Anonymous
Wed 10 Sep 2014 03:21:15 AM UTC, comment #4: 

What I mean is for you to pass in the format string or template that you want your date strings to be parsed, for example:

n = datenum ("26-jun-00 14:56:00", "dd-mmm-yy HH:MM:SS")
n =    7.3066e+05

This way you control the format that you are expecting to handle.

Also the way I read the paragraph in question, it applies to formats that do have two-digit years, such as the built-in format "mm/dd/yy" or any custom format that you might come up with. So it is not invalid, but most of the built-in formats only parse four-digit years.

Mike Miller <mtmiller>
Project Administrator
Wed 10 Sep 2014 03:14:14 AM UTC, comment #3: 

Thank you for responding.
A question then a comment:

The format string that you recommend, "dd-mmm-yy HH:MM:SS" ,
looks like the one in the example in the original submission.  Did you mean "dd-mmm-yyyy HH:MM:SS" per format code 0 of function datestr?

As you point out, function datestr does not list date format "dd-mmm-yy HH:MM:SS".  However, documentation for function datenum contains the following paragraph:

"When processing input datestrings, p is the year at the start of the century to which two-digit years will be referenced. If not specified, it defaults to the current year minus 50."

One could restate the original submission as noting that the quoted paragraph is invalid.  Your response suggests that the paragraph is in fact invalid.  It's interesting however, that the form "days = datenum ("datestr", p)" does not complain about the extra parameter 'p'.

Anonymous
Wed 10 Sep 2014 02:34:54 AM UTC, comment #2: 

Thanks for your bug report. I can't see this date format working for any version of Octave going back to 3.2.4. I also don't see this format listed on the Matlab help for datenum or datevec. The only built-in format that looks like it is supposed to handle two-digit years is "mm/dd/yy". It would be best to pass a format string like "dd-mmm-yy HH:MM:SS" if you want it to interpret your desired format.

Mike Miller <mtmiller>
Project Administrator
Tue 09 Sep 2014 08:55:13 PM UTC, comment #1: 

Hello,

Reviewing my records showed that datenum had the problem described since prior to updating Octave on 09 Sept 2014.

M.Reich

Anonymous
Tue 09 Sep 2014 08:15:57 PM UTC, original submission:  

Hello,

Running Octave 3.8.1 under Cygwin under MSwin 7.
After updating today, the function datenum works as illustrated:

datenum("26-jun-00 14:56:00")
ans =  178.62
datenum("26-jun-00 14:56:00",2000)
ans =  178.62
datenum("26-jun-00 14:56:00",000)
ans =  178.62
datenum("26-jun-2000 14:56:00")
ans =    7.3066e+05

That is, datenum does not correctly interpret datestrings with two digit years.  Prior to updating, datenum may have worked properly as described in the 'datenum' entry of Edition 3 of the GNU Octave reference manual.

Thank you,
M.Reich

Anonymous

 

(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 None (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-09-10 mtmiller CategoryOctave Function => Documentation
        Item GroupIncorrect Result => Documentation
        StatusInvalid => Fixed
        SummaryFunction datenum incorectly handles two digit years => datenum docstring doesn't mention format string option
    2014-09-10 mtmiller StatusNone => Invalid
        Open/ClosedOpen => Closed

    Back to the top


    Powered by Savane 3.5