Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@nextcloud.com>2022-10-03 11:47:27 +0300
committerClaudio Cambra <claudio.cambra@nextcloud.com>2022-10-31 20:06:09 +0300
commit79c0f3464a28159bddcb783722a01663c31a3bc5 (patch)
treebe598e66c249f1c44202df58bfeb7d92ec87cdf6
parentff4a4c63a1b63f5acb81fcf0616d251a93e1766d (diff)
Fix default date parser handling of timezones
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
-rw-r--r--src/gui/filedetails/ShareDelegate.qml13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/filedetails/ShareDelegate.qml b/src/gui/filedetails/ShareDelegate.qml
index a7632f712..7b8626e7b 100644
--- a/src/gui/filedetails/ShareDelegate.qml
+++ b/src/gui/filedetails/ShareDelegate.qml
@@ -599,7 +599,10 @@ GridLayout {
// https://invent.kde.org/pim/kalendar/-/blob/release/22.08/src/contents/ui/KalendarUtils/dateutils.js
function parseDateString(dateString) {
function defaultParse() {
- return Date.fromLocaleDateString(Qt.locale(), dateString, Locale.NarrowFormat);
+ const defaultParsedDate = Date.fromLocaleDateString(Qt.locale(), dateString, Locale.NarrowFormat);
+ // JS always generates date in system locale, eliminate timezone difference to UTC
+ const msecsSinceEpoch = defaultParsedDate.getTime() - (defaultParsedDate.getTimezoneOffset() * 60 * 1000);
+ return new Date(msecsSinceEpoch);
}
const dateStringDelimiterMatches = dateString.match(/\D/);
@@ -626,6 +629,7 @@ GridLayout {
if(splitDateString.length === 0 ||
splitDateString.length > 3 ||
userProvidedYear.length >= stringifiedCurrentYear.length) {
+
return defaultParse();
}
@@ -640,6 +644,8 @@ GridLayout {
const monthIndexNum = Number(splitDateString[localisedDateMonthPosition]) - 1;
const dayNum = Number(splitDateString[localisedDateDayPosition]);
+ console.log(dayNum, monthIndexNum, fixedYearNum);
+
// Modification: return date in UTC
return new Date(Date.UTC(fixedYearNum, monthIndexNum, dayNum));
}
@@ -647,6 +653,7 @@ GridLayout {
Layout.fillWidth: true
height: visible ? implicitHeight : 0
+
// We want all the internal benefits of the spinbox but don't actually want the
// buttons, so set an empty item as a dummy
up.indicator: Item {}
@@ -680,6 +687,10 @@ GridLayout {
!root.waitingForExpireDateEnabledChange
onValueModified: {
+ if (!enabled || !activeFocus) {
+ return;
+ }
+
root.setExpireDate(value * dayInMSecs);
root.waitingForExpireDateChange = true;
}