datestr2num of year and month fails for February on September 30

The design of the function datestr2num, unfortunately, has an undesired side-effect.

Today (September 30) I cannot convert monthly data, as February doesn’t have 30 days.

Conversion of:

datestr2num(‘2000-02’)

Gives an error:

ValueError: day is out of range for month

Should I file a bug report or a feature request?

Thanks,

Mark

···

On Thu, Sep 19, 2013 at 11:38 PM, Goyo <goyodiaz@…83…287…> wrote:

2013/9/19 Mark Bakker <markbak@…120…287…>:

Hello List,

When I use datestr2num(‘2010-05’) it nicely converts that to a number

representing the date.

When I convert that number back with num2date, it turns out it sets the day

to the 19th of the month. The dime is 0:00:00.

Any reason it is set to the 19th instead of the first?

Maybe because today it the 19th, or is that just a coincidence?

datestr2num calls dateutil.parser.parse, which by default uses the

current date at 00:00:00 for missing fields. The dateutil function

also can use a “default” argument to change this bahavoir but it is

not available in datestr2num.

http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c

Goyo

The design of the function datestr2num, unfortunately, has an undesired
side-effect.
Today (September 30) I cannot convert monthly data, as February doesn't
have 30 days.
Conversion of:
datestr2num('2000-02')
Gives an error:
ValueError: day is out of range for month

Should I file a bug report or a feature request?

I would classify it as a bug resulting from a bad default in dateutil.

Eric

···

On 2013/09/30 3:45 AM, Mark Bakker wrote:

Thanks,

Mark

    On Thu, Sep 19, 2013 at 11:38 PM, Goyo <goyodiaz@…287… > <mailto:goyodiaz@…287…>> wrote:

        2013/9/19 Mark Bakker <markbak@…287…
        <mailto:markbak@…287…>>:
         > Hello List,
         >
         > When I use datestr2num('2010-05') it nicely converts that to
        a number
         > representing the date.
         > When I convert that number back with num2date, it turns out
        it sets the day
         > to the 19th of the month. The dime is 0:00:00.
         > Any reason it is set to the 19th instead of the first?
         > Maybe because today it the 19th, or is that just a coincidence?

        datestr2num calls dateutil.parser.parse, which by default uses the
        current date at 00:00:00 for missing fields. The dateutil function
        also can use a "default" argument to change this bahavoir but it is
        not available in datestr2num.

        http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c

        Goyo

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users