diff --git a/CHANGELOG.md b/CHANGELOG.md index 65a7e8279a..d729dd630a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixes [#4718](https://github.com/microsoft/BotFramework-WebChat/issues/4718). In high contrast mode, Adaptive Card buttons, when pushed, should highlighted properly, by [@compulim](https://github.com/compulim), in PR [#4746](https://github.com/microsoft/BotFramework-WebChat/pull/4746) - Fixes [#4721](https://github.com/microsoft/BotFramework-WebChat/issues/4721) and [#4726](https://github.com/microsoft/BotFramework-WebChat/issues/4726). Adaptive Cards `TextBlock` heading elements should start at level 2, by [@compulim](https://github.com/compulim), in PR [#4747](https://github.com/microsoft/BotFramework-WebChat/issues/4747) +- Fixes [#3699](https://github.com/microsoft/BotFramework-WebChat/issues/3699). Correcting timestamp roundoff, by [@compulim](https://github.com/compulim), in PR [#4821](https://github.com/microsoft/BotFramework-WebChat/pull/4821) ## [4.15.8] - 2023-06-06 diff --git a/__tests__/html/timestamp.roundOff.html b/__tests__/html/timestamp.roundOff.html new file mode 100644 index 0000000000..fbea0d85d0 --- /dev/null +++ b/__tests__/html/timestamp.roundOff.html @@ -0,0 +1,84 @@ + + +
+ + + + + + + + + + diff --git a/__tests__/html/timestamp.roundOff.js b/__tests__/html/timestamp.roundOff.js new file mode 100644 index 0000000000..f906cfbe37 --- /dev/null +++ b/__tests__/html/timestamp.roundOff.js @@ -0,0 +1,5 @@ +/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ + +describe('timestamp', () => { + test('should round off correctly', () => runHTML('timestamp.roundOff.html')); +}); diff --git a/packages/api/src/hooks/useRelativeTimeFormatter.ts b/packages/api/src/hooks/useRelativeTimeFormatter.ts index 2d2c29f086..24a9bb3b27 100644 --- a/packages/api/src/hooks/useRelativeTimeFormatter.ts +++ b/packages/api/src/hooks/useRelativeTimeFormatter.ts @@ -41,9 +41,9 @@ export default function useRelativeTimeFormatter(): (dateOrString: Date | string return localize('ACTIVITY_STATUS_TIMESTAMP_ONE_HOUR_AGO'); } else if (deltaInHours < 5) { return relativeTimeFormatter('hour')(-deltaInHours); - } else if (deltaInHours <= 24) { + } else if (deltaInMs <= 24 * 3_600_000) { return localize('ACTIVITY_STATUS_TIMESTAMP_TODAY'); - } else if (deltaInHours <= 48) { + } else if (deltaInMs <= 48 * 3_600_000) { return localize('ACTIVITY_STATUS_TIMESTAMP_YESTERDAY'); }