Opened 22 months ago
Closed 22 months ago
#34387 closed Uncategorized (wontfix)
DateFormat.P() does not follow PHP's date string format
Reported by: | null | Owned by: | Ayush Bisht |
---|---|---|---|
Component: | Utilities | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
PHP's documentation defines the P character as follows:
"P Difference to Greenwich time (GMT) with colon between hours and minutes Example: +02:00"
However in django, P() appears to be implemented as
"Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off
if they're zero and the strings 'midnight' and 'noon' if appropriate.
Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.'
Proprietary extension."
For example:
DateFormat(self.created_on).format("F jS Y, h:ia P")
returns "March 5th 2023, 08:44a.m. 8:44 a.m." when it should return "March 5th 2023, 08:44a.m. -05:00"
Change History (4)
comment:1 by , 22 months ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 22 months ago
Resolution: | wontfix |
---|---|
Status: | closed → new |
Type: | Bug → Uncategorized |
Version: | 3.2 → 4.2 |
In that case the inline documentation is incorrect and should be updated as in djang.utils.dateformat it still, as of 4.2, reads:
""" PHP date() style date formatting See http://www.php.net/date for format strings Usage: >>> import datetime >>> d = datetime.datetime.now() >>> df = DateFormat(d) >>> print(df.format('jS F Y H:i')) 7th October 2003 11:39 >>> """
comment:3 by , 22 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 22 months ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
I appreciate you'd like to reopen the ticket, but I don't see anything wrong in this docstring. We could remove "See http://www.php.net/date for format strings" as there is no need to check PHP docs for format strings but such a tiny cleanup doesn't require a ticket.
Thanks for this patch, however it works as documented:
We will not make a backward incompatible change to follow the PHP implementation.