Skip to content

Commit

Permalink
fix: Use default custom time range time without timezone (#29669)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored Jul 23, 2024
1 parent 453e6de commit cd713a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit cd713a2

Please sign in to comment.