[Django] #22814: parse_datetime can't parse datetimes returned from postgresql

27 views
Skip to first unread message

Django

unread,
Jun 11, 2014, 7:43:01 PM6/11/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
----------------------------+--------------------
Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
The datetime format returned by postgresql is "2014-06-11
23:31:38.134266+00" which is failed to parsed because the offset is only
two digits.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 12, 2014, 2:08:25 AM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+--------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Where does Django call `parse_datetime` on a value returned by PostgreSQL?

If it never does, I'd just document the expected format.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:1>

Django

unread,
Jun 12, 2014, 11:39:24 AM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+--------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------

Comment (by Naddiseo):

`django.db.models.fields.DateTimeField` calls it in its `to_python`
method. I recommend django switch to be closer to ISO-8601 which allows
the following formats: Z; [+-]hh:mm, [+-]hhmm, [+-]hh
Currently `parse_datetime` allows all except the last case which was taken
out in 2f59e94a4150c84c8b4 because it (mistakenly) also allowed [+-]hm

I propose that [+-]hh be reintroduced with the semantics outlined in
ISO-8601. (I'll create a PR)

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:2>

Django

unread,
Jun 12, 2014, 11:47:48 AM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+-------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: assigned
Component: Utilities | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+-------------------------------------
Changes (by aaugustin):

* owner: nobody => aaugustin
* status: new => assigned
* stage: Unreviewed => Accepted


Comment:

Wikipedia confirms that `±hh` is supported. Let's do this.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:3>

Django

unread,
Jun 12, 2014, 12:02:04 PM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+--------------------------------------

Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: assigned
Component: Utilities | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by Naddiseo):

* stage: Accepted => Unreviewed


Comment:

https://github.com/django/django/pull/2804

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:4>

Django

unread,
Jun 12, 2014, 12:40:40 PM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------

Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: assigned
Component: Utilities | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------
Changes (by aaugustin):

* has_patch: 0 => 1
* stage: Unreviewed => Ready for checkin


Comment:

Looks good. My only comment is the most insignificant I ever left on a PR
:-) If you can amend the commit and force-push it, I'll merge it.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:5>

Django

unread,
Jun 12, 2014, 1:00:05 PM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: assigned
Component: Utilities | Version: 1.6

Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------
Changes (by Naddiseo):

* cc: django@… (added)


Comment:

Done, and flake8 passes on both changed files.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:6>

Django

unread,
Jun 12, 2014, 1:06:23 PM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: closed
Component: Utilities | Version: 1.6
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------
Changes (by Richard Eames <reames@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"7beaeeed2b99ec120486ee53e1eb7f1fe2515b9c"]:
{{{
#!CommitTicketReference repository=""
revision="7beaeeed2b99ec120486ee53e1eb7f1fe2515b9c"
Fixed #22814 -- Allowed ISO-8601 [+-]hh timezone format in parse_datetime
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:7>

Django

unread,
Jun 12, 2014, 1:06:24 PM6/12/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: closed
Component: Utilities | Version: 1.6

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"26cd19561331ac4a8a5f084a30c8ba0123d33278"]:
{{{
#!CommitTicketReference repository=""
revision="26cd19561331ac4a8a5f084a30c8ba0123d33278"
Merge pull request #2804 from AsymmetricVentures/issue22814

Fixed #22814 -- Allowed ISO-8601 [+-]hh timezone format in parse_datetime
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:8>

Django

unread,
Jun 24, 2014, 5:49:20 PM6/24/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: closed
Component: Utilities | Version: 1.6

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------

Comment (by anonymous):

Any chance of getting this backported to 1.7 and/or 1.6?

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:9>

Django

unread,
Jun 25, 2014, 4:57:52 AM6/25/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: closed
Component: Utilities | Version: 1.6

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------

Comment (by aaugustin):

I'll do it for 1.7.

I'd rather not do it in 1.6. I'm wary of making small changes in low level
utilities in stable versions because people tend to rely on the exact
behaviour, sometimes after checking the source.

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:10>

Django

unread,
Jun 25, 2014, 4:59:00 AM6/25/14
to django-...@googlegroups.com
#22814: parse_datetime can't parse datetimes returned from postgresql
---------------------------+---------------------------------------------
Reporter: Naddiseo | Owner: aaugustin
Type: Bug | Status: closed
Component: Utilities | Version: 1.6

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"8dcc7810f07e2ce76ebee50c70a5c16f1bc9edec"]:
{{{
#!CommitTicketReference repository=""
revision="8dcc7810f07e2ce76ebee50c70a5c16f1bc9edec"
[1.7.x] Fixed #22814 -- Allowed ISO-8601 [+-]hh timezone format in
parse_datetime

Backport of 7beaeeed from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22814#comment:11>

Reply all
Reply to author
Forward
0 new messages