urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Support for setting the units of the full date threshold of `am-time-ago` #237

Closed ghost closed 8 years ago

ghost commented 8 years ago

Added amFullDateThresholdDiff for changing default. Now every one can choose when need show FullDate.

var daysAgo = getNow().diff(momentInstance, 'day'); to (by default fullDateThresholdDiff is 'day') var timeAgo = getNow().diff(momentInstance, fullDateThresholdDiff);

ghost commented 8 years ago

I'm so sorry about my bad eng.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.8%) to 91.855% when pulling 1e578f0c2ab6894f442bc06ac79f999a9007b2e8 on denistrustepain:timeAgo into 412f3753e42fcaf61bd7ee8de76ce762ed561368 on urish:master.

urish commented 8 years ago

Hi, thanks for your contribution!

What is your use case for this feature ?

ghost commented 8 years ago

For exaple I have time tag with amTimeAgo directive.

Now: 12:00 AM. post.created_at: 12:00 AM.

We will seen: a few seconds ago.

<time am-time-ago="post.created_at" am-full-date-threshold="60" am-full-date-threshold-diff="minute" am-full-date-format="{{ post.created_at | getDateFormat }}"</time>

getDateFormat (filter) : // if is prev. years :: 23 Feb 2015 if (date.diff(today, 'years') < 0) format = 'MMM Do YYYY'; // if posted yesterday: yesterday at 12:00 else if (date.diff(today, 'days') == -1) format = '[yesterday at] HH:mm'; // if posted before then yesterday: 23 Feb at 12:00 else if (date.diff(today, 'days') <= -2) format = 'MMM Do [at] HH:mm'; // if posted today: today at 12:00 else if (date.diff(today, 'minutes') <= -60) format = '[today at] HH:mm'; And minimum in one day time I could see another time format. But what if I'd need to change format, for example, in 10 minutes?

urish commented 8 years ago

I see, so here are my suggestions:

  1. Change the name of the attribute from fullDateThresholdDiff to fullDateThresholdUnit
  2. Add a unit test for the new features

then I will happily merge :-)

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.1%) to 92.76% when pulling 8983f17f5c17becc440457a10dbda13aaf4998db on denistrustepain:timeAgo into 412f3753e42fcaf61bd7ee8de76ce762ed561368 on urish:master.

ghost commented 8 years ago

so?

urish commented 8 years ago

Thanks Denis, I still haven't had an opportunity to look into it, it's on my list

urish commented 8 years ago

Looks great, thanks!