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 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();
|
||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
||||
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||
|
||||
const defaultCustomRange: CustomRangeType = {
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||
SEVEN_DAYS_AGO.getDate() - 7,
|
||||
).toString(),
|
||||
sinceMode: 'relative',
|
||||
sinceGrain: 'day',
|
||||
|
|
|
|||
|
|
@ -151,14 +151,14 @@ describe('customTimeRangeDecode', () => {
|
|||
it('7) default', () => {
|
||||
const SEVEN_DAYS_AGO = new Date();
|
||||
const MIDNIGHT = new Date();
|
||||
SEVEN_DAYS_AGO.setUTCHours(0, 0, 0, 0);
|
||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
||||
SEVEN_DAYS_AGO.setHours(0, 0, 0, 0);
|
||||
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||
expect(
|
||||
customTimeRangeDecode('now : DATEADD(DATETIME("TODAY"), -7, day)'),
|
||||
).toEqual({
|
||||
customRange: {
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||
SEVEN_DAYS_AGO.getDate() - 7,
|
||||
).toString(),
|
||||
sinceMode: 'relative',
|
||||
sinceGrain: 'day',
|
||||
|
|
@ -176,18 +176,18 @@ describe('customTimeRangeDecode', () => {
|
|||
|
||||
it('8) relative : relative return default', () => {
|
||||
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();
|
||||
MIDNIGHT.setUTCHours(0, 0, 0, 0);
|
||||
MIDNIGHT.setHours(0, 0, 0, 0);
|
||||
expect(
|
||||
customTimeRangeDecode(
|
||||
'DATEADD(DATETIME("2021-01-26T00:00:00"), -55, day) : DATEADD(DATETIME("2021-01-27T00:00:00"), 7, day)',
|
||||
),
|
||||
).toEqual({
|
||||
customRange: {
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setUTCDate(
|
||||
SEVEN_DAYS_AGO.getUTCDate() - 7,
|
||||
sinceDatetime: SEVEN_DAYS_AGO.setDate(
|
||||
SEVEN_DAYS_AGO.getDate() - 7,
|
||||
).toString(),
|
||||
sinceMode: 'relative',
|
||||
sinceGrain: 'day',
|
||||
|
|
|
|||
Loading…
Reference in New Issue