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

fix(TMC-27619/cellDate): enable tz conversion with sourceTz #5332

Merged
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
5 changes: 5 additions & 0 deletions .changeset/five-ears-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talend/react-components": patch
---

fix(TMC-27619/cellDate): enable tz offset conversion with sourceTz
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function computeValue(cellData, columnData, t) {
} else if (columnData.mode === 'format') {
if (columnData.timeZone) {
return dateUtils.formatToTimeZone(dateFNS, columnData.pattern || DATE_TIME_FORMAT, {
...(columnData.sourceTimeZone && { sourceTimeZone: columnData.sourceTimeZone }),
timeZone: columnData.timeZone,
locale: getLocale(t),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,22 @@ describe('CellDatetime', () => {
mode: 'format',
pattern: 'YYYY-MM-DD HH:mm:ss',
timeZone: 'Pacific/Niue',
sourceTimeZone: 'Europe/Paris',
};
const t = jest.fn();

const cellData = 1474495200000;
computeValue(cellData, columnData, t);
const expectedStrDate = '2016-09-22 09:00:00';
const computedStrOffset = computeValue(cellData, columnData, t);

// then
expect(computedStrOffset).toEqual(expectedStrDate);
expect(dateUtils.formatToTimeZone).toHaveBeenCalledWith(
new Date(cellData),
columnData.pattern,
{
timeZone: columnData.timeZone,
sourceTimeZone: columnData.sourceTimeZone,
locale: getLocale(t),
},
);
Expand Down
Loading