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

Draft - Fix the T1255474 bug #6

Open
wants to merge 1 commit into
base: 24_2
Choose a base branch
from
Open
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
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
Loading