fix: Use default custom time range time without timezone (#29669)
This commit is contained in:
parent
453e6deb97
commit
cd713a239e
|
|
@ -39,14 +39,14 @@ export const ISO8601_AND_CONSTANT = RegExp(
|
||||||
);
|
);
|
||||||
const DATETIME_CONSTANT = ['now', 'today'];
|
const DATETIME_CONSTANT = ['now', 'today'];
|
||||||
const SEVEN_DAYS_AGO = new Date();
|
const SEVEN_DAYS_AGO = new Date();
|
||||||
SEVEN_DAYS_AGO.setUTCHours(0, 0, 0, 0);
|
SEVEN_DAYS_AGO.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const MIDNIGHT = new Date();
|
const MIDNIGHT = new Date();
|
||||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const defaultCustomRange: CustomRangeType = {
|
const defaultCustomRange: CustomRangeType = {
|
||||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
SEVEN_DAYS_AGO.getDate() - 7,
|
||||||
).toString(),
|
).toString(),
|
||||||
sinceMode: 'relative',
|
sinceMode: 'relative',
|
||||||
sinceGrain: 'day',
|
sinceGrain: 'day',
|
||||||
|
|
|
||||||
|
|
@ -151,14 +151,14 @@ describe('customTimeRangeDecode', () => {
|
||||||
it('7) default', () => {
|
it('7) default', () => {
|
||||||
const SEVEN_DAYS_AGO = new Date();
|
const SEVEN_DAYS_AGO = new Date();
|
||||||
const MIDNIGHT = new Date();
|
const MIDNIGHT = new Date();
|
||||||
SEVEN_DAYS_AGO.setUTCHours(0, 0, 0, 0);
|
SEVEN_DAYS_AGO.setHours(0, 0, 0, 0);
|
||||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||||
expect(
|
expect(
|
||||||
customTimeRangeDecode('now : DATEADD(DATETIME("TODAY"), -7, day)'),
|
customTimeRangeDecode('now : DATEADD(DATETIME("TODAY"), -7, day)'),
|
||||||
).toEqual({
|
).toEqual({
|
||||||
customRange: {
|
customRange: {
|
||||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
SEVEN_DAYS_AGO.getDate() - 7,
|
||||||
).toString(),
|
).toString(),
|
||||||
sinceMode: 'relative',
|
sinceMode: 'relative',
|
||||||
sinceGrain: 'day',
|
sinceGrain: 'day',
|
||||||
|
|
@ -176,18 +176,18 @@ describe('customTimeRangeDecode', () => {
|
||||||
|
|
||||||
it('8) relative : relative return default', () => {
|
it('8) relative : relative return default', () => {
|
||||||
const SEVEN_DAYS_AGO = new Date();
|
const SEVEN_DAYS_AGO = new Date();
|
||||||
SEVEN_DAYS_AGO.setUTCHours(0, 0, 0, 0);
|
SEVEN_DAYS_AGO.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const MIDNIGHT = new Date();
|
const MIDNIGHT = new Date();
|
||||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||||
expect(
|
expect(
|
||||||
customTimeRangeDecode(
|
customTimeRangeDecode(
|
||||||
'DATEADD(DATETIME("2021-01-26T00:00:00"), -55, day) : DATEADD(DATETIME("2021-01-27T00:00:00"), 7, day)',
|
'DATEADD(DATETIME("2021-01-26T00:00:00"), -55, day) : DATEADD(DATETIME("2021-01-27T00:00:00"), 7, day)',
|
||||||
),
|
),
|
||||||
).toEqual({
|
).toEqual({
|
||||||
customRange: {
|
customRange: {
|
||||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
SEVEN_DAYS_AGO.getDate() - 7,
|
||||||
).toString(),
|
).toString(),
|
||||||
sinceMode: 'relative',
|
sinceMode: 'relative',
|
||||||
sinceGrain: 'day',
|
sinceGrain: 'day',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue