Skip to content

Commit

Permalink
Merge pull request moment#1716 from jbrockmeyer/getRelativeTimeThresh…
Browse files Browse the repository at this point in the history
…old_Issue_1715

Fix issue moment#1715 to retrieve relativeTimeThreshold settings

@changelog
@section features
@description Allow getting relativeTimeThreshold
  • Loading branch information
ichernev committed Jun 17, 2014
2 parents 34b877a + f4aec82 commit ebeffba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,11 @@
if (relativeTimeThresholds[threshold] === undefined) {
return false;
}

if(limit === undefined){
return relativeTimeThresholds[threshold];
}

relativeTimeThresholds[threshold] = limit;
return true;
};
Expand Down
10 changes: 10 additions & 0 deletions test/moment/relative_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ exports.relativeTime = {
a.subtract('days', 1);
test.equal(a.fromNow(), "a year ago", "Above custom days to years threshold");
moment.relativeTimeThreshold('dy', 345);
test.done();
},

"retrive threshold settings" : function (test) {
test.expect(1);
moment.relativeTimeThreshold('m', 45);
var minuteThreshold = moment.relativeTimeThreshold('m');

test.equal(minuteThreshold, 45, "Can retrieve minute setting");

test.done();
}
};

0 comments on commit ebeffba

Please sign in to comment.