From 834d2b40cae794b730cd747c5ac74d24abcdb7e6 Mon Sep 17 00:00:00 2001 From: MGJamJam Date: Wed, 9 Oct 2024 17:32:51 +0200 Subject: [PATCH 1/3] make start timestamp timezone aware --- src/utils/dataUtils.test.ts | 6 +++--- src/utils/dataUtils.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/dataUtils.test.ts b/src/utils/dataUtils.test.ts index 54770da..0b0ee01 100644 --- a/src/utils/dataUtils.test.ts +++ b/src/utils/dataUtils.test.ts @@ -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:00:00 }); it('should return correct timestamp for DAY interval', () => { diff --git a/src/utils/dataUtils.ts b/src/utils/dataUtils.ts index a9bdb1e..f61ee27 100644 --- a/src/utils/dataUtils.ts +++ b/src/utils/dataUtils.ts @@ -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': From ca02ef386de379d766820ca69c27b1b1b383559d Mon Sep 17 00:00:00 2001 From: MGJamJam Date: Thu, 10 Oct 2024 15:39:04 +0200 Subject: [PATCH 2/3] update Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d734943..67acd73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Development +### Fix + +- wrong padding of timeseries data for `HOUR` interval for timezones with minute offsets + ## 1.3.0 ### Added From 055b8d04f4cc5715df3f624e6a9365e0e3a7fd7c Mon Sep 17 00:00:00 2001 From: MGJamJam Date: Thu, 10 Oct 2024 15:41:06 +0200 Subject: [PATCH 3/3] fix test comment --- src/utils/dataUtils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/dataUtils.test.ts b/src/utils/dataUtils.test.ts index 0b0ee01..d1183e9 100644 --- a/src/utils/dataUtils.test.ts +++ b/src/utils/dataUtils.test.ts @@ -29,7 +29,7 @@ describe('calculateTimeSeriesStartTimestamp', () => { const result = calculateTimeSeriesStartTimestamp(referenceDataTimestamp, intervalStartTimestamp, 'HOUR'); //assert - expect(result).toEqual(1720593000000); // 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', () => {