Skip to content

Commit

Permalink
fix timestamp for quarter range in time series
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashkochar20 committed Mar 2, 2022
1 parent 61a9fab commit 2c61f6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cubejs-backend-shared/src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const TIME_SERIES: { [key: string]: (range: DateRange) => QueryDateRange[
week: (range: DateRange) => Array.from(range.snapTo(<unitOfTime.Diff>'isoWeek').by('week'))
.map(d => [d.startOf('isoWeek').format('YYYY-MM-DDT00:00:00.000'), d.endOf('isoWeek').format('YYYY-MM-DDT23:59:59.999')]),
quarter: (range: DateRange) => Array.from(range.snapTo('quarter').by('quarter'))
.map(d => [d.format('YYYY-MM-DDT00:00:00.000'), d.endOf('quarter').format('YYYY-MM-DDT23:59:99.999')]),
.map(d => [d.format('YYYY-MM-DDT00:00:00.000'), d.endOf('quarter').format('YYYY-MM-DDT23:59:59.999')]),
};

export const timeSeries = (granularity: string, dateRange: QueryDateRange): QueryDateRange[] => {
Expand Down
8 changes: 4 additions & 4 deletions packages/cubejs-backend-shared/test/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ describe('timeSeries', () => {

it('quarter', () => {
expect(timeSeries('quarter', ['2021-01-01', '2021-12-31'])).toEqual([
['2021-01-01T00:00:00.000', '2021-03-31T23:59:99.999'],
['2021-04-01T00:00:00.000', '2021-06-30T23:59:99.999'],
['2021-07-01T00:00:00.000', '2021-09-30T23:59:99.999'],
['2021-10-01T00:00:00.000', '2021-12-31T23:59:99.999'],
['2021-01-01T00:00:00.000', '2021-03-31T23:59:59.999'],
['2021-04-01T00:00:00.000', '2021-06-30T23:59:59.999'],
['2021-07-01T00:00:00.000', '2021-09-30T23:59:59.999'],
['2021-10-01T00:00:00.000', '2021-12-31T23:59:59.999'],
]);
});
});

0 comments on commit 2c61f6d

Please sign in to comment.