Merge pull request #3196 from utkarshcmu/custom-time
Timepicker display fixed for now-*
This commit is contained in:
@@ -134,8 +134,12 @@ _.each(rangeOptions, function (frame) {
|
|||||||
return from.fromNow() + ' to ' + formatDate(range.to);
|
return from.fromNow() + ' to ' + formatDate(range.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = describeTextRange(range.from);
|
if (range.to.toString() === 'now') {
|
||||||
return res.display;
|
var res = describeTextRange(range.from);
|
||||||
|
return res.display;
|
||||||
|
}
|
||||||
|
|
||||||
|
return range.from.toString() + ' to ' + range.to.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
|
|||||||
@@ -80,6 +80,22 @@ describe("rangeUtil", () => {
|
|||||||
var text = rangeUtil.describeTimeRange({from: 'now-13h', to: 'now'});
|
var text = rangeUtil.describeTimeRange({from: 'now-13h', to: 'now'});
|
||||||
expect(text).to.be('Last 13 hours')
|
expect(text).to.be('Last 13 hours')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Date range with from and to both are in now-* format', () => {
|
||||||
|
var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now-3h'});
|
||||||
|
expect(text).to.be('now-6h to now-3h')
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Date range with from and to both are either in now-* or now/* format', () => {
|
||||||
|
var text = rangeUtil.describeTimeRange({from: 'now/d+6h', to: 'now-3h'});
|
||||||
|
expect(text).to.be('now/d+6h to now-3h')
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Date range with from and to both are either in now-* or now+* format', () => {
|
||||||
|
var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now+1h'});
|
||||||
|
expect(text).to.be('now-6h to now+1h')
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user