From fd984d5d19c6a5c8391720a28c38a7f9967f251a Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 13 Apr 2023 07:15:44 -0400 Subject: [PATCH] Section date timezone in chat. This fix a 1 day diff because of JS timezone convertion. --- CHANGELOG.md | 5 +++++ linphone-app/ui/modules/Linphone/Chat/Chat.qml | 2 +- linphone-app/ui/modules/Linphone/History/History.qml | 2 +- linphone-app/ui/scripts/Utils/utils.js | 5 ++--- linphone-app/ui/views/App/Main/Conferences.qml | 4 +++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 386577ec9..38feeafff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - File viewer in chats (Image/Animated Image/Video/Texts) with the option to export the file. - Accept/decline CLI commands. +## 5.0.16 - undefined + +### Fixed +- Section date timezone in chat. + ## 5.0.15 - 2023-04-11 ### Fixed diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index cc82c198d..1759a2462 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -155,7 +155,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - text: new Date(section).toLocaleDateString(App.locale) + text: Utils.exactDate(new Date(section)).toLocaleDateString(App.locale) } } } diff --git a/linphone-app/ui/modules/Linphone/History/History.qml b/linphone-app/ui/modules/Linphone/History/History.qml index 46c4a8663..88183701b 100644 --- a/linphone-app/ui/modules/Linphone/History/History.qml +++ b/linphone-app/ui/modules/Linphone/History/History.qml @@ -102,7 +102,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - text: new Date(section).toLocaleDateString(App.locale) + text: Utils.exactDate(new Date(section)).toLocaleDateString(App.locale) } } } diff --git a/linphone-app/ui/scripts/Utils/utils.js b/linphone-app/ui/scripts/Utils/utils.js index 698b25b5b..d098f39d1 100644 --- a/linphone-app/ui/scripts/Utils/utils.js +++ b/linphone-app/ui/scripts/Utils/utils.js @@ -495,11 +495,10 @@ function fromUTC(date){ // return EXACTLY what date has been set (not take account of Locale timezones, eg. Date(2000,0,1) will print january and not december if timezone lead there.) // Use this function for toLocaleString/toLocaleDateString or other function exactDate(date) { - var timeOffset = date.getTimezoneOffset() * 60000 - var exactDate = new Date(date.valueOf() - timeOffset) + var timeOffset = date.getTimezoneOffset() * 60000 // getTimezoneOffset == UTC - locale + var exactDate = new Date(date.valueOf() + timeOffset) // Revert back JS timezone to get initial UTC return exactDate } - // ----------------------------------------------------------------------------- function formatSize (size) { diff --git a/linphone-app/ui/views/App/Main/Conferences.qml b/linphone-app/ui/views/App/Main/Conferences.qml index 9df4c5472..367823569 100644 --- a/linphone-app/ui/views/App/Main/Conferences.qml +++ b/linphone-app/ui/views/App/Main/Conferences.qml @@ -9,6 +9,8 @@ import LinphoneEnums 1.0 import App.Styles 1.0 +import 'qrc:/ui/scripts/Utils/utils.js' as Utils + // ============================================================================= Item{ @@ -139,7 +141,7 @@ Item{ horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - text: new Date(section).toLocaleDateString(App.locale) + text: Utils.exactDate(new Date(section)).toLocaleDateString(App.locale) } } }