MCPcopy Index your code
hub / github.com/csev/py4e / duration_humanize__relativeTime

Function duration_humanize__relativeTime

code/gmane/Chart.bundle.js:4605–4629  ·  view source on GitHub ↗
(posNegDuration, withoutSuffix, locale)

Source from the content-addressed store, hash-verified

4603 }
4604
4605 function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
4606 var duration = create__createDuration(posNegDuration).abs();
4607 var seconds = round(duration.as('s'));
4608 var minutes = round(duration.as('m'));
4609 var hours = round(duration.as('h'));
4610 var days = round(duration.as('d'));
4611 var months = round(duration.as('M'));
4612 var years = round(duration.as('y'));
4613
4614 var a = seconds < thresholds.s && ['s', seconds] ||
4615 minutes === 1 && ['m'] ||
4616 minutes < thresholds.m && ['mm', minutes] ||
4617 hours === 1 && ['h'] ||
4618 hours < thresholds.h && ['hh', hours] ||
4619 days === 1 && ['d'] ||
4620 days < thresholds.d && ['dd', days] ||
4621 months === 1 && ['M'] ||
4622 months < thresholds.M && ['MM', months] ||
4623 years === 1 && ['y'] || ['yy', years];
4624
4625 a[2] = withoutSuffix;
4626 a[3] = +posNegDuration > 0;
4627 a[4] = locale;
4628 return substituteTimeAgo.apply(null, a);
4629 }
4630
4631 // This function allows you to set a threshold for relative time strings
4632 function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {

Callers 1

humanizeFunction · 0.85

Calls 2

create__createDurationFunction · 0.85
roundFunction · 0.70

Tested by

no test coverage detected