#35443: Support negative numbers for ordinals
-------------------------------------+-------------------------------------
               Reporter:  Siburg     |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  5.0
  contrib.humanize                   |
               Severity:  Normal     |       Keywords:  humanize ordinal
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The `ordinal` template tag in `/contrib/humanize/templatetags/humanize.py`
 returns strange results for negative numbers. For example:
 -1 becomes -1th
 -9 becomes -9st
 -8 becomes -8nd
 -7 becomes -7rd

 I think that can be regarded as a bug. I can think of following approaches
 for dealing with it.

 0) The null option. Won't fix. Assume ordinals are not supposed to support
 negative numbers. I can live with that; I don't have a use case for them
 either. I only discovered this anomaly while running a unit test with a -1
 input. But it does feel weird to knowingly have this issue.

 1) Treat it as invalid input and just return the original input; similar
 to a `ValueError`.

 2) Treat it as a positive number, and return the ordinal for its absolute
 value.

 3) Treat it as valid input, and return the ordinal for its absolute value
 with a minus sign in front of it. I assume that will work for non-English
 languages too.

 I suggest doing 3). Either way, if a decision or recommendation is made to
 do anything about it I can prepare a PR.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35443>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f65bb9785-cdd8e238-c06a-46bb-88fc-d0077a33bada-000000%40eu-central-1.amazonses.com.

Reply via email to