Section date timezone in chat. This fix a 1 day diff because of JS timezone convertion.

This commit is contained in:
Julien Wadel 2023-04-13 07:15:44 -04:00
parent 80bbcb0272
commit fd984d5d19
5 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -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) {

View file

@ -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)
}
}
}