relativedelta(date1, date2).weeks fails

Bug #727525 reported by John Anderson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
Confirmed
Undecided
Unassigned

Bug Description

Did you forget to implement weeks or am I missing something?

Thanks,
John Anderson

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Hi John,

There's really no weeks attribute, but there's a 'weeks' keyword which is why you may be thinking the former exists.

You can easily get weeks by doing "relativedelta(date1, date2).days / 7", though.

Changed in dateutil:
status: New → Invalid
Revision history for this message
John Anderson (john-appmagic) wrote : Re: [Bug 727525] Re: relativedelta(date1, date2).weeks fails

Why don't you have a weeks attribute, you seem to have attribute for everything else?

This leads to awkward code, e.g.:

                recurrence = {'hourly':'hours', 'daily':'days', 'weekly':'weeks', 'monthly':'months', 'yearly': 'years'}[object.recurrence]
                delta = relativedelta(end - start)

                if recurrence == 'weeks': # relativedelta doesn't support weeks for some strange reason
                    delta = int(delta.days / 7)
                else:
                    delta = getattr(delta, recurrence)

John

On Mar 10, 2011, at 6:15 AM, Gustavo Niemeyer wrote:

> Hi John,
>
> There's really no weeks attribute, but there's a 'weeks' keyword which
> is why you may be thinking the former exists.
>
> You can easily get weeks by doing "relativedelta(date1, date2).days /
> 7", though.
>
> ** Changed in: dateutil
> Status: New => Invalid
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/727525
>
> Title:
> relativedelta(date1, date2).weeks fails
>
> Status in python-dateutil:
> Invalid
>
> Bug description:
> Did you forget to implement weeks or am I missing something?
>
> Thanks,
> John Anderson
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/dateutil/+bug/727525/+subscribe

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Alright, that's a sane argument.

I'll reopen this.

Changed in dateutil:
status: Invalid → Confirmed
Revision history for this message
Paul G (p-ganssle) wrote :

I migrated this over to the github issue tracker: https://github.com/dateutil/dateutil/issues/45

And I have submitted a fix as well: https://github.com/dateutil/dateutil/pull/49

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.