Skip to content
Open
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
13 changes: 12 additions & 1 deletion packages/core/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,5 +805,16 @@ export const getReadableTimeString = (
.replace('mm', minutes)
.replace('ss', seconds);

return `${timeString} (${format})`;
const timezoneOffsetMinutes = -now.getTimezoneOffset();
const timezoneSign = timezoneOffsetMinutes >= 0 ? '+' : '-';
const timezoneHours = String(
Math.floor(Math.abs(timezoneOffsetMinutes) / 60),
).padStart(2, '0');
const timezoneMinutes = String(Math.abs(timezoneOffsetMinutes) % 60).padStart(
2,
'0',
);
const timezone = `UTC${timezoneSign}${timezoneHours}:${timezoneMinutes}`;

return `${timeString} (${format}, ${timezone})`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@
expect(mockInterface.getDeviceLocalTimeString).toHaveBeenCalledWith(
undefined,
);
expect(seenPendingFeedback).toEqual([

Check failure on line 168 in packages/core/tests/unit-test/task-executor-concurrency.test.ts

View workflow job for this annotation

GitHub Actions / main (24.13.0)

tests/unit-test/task-executor-concurrency.test.ts > TaskExecutor concurrency isolation > should use device-local formatted time for replanning feedback

AssertionError: expected [ '', …(1) ] to deeply equal [ '', StringMatching{…} ] - Expected + Received [ "", - StringMatching /^Current time: 2023-10-15 15:37:00 \(YYYY-MM-DD HH:mm:ss, UTC[+-]\d{2}:\d{2}\)$/, + "Current time: 2023-10-15 15:37:00 (YYYY-MM-DD HH:mm:ss)", ] ❯ tests/unit-test/task-executor-concurrency.test.ts:168:33

Check failure on line 168 in packages/core/tests/unit-test/task-executor-concurrency.test.ts

View workflow job for this annotation

GitHub Actions / main (24.13.0)

tests/unit-test/task-executor-concurrency.test.ts > TaskExecutor concurrency isolation > should use device-local formatted time for replanning feedback

AssertionError: expected [ '', …(1) ] to deeply equal [ '', StringMatching{…} ] - Expected + Received [ "", - StringMatching /^Current time: 2023-10-15 15:37:00 \(YYYY-MM-DD HH:mm:ss, UTC[+-]\d{2}:\d{2}\)$/, + "Current time: 2023-10-15 15:37:00 (YYYY-MM-DD HH:mm:ss)", ] ❯ tests/unit-test/task-executor-concurrency.test.ts:168:33
'',
'Current time: 2023-10-15 15:37:00 (YYYY-MM-DD HH:mm:ss)',
expect.stringMatching(
/^Current time: 2023-10-15 15:37:00 \(YYYY-MM-DD HH:mm:ss, UTC[+-]\d{2}:\d{2}\)$/,
),
Comment on lines +170 to +172
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep device-time assertion consistent with mocked return

This expectation now requires a UTC±HH:MM suffix, but in the same test mockInterface.getDeviceLocalTimeString is explicitly mocked to return 2023-10-15 15:37:00 (YYYY-MM-DD HH:mm:ss) without any timezone component, so the regex can never match and the test will fail deterministically when this path is exercised. Either the mock value (and real device implementations) needs to include the timezone suffix, or this assertion should continue to accept the existing device-local format.

Useful? React with 👍 / 👎.

]);
});

Expand Down Expand Up @@ -225,7 +227,9 @@

expect(seenPendingFeedback).toEqual([
'',
'Current time: 2023-10-15 08:30:00 (YYYY-MM-DD HH:mm:ss)',
expect.stringMatching(
/^Current time: 2023-10-15 08:30:00 \(YYYY-MM-DD HH:mm:ss, UTC[+-]\d{2}:\d{2}\)$/,
),
]);
});
});
Loading