Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

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

Merged
merged 2 commits into from Mar 30, 2016
Merged

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

merged 2 commits into from Mar 30, 2016

Conversation

ghost
Copy link

@ghost ghost commented Mar 28, 2016

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
Copy link
Author

ghost commented Mar 28, 2016

I'm so sorry about my bad eng.

@coveralls
Copy link

Coverage Status

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

@urish
Copy link
Owner

urish commented Mar 28, 2016

Hi, thanks for your contribution!

What is your use case for this feature ?

@ghost
Copy link
Author

ghost commented Mar 28, 2016

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
Copy link
Owner

urish commented Mar 28, 2016

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
Copy link

Coverage Status

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

@ghost
Copy link
Author

ghost commented Mar 29, 2016

so?

@urish
Copy link
Owner

urish commented Mar 29, 2016

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

@urish urish merged commit d9c300b into urish:master Mar 30, 2016
@urish
Copy link
Owner

urish commented Mar 30, 2016

Looks great, thanks!

@urish urish changed the title addede amFullDateThresholdDiff Support for setting the units of the full date threshold of am-time-ago Mar 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants