summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/skin/hotkey_opts.cpp3
-rw-r--r--src/modules/utils/timeutils.cpp44
-rw-r--r--src/modules/utils/timezones.cpp33
3 files changed, 27 insertions, 53 deletions
diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp
index f57baa324f..4c41cc0b72 100644
--- a/src/modules/skin/hotkey_opts.cpp
+++ b/src/modules/skin/hotkey_opts.cpp
@@ -617,9 +617,8 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (lpdis->CtlID == IDC_CANVAS) {
sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Actions:"), &rc);
- rc.left += 10;
- rc.left = prefix + width * 0;
+ rc.left = prefix;
ImageList_Draw(hIml, 5, lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, ILD_TRANSPARENT);
rc.left += 20;
sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Undo"), &rc);
diff --git a/src/modules/utils/timeutils.cpp b/src/modules/utils/timeutils.cpp
index 62d47e8cd9..a2f926f74d 100644
--- a/src/modules/utils/timeutils.cpp
+++ b/src/modules/utils/timeutils.cpp
@@ -27,7 +27,7 @@ simple UTC offsets.
#include "..\..\core\commonheaders.h"
-//KB167296
+// KB167296
void UnixTimeToFileTime(mir_time ts, LPFILETIME pft)
{
unsigned __int64 ll = UInt32x32To64(ts, 10000000) + 116444736000000000i64;
@@ -46,15 +46,12 @@ void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int
{
if (szDest == NULL || cbDest == 0) return;
- TCHAR *pDest = szDest;
- int destCharsLeft = cbDest - 1;
+ CMString tszTemp;
- for (const TCHAR* pFormat = szFormat; *pFormat; ++pFormat)
- {
+ for (const TCHAR* pFormat = szFormat; *pFormat; ++pFormat) {
DWORD fmt;
bool date, iso = false;
- switch (*pFormat)
- {
+ switch (*pFormat) {
case 't':
fmt = TIME_NOSECONDS;
date = false;
@@ -85,33 +82,22 @@ void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int
break;
default:
- if (destCharsLeft--)
- *pDest++=*pFormat;
+ tszTemp.AppendChar(*pFormat);
continue;
}
TCHAR dateTimeStr[64];
- int dateTimeStrLen;
-
if (iso)
- {
- dateTimeStrLen = mir_sntprintf(dateTimeStr, SIZEOF(dateTimeStr),
- _T("%d-%02d-%02dT%02d:%02d:%02dZ"),
- st->wYear, st->wMonth, st->wDay,
- st->wHour, st->wMinute, st->wSecond) + 1;
+ tszTemp.AppendFormat(_T("%d-%02d-%02dT%02d:%02d:%02dZ"), st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
+ else if (date) {
+ GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, SIZEOF(dateTimeStr));
+ tszTemp.Append(dateTimeStr);
+ }
+ else {
+ GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, SIZEOF(dateTimeStr));
+ tszTemp.Append(dateTimeStr);
}
- else if (date)
- dateTimeStrLen = GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL,
- dateTimeStr, SIZEOF(dateTimeStr));
- else
- dateTimeStrLen = GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL,
- dateTimeStr, SIZEOF(dateTimeStr));
-
- if (dateTimeStrLen) --dateTimeStrLen;
- if (destCharsLeft < dateTimeStrLen) dateTimeStrLen = destCharsLeft;
- memcpy(pDest, dateTimeStr, dateTimeStrLen * sizeof(dateTimeStr[0]));
- destCharsLeft -= dateTimeStrLen;
- pDest += dateTimeStrLen;
}
- *pDest = 0;
+
+ _tcsncpy_s(szDest, cbDest, tszTemp, _TRUNCATE);
}
diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp
index 46b8f8ce56..e2c271c140 100644
--- a/src/modules/utils/timezones.cpp
+++ b/src/modules/utils/timezones.cpp
@@ -254,16 +254,11 @@ static int timeapiPrintTimeStamp(HANDLE hTZ, mir_time ts, LPCTSTR szFormat, LPTS
if (tz == NULL && (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)))
return 1;
+ if (tz == NULL)
+ tz = &myInfo.myTZ;
+
FILETIME ft;
-
- if (tz == NULL) tz = &myInfo.myTZ;
- if (tz == NULL) {
- FILETIME lft;
-
- UnixTimeToFileTime(ts, &lft);
- FileTimeToLocalFileTime(&lft, &ft);
- }
- else if (tz == UTC_TIME_HANDLE)
+ if (tz == UTC_TIME_HANDLE)
UnixTimeToFileTime(ts, &ft);
else {
if (tz->offset == INT_MIN)
@@ -276,7 +271,6 @@ static int timeapiPrintTimeStamp(HANDLE hTZ, mir_time ts, LPCTSTR szFormat, LPTS
FileTimeToSystemTime(&ft, &st);
FormatTime(&st, szFormat, szDest, cbDest);
-
return 0;
}
@@ -289,16 +283,10 @@ static LPTIME_ZONE_INFORMATION timeapiGetTzi(HANDLE hTZ)
static mir_time timeapiTimeStampToTimeZoneTimeStamp(HANDLE hTZ, mir_time ts)
{
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
+ if (tz == NULL)
+ tz = &myInfo.myTZ;
- if (tz == NULL) tz = &myInfo.myTZ;
- if (tz == NULL) {
- FILETIME ft, lft;
-
- UnixTimeToFileTime(ts, &ft);
- FileTimeToLocalFileTime(&ft, &lft);
- return FileTimeToUnixTime(&lft);
- }
- else if (tz == UTC_TIME_HANDLE)
+ if (tz == UTC_TIME_HANDLE)
return ts;
if (tz->offset == INT_MIN)
@@ -481,18 +469,19 @@ extern "C" __declspec(dllexport) void RecalculateTime(void)
if (pfnGetDynamicTimeZoneInformation && pfnGetDynamicTimeZoneInformation(&dtzi) != TIME_ZONE_ID_INVALID) {
TCHAR *myTzKey = mir_u2t(dtzi.TimeZoneKeyName);
- _tcscpy(myInfo.myTZ.tszName, myTzKey);
+ _tcsncpy_s(myInfo.myTZ.tszName, myTzKey, _TRUNCATE);
mir_free(myTzKey);
found = true;
}
for (int i = 0; i < g_timezones.getCount(); i++) {
MIM_TIMEZONE &tz = g_timezones[i];
- if (tz.offset != INT_MIN) tz.offset = INT_MIN;
+ if (tz.offset != INT_MIN)
+ tz.offset = INT_MIN;
if (!found) {
if (!wcscmp(tz.tzi.StandardName, myInfo.myTZ.tzi.StandardName) || !wcscmp(tz.tzi.DaylightName, myInfo.myTZ.tzi.DaylightName)) {
- _tcscpy(myInfo.myTZ.tszName, tz.tszName);
+ _tcsncpy_s(myInfo.myTZ.tszName, tz.tszName, _TRUNCATE);
found = true;
}
}