bugGNU Octave - Bugs: bug #42241, datevec() should allow partial...

 
 

bug #42241: datevec() should allow partial matches when format is specified

Submitted by:  Ben Kurtz <bkurtz>
Submitted on:  Wed 30 Apr 2014 08:00:40 AM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Patch Submitted Assigned to:  None
Originator Name:  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.

 

Wed 04 Aug 2021 07:38:09 PM UTC, comment #3: 

This issue is still present in Octave 6.1.0.

datevec('2013-08-01 08:00:00/xyzpdq')
error: datevec: none of the standard formats match the DATE string
error: called from
    datevec at line 139 column 11

datevec('2013-08-01 08:00:00/xyzpdq','yyyy-mm-dd HH:MM:SS')
error: datevec: DATE not parsed correctly with given format
error: called from
    datevec at line 149 column 11

Anonymous
Thu 15 Dec 2016 03:03:25 PM UTC, comment #2: 

This issue is still present in Octave 4.2.0.

The second code line from comment #0 still throws an error in Ocave.

There is a proposal for a PATCH in comment #0.

Hartmut <hardy>
Wed 30 Apr 2014 08:01:59 AM UTC, comment #1: 

Also, I've done this a couple of times and I'm not sure what the best procedure is; for simple stuff like this, should I submit it as a 'bug' or a 'patch' in Savannah?

Ben Kurtz <bkurtz>
Wed 30 Apr 2014 08:00:40 AM UTC, original submission:  

In MATLAB if I specify the format for a date, anything that matches will parse:

>> datevec('2013-08-01 08:00:00/xyzpdq')
Error using datevec (line 213)
Failed to lookup month of year.

>> datevec('2013-08-01 08:00:00/xyzpdq','yyyy-mm-dd HH:MM:SS')

ans =

        2013           8           1           8           0           0

This is useful when:

  • date is part of a filename (don't have to write/run code to strip the tail end before parsing)
  • just want the date of a date/time string of known format

The current octave implementation throws errors for both calls, because it requires the full input string to match the format.

Attaching a patch that makes the behavior more like MATLAB, i.e. if a format is specified, the conversion will work as long as the string matches the format, even if there are extra characters at the end.

Ben Kurtz <bkurtz>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31281:  datevec.patch added by bkurtz (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by bkurtz (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-17 mtmiller Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 3 - Low
        Item GroupMatlab Compatibility => Feature Request
        StatusNone => Patch Submitted
    2014-04-30 bkurtz Attached File- => Added datevec.patch, #31281

    Back to the top


    Powered by Savane 3.7