Re: [Django] #18202: inconsistent humanize naturaltime

2013-03-22 Thread Django
#18202: inconsistent humanize naturaltime
-+-
 Reporter:  oradoe   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  contrib.humanize |  Version:  1.4
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:  naturaltime, | Triage Stage:  Design
  humanize   |  decision needed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by aaugustin):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 I don't see a compelling argument for changing the current behavior, and
 adding a parameter sounds vastly overkill compared to the goals of
 `|naturaltime`.

 If you have more advanced formatting needs, I recommend writing a custom
 filter.

-- 
Ticket URL: 
Django 
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 post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #18202: inconsistent humanize naturaltime

2012-04-29 Thread Django
#18202: inconsistent humanize naturaltime
-+-
 Reporter:  oradoe   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.humanize |  Version:  1.4
 Severity:  Normal   |   Resolution:
 Keywords:  naturaltime, | Triage Stage:  Design
  humanize   |  decision needed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by pyriku):

 I think that is not a bad solution add a new parameter to the filter that
 allow the user specify how much levels of deep he wants in each case.
 Anyway, the default behavior should remain the same. As I see it, the
 result could be something like:


   {{{#!python
   {{date|naturaltime}} == "2 hours ago"
   {{date|naturaltime 1}} == "2 hours ago"
   {{date|naturaltime 2}} == "2 hours, 20 minutes ago"

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #18202: inconsistent humanize naturaltime

2012-04-28 Thread Django
#18202: inconsistent humanize naturaltime
-+-
 Reporter:  oradoe   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.humanize |  Version:  1.4
 Severity:  Normal   |   Resolution:
 Keywords:  naturaltime, | Triage Stage:  Design
  humanize   |  decision needed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by aviraldg):

 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * needs_tests:   => 0
 * stage:  Unreviewed => Design decision needed


Comment:

 The current behaviour makes perfect sense to me. Can't see why you'd want
 to change it.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #18202: inconsistent humanize naturaltime

2012-04-24 Thread Django
#18202: inconsistent humanize naturaltime
--+---
 Reporter:  oradoe|  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  contrib.humanize  |Version:  1.4
 Severity:  Normal|   Keywords:  naturaltime, humanize
 Triage Stage:  Unreviewed|  Has patch:  1
Easy pickings:  1 |  UI/UX:  0
--+---
 Currently, if delta is less than a day, we have 1 level of difference:
 4 minutes ago. (not 4 minutes, some seconds ago)
 2 hours ago. (not 2 hours, some minutes ago)

 Else, we have 2 levels of difference:
 2 days, 14 hours ago. (not 2 days ago)
 3 weeks, 3 days ago. (not 3 weeks ago)

 Expected (now): consistent of only 1 level of difference.
 Expected(near future): parameter for level of difference.

 my workaround:


 __author__ = 'truongsinh'
 import re
 from datetime import date, datetime, timedelta

 from django import template
 from django.conf import settings
 from django.template import defaultfilters
 from django.utils.encoding import force_unicode
 from django.utils.formats import number_format
 from django.utils.translation import pgettext, ungettext, ugettext as _
 from django.utils.timezone import is_aware, utc

 register = template.Library()

 @register.filter
 def naturaltime(value):
 """
 For date and time values shows how many seconds, minutes
 or hours ago
 compared to current timestamp returns representing string.
 """
 if not isinstance(value, date): # datetime is a subclass of date
 return value

 now = datetime.now(utc if is_aware(value) else None)
 if value < now:
 delta = now - value
 if delta.days:
 return pgettext(
 'naturaltime', '{delta:s} ago'
 ).format(delta =
 '''defaultfilters.timesince(value).split(',')[0])'''
 elif not delta.seconds:
 return _(u'now')
 elif delta.seconds < 60:
 return ungettext(
 u'a second ago', u'%(count)s seconds ago',
 delta.seconds
 ) % {'count': delta.seconds}
 elif delta.seconds // 60 < 60:
 count = delta.seconds // 60
 return ungettext(
 u'a minute ago', u'%(count)s minutes ago',
 count
 ) % {'count': count}
 else:
 count = delta.seconds // 60 // 60
 return ungettext(
 u'an hour ago', u'%(count)s hours ago',
 count
 ) % {'count': count}
 else:
 delta = value - now
 if delta.days:
 return pgettext(
 'naturaltime', '%(delta)s from now'
 ) % {'delta':
 '''defaultfilters.timeuntil(value).split(',')[0]'''}
 elif not delta.seconds:
 return _(u'now')
 elif delta.seconds < 60:
 return ungettext(
 u'a second from now', u'%(count)s seconds
 from now', delta.seconds
 ) % {'count': delta.seconds}
 elif delta.seconds // 60 < 60:
 count = delta.seconds // 60
 return ungettext(
 u'a minute from now', u'%(count)s minutes
 from now', count
 ) % {'count': count}
 else:
 count = delta.seconds // 60 // 60
 return ungettext(
 u'an hour from now', u'%(count)s hours
 from now', count
 ) % {'count': count}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.