I see your point but its tricky to know where you draw the line. Where do 
months stand? That answer will change depending on the project 
requirements. I wonder if there is a way of changing how the "time_strings" 
parameter works to control the depth more granularly but this does put a 
higher overhead on using the function, and certainly couldn't be used with 
the html filter.

I think adding the depth parameter increases the usefulness without to 
large of an overhead and that more specific requirements can carry on being 
implemented on a case by case basis.

Maybe the logic for calculating the time before formatting could be taken 
out of the function? That way it would be far easier to implement your own 
custom versions of the function without copying and pasting, and makes the 
code more readable too.

On Saturday, 23 May 2020 11:00:33 UTC+1, Tom Forbes wrote:
>
> 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 <to...@tobysuch.uk <javascript:>> 
> 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-d...@googlegroups.com <javascript:>.
> 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/d5c26ed2-b1f7-499b-b279-6961b978cfc8%40googlegroups.com.

Reply via email to