angular-moment icon indicating copy to clipboard operation
angular-moment copied to clipboard

More granular amDifference filter?

Open slavafomin opened this issue 10 years ago • 11 comments

Hello!

I would love to see more granular approach with amDifference filter. For example, I want to display minutes for small differences, days for bigger differences and month for even bigger differences.

It dosn't make sense to show something like 67 days, I would prefer to show 9 weeks.

Looks like Timeago directive is working in similar fasion.

it would be even cooler to show something like 9 weeks, 4 days.

Or is it outisde of the scope of this module?

Thank you!

slavafomin avatar Mar 31 '15 12:03 slavafomin

+1, I'd take it even a step further.

I'd love to see someone build in functionality to allow for me to set some kind of "threshold" for when amDifference should "kick over" to amCalendar or amDateFormat.

for example... would be great to have a way for me to display something in "time ago" formats for up to say, 5 days.. then kick over to a custom date format for anything longer ago than 5 days.

RavenHursT avatar Apr 01 '15 21:04 RavenHursT

@RavenHursT please see this topic as well: https://github.com/urish/angular-moment/issues/75

slavafomin avatar Apr 01 '15 21:04 slavafomin

Thanks for the comments. The current interface for amDifference is already over-complicated (the filter takes up to 5 extra parameters).

I would love to see somebody comes up with a suggestion how to incorporate this features while keeping the API as simple as possible...

urish avatar Apr 01 '15 21:04 urish

Maybe we could define some presets and provide them to the filter?

Something like this:


// Defining new preset via provider.
provider.addPreset('myFilterPreset', {
  fooOption: 'value',
  barOption: 'anotherValue',
  // ...
});


<!-- Passing preset name to the filter -->
{{ something|amDifference:'myFilterPreset' }}

slavafomin avatar Apr 02 '15 10:04 slavafomin

+1 Would be good to be able to define the granularity (e.g. 2 years vs 2 years, 3 months, 15 days).

Maybe integrate with https://github.com/jsmreese/moment-duration-format

philippeluickx avatar May 05 '15 08:05 philippeluickx

Can't we "bump" these? +1? ;-)

RavenHursT avatar May 15 '15 01:05 RavenHursT

:+1:

josx avatar Sep 03 '15 17:09 josx

I also need this feature on my work, so I decided to do it. Any comment on this PR?

josx avatar Sep 03 '15 19:09 josx

@josx thanks for the PR, I left my comments there :)

urish avatar Sep 03 '15 22:09 urish

:+1:

RavenHursT avatar Sep 03 '15 22:09 RavenHursT

@RavenHursT you are invited to share your thoughts in the PR (#172)

urish avatar Sep 03 '15 23:09 urish