Skip to content

Commit

Permalink
Fix T1255474
Browse files Browse the repository at this point in the history
  • Loading branch information
Alyar committed Jan 17, 2025
1 parent ab905f2 commit e34d308
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import dateUtils from '@js/core/utils/date';
import { isDefined } from '@js/core/utils/type';
import { dateUtilsTs } from '@ts/core/utils/date';

import timeZoneUtils from '../../m_utils_time_zone';
import { PathTimeZoneConversion } from './const';
import type { DateType, TimeZoneCalculatorOptions, TimeZoneOffsetsType } from './types';

Expand Down Expand Up @@ -63,13 +64,22 @@ export class TimeZoneCalculator {
const direction = isBack
? -1
: 1;

const resultDate = new Date(date);
return dateUtilsTs.addOffsets(resultDate, [
let convertedDateByOffsets = dateUtilsTs.addOffsets(resultDate, [
direction * (toMs('hour') * targetOffset),
-direction * (toMs('hour') * clientOffset),
]);

if (isBack) {
const DSTOffset = timeZoneUtils.getDaylightOffsetInMs(resultDate, convertedDateByOffsets);

if (DSTOffset !== 0) {
convertedDateByOffsets = dateUtilsTs.addOffsets(convertedDateByOffsets, [DSTOffset]);
}
}

return convertedDateByOffsets;

// V1
// NOTE: Previous date calculation engine.
// Engine was changed after fix T1078292.
Expand Down

0 comments on commit e34d308

Please sign in to comment.