It seems that parse_duration only handles a very limited set of formats
(ISO8601, and '1 days, 04:00:00'), however, postgres's format is slightly
different.
'1 day 04:00:00'
I think this format could quite easily be handled by that function.
Any opposition to a patch that does that?
--
Ticket URL: <https://code.djangoproject.com/ticket/28076>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: me => Matthew Schinckel
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:1>
* has_patch: 0 => 1
* needs_tests: 0 => 1
* easy: 0 => 1
Comment:
https://github.com/django/django/pull/8354
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:2>
Comment (by Matthew Schinckel):
Turned out to be easier than I thought: It's just making the comma
optional.
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:3>
Comment (by Matthew Schinckel):
Hmm. Not quite.
There's some other differences: it's legal to have '-1 day, +04:00:00',
for instance, which the standard_duration_re will not match.
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:4>
* type: Uncategorized => Cleanup/optimization
* component: Forms => Utilities
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
You may want to also look at #25060 which suggests some changes to
`parse_duration()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:5>
Comment (by Matthew Schinckel):
Thanks Tim.
It looks to me that str(timedelta) is a subset of the format used by
Postgres.
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:6>
Comment (by Matthew Schinckel):
Oh wait, I read that wrong. It looks to me that parse_duration _already_
does parse str(timedelta)...
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"493f7e9e1ed7d68df102de6c5926a55521b145c9" 493f7e9e]:
{{{
#!CommitTicketReference repository=""
revision="493f7e9e1ed7d68df102de6c5926a55521b145c9"
Fixed #28076 -- Added support for PostgreSQL's interval format to
parse_duration().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28076#comment:8>