Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fat/AN-4385 make padding calculation for HOUR interval timezone aware #104

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Development

### Fix

- wrong padding of timeseries data for `HOUR` interval for timezones with minute offsets

## 1.3.0

### Added
Expand Down
6 changes: 3 additions & 3 deletions src/utils/dataUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ describe('calculateTimeSeriesStartTimestamp', () => {

it('should return correct timestamp for HOUR interval', () => {
//arrange
const referenceDataTimestamp = 1720598400000; // Wednesday, 10 July 2024 08:00:00
const intervalStartTimestamp = 1720591381300; // Wednesday, 10 July 2024 03:03:01.300
const referenceDataTimestamp = 1720600200000; // Wednesday, 10 July 2024 08:30:00
const intervalStartTimestamp = 1720591381300; // Wednesday, 10 July 2024 06:03:01.300

//act
const result = calculateTimeSeriesStartTimestamp(referenceDataTimestamp, intervalStartTimestamp, 'HOUR');

//assert
expect(result).toEqual(1720591200000); // Wednesday, 10 July 2024 06:00:00
expect(result).toEqual(1720593000000); // Wednesday, 10 July 2024 06:30:00
});

it('should return correct timestamp for DAY interval', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/dataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function calculateTimeSeriesStartTimestamp(
case 'MINUTE':
return intervalStartDate.setSeconds(0, 0);
case 'HOUR':
return intervalStartDate.setMinutes(0, 0, 0);
// minutes set because of timezones that have a minutes offset
return intervalStartDate.setMinutes(referenceDataDate.getMinutes(), 0, 0);
case 'DAY':
return intervalStartDate.setHours(referenceDataDate.getHours(), referenceDataDate.getMinutes(), 0, 0);
case 'MONTH':
Expand Down
Loading