I like this idea. However while `depth=1` makes sense for shorter time periods 
where the difference between `4 hours` and `4 hours and 3 minutes ago` is not 
required to be displayed, when you get a value that is over a year ago it loses 
a lot of granularity. The difference between `1 year` and `1 year and 11 
months` is much more important.

In this case you probably want `depth=2` (“1 year, 6 months ago”), but only for 
values over a year ago. Given that, maybe a simple depth flag isn’t enough? I 
think what we really want here is a `compact=True` flag.

> On 22 May 2020, at 16:59, Toby Such <t...@tobysuch.uk> wrote:
> 
> Hi all!
> 
> I've been a little frustrated with the timesince filter that comes with 
> default Django. By default it always comes with 2 parts e.g. 4 hours and 3 
> minutes ago but I would much rather have just the 4 hours. In my own projects 
> I've simply created my own version of the timesince filter and accompanying 
> utils function that powers it that just has the code which adds the second 
> part removed. However I wonder why this isn't standard as I can't think of a 
> single website that displays time since as multiple parts. 
> 
> I'm proposing adding a 'depth' parameter to the timesince function which 
> would allow the developer to set how many parts to render. At depth one it 
> would be "3 weeks". 2 depth: "3 weeks 2 days" (default behaviour), 3 depth: 
> "3 weeks, 2 days, 4 hours ago" etc.
> 
> Does anyone have any thoughts related to this?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> <mailto:django-developers+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/97fbcab8-3f0f-4277-9296-fdcff7fcdab5%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/97fbcab8-3f0f-4277-9296-fdcff7fcdab5%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/DCC0D41F-A34F-4FFD-B8CC-39988EBE357E%40tomforb.es.

Reply via email to