Skip to content

Commit

Permalink
fix(Yagr plugin): fix alignment with timezone (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flunt1k authored Feb 8, 2024
1 parent 7b55f2f commit e278db5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/plugins/yagr/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ describe('plugins/yagr/utils', () => {
describe('GetUplotTimezoneAligner', () => {
test.each<[YagrChartOptions | undefined, string | undefined, number, number]>([
// UTC
[{}, 'UTC', 1706659878000, 1706670678000],
[{}, 'UTC', 1706659878000, 1706649078000],
// UTC + 1
[{}, 'Europe/Belgrade', 1706659878000, 1706667078000],
[{}, 'Europe/Belgrade', 1706659878000, 1706652678000],
// UTC - 1
[{}, 'America/Scoresbysund', 1706659878000, 1706674278000],
[{}, 'America/Scoresbysund', 1706659878000, 1706645478000],
// UTC + 4
[{}, 'Asia/Muscat', 1706659878000, 1706656278000],
[{}, 'Asia/Muscat', 1706659878000, 1706663478000],
])(
'should return timestamp with added timezone diff',
'should return timestamp with subtracted timezone diff',
(chart, timeZone, timestamp, expectedResult) => {
const uplotTimezoneAligener = getUplotTimezoneAligner(chart, timeZone);

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/yagr/renderer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const getUplotTimezoneAligner =

const uPlotOffset = (browserTimezone - timestampRealTimezone) * 60 * 1000;

return new Date(browserDate.valueOf() + uPlotOffset);
return new Date(browserDate.valueOf() - uPlotOffset);
};

export const shapeYagrConfig = (args: ShapeYagrConfigArgs): MinimalValidConfig => {
Expand Down

0 comments on commit e278db5

Please sign in to comment.