#22814 closed Bug (fixed)
parse_datetime can't parse datetimes returned from postgresql
Reported by: | no | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Utilities | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | django@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (11)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
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)
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
Wikipedia confirms that ±hh
is supported. Let's do this.
comment:4 by , 10 years ago
Triage Stage: | Accepted → Unreviewed |
---|
comment:5 by , 10 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
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.
comment:7 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:10 by , 10 years ago
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.
Where does Django call
parse_datetime
on a value returned by PostgreSQL?If it never does, I'd just document the expected format.