summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-23 02:54:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-23 02:54:34 +0300
commit0a776b6ba6632a16a6db773f8fbf0e2362940e7f (patch)
tree593e3398db17b0613bd021f8096dc3ed53386faa /plugins
parent629d82bee5187c24d0a8180f85d03ac941788339 (diff)
fixes #2793 (date setting fails when dates of system & local time differ)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index d17d7d2643..f608a509dd 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -612,7 +612,7 @@ static void PopulateTimeCombo(CCtrlCombo &pCombo, const SYSTEMTIME *tmUtc)
GetSystemTime(&tm2);
if (tmUtc->wDay != tm2.wDay || tmUtc->wMonth != tm2.wMonth || tmUtc->wYear != tm2.wYear) {
// ensure that we start on midnight local time
- SystemTimeToTzSpecificLocalTime(nullptr, (SYSTEMTIME*)tmUtc, &tm2);
+ SystemTimeToTzSpecificLocalTime(nullptr, tmUtc, &tm2);
tm2.wHour = 0;
tm2.wMinute = 0;
tm2.wSecond = 0;
@@ -876,15 +876,19 @@ static bool GetTriggerTime(CCtrlCombo &pCombo, ULONGLONG savedLi, SYSTEMTIME &pD
if (n != -1) {
// use preset value
if (IsRelativeCombo(pCombo)) {
- ULONGLONG li;
- SystemTimeToFileTime(&pDate, (FILETIME*)&li);
- savedLi = li - (li % DayToFileTime) + (savedLi % DayToFileTime);
+ // combine date from pDate (local) and time from savedLi (utc)
+ SYSTEMTIME st, st2;
+ FileTimeToSystemTime((FILETIME *)&savedLi, &st);
+ SystemTimeToTzSpecificLocalTime(nullptr, &st, &st2);
+ st2.wYear = pDate.wYear; st2.wMonth = pDate.wMonth; st2.wDay = pDate.wDay; st2.wDayOfWeek = pDate.wDayOfWeek;
+ SystemTimeToFileTime(&st2, (FILETIME*)&savedLi);
// time offset from ref time ("24:43 (5 Minutes)" etc.)
UINT nDeltaSeconds = pCombo.GetItemData(n);
savedLi += (ULONGLONG)nDeltaSeconds * FILETIME_TICKS_PER_SEC;
- FileTimeToSystemTime((FILETIME*)&savedLi, &pDate);
+ FileTimeToSystemTime((FILETIME*)&savedLi, &st);
+ TzSpecificLocalTimeToSystemTime(nullptr, &st, &pDate);
// if specified time is a small offset (< 10 Minutes) then retain current second count for better accuracy
// otherwise try to match specified time (which never contains seconds only even minutes) as close as possible
@@ -896,10 +900,7 @@ static bool GetTriggerTime(CCtrlCombo &pCombo, ULONGLONG savedLi, SYSTEMTIME &pD
else {
// absolute time (offset from midnight on pDate)
UINT nDeltaSeconds = pCombo.GetItemData(n) & ~0x80000000;
- pDate.wHour = 0;
- pDate.wMinute = 0;
- pDate.wSecond = 0;
- pDate.wMilliseconds = 0;
+ pDate.wHour = pDate.wMinute = pDate.wSecond = pDate.wMilliseconds = 0;
TzLocalSTToFileTime(&pDate, (FILETIME*)&savedLi);
savedLi += (ULONGLONG)nDeltaSeconds * FILETIME_TICKS_PER_SEC;