From 540ee3539397f58d4cbc0b93190b9e412ecc55fa Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 17 May 2017 13:52:39 +0200 Subject: [PATCH] timerange: new quick ranges, month and year so far The new time ranges can also be used for time range overrides in the override relative time field. E.g. now/M or now/y. --- public/app/core/utils/rangeutil.ts | 4 +++- public/test/core/utils/rangeutil_specs.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 81fcbeb913f..71409e35ae4 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -18,9 +18,11 @@ var rangeOptions = [ { from: 'now/d', to: 'now/d', display: 'Today', section: 2 }, { from: 'now/d', to: 'now', display: 'Today so far', section: 2 }, { from: 'now/w', to: 'now/w', display: 'This week', section: 2 }, - { from: 'now/w', to: 'now', display: 'This week so far', section: 2 }, + { from: 'now/w', to: 'now', display: 'This week so far', section: 2 }, { from: 'now/M', to: 'now/M', display: 'This month', section: 2 }, + { from: 'now/M', to: 'now', display: 'This month so far', section: 2 }, { from: 'now/y', to: 'now/y', display: 'This year', section: 2 }, + { from: 'now/y', to: 'now', display: 'This year so far', section: 2 }, { from: 'now-1d/d', to: 'now-1d/d', display: 'Yesterday', section: 1 }, { from: 'now-2d/d', to: 'now-2d/d', display: 'Day before yesterday', section: 1 }, diff --git a/public/test/core/utils/rangeutil_specs.ts b/public/test/core/utils/rangeutil_specs.ts index 18ce89d53f2..93994f65850 100644 --- a/public/test/core/utils/rangeutil_specs.ts +++ b/public/test/core/utils/rangeutil_specs.ts @@ -47,6 +47,16 @@ describe("rangeUtil", () => { var info = rangeUtil.describeTextRange('now/w'); expect(info.display).to.be('This week so far'); }); + + it('should handle now/M', () => { + var info = rangeUtil.describeTextRange('now/M'); + expect(info.display).to.be('This month so far'); + }); + + it('should handle now/y', () => { + var info = rangeUtil.describeTextRange('now/y'); + expect(info.display).to.be('This year so far'); + }); }); describe("Can get date range described", () => {