diff options
author | George Hazan <george.hazan@gmail.com> | 2015-04-08 22:25:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-04-08 22:25:42 +0000 |
commit | 85ef6630cdedb73d7767aa9c6af03304fbe01e47 (patch) | |
tree | 7670688db4f60292e12d62f34928f8a10bea9aee /src/modules/utils/timeutils.cpp | |
parent | 0e830877dda255b570b9939ba92727a323987448 (diff) |
dead code removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@12688 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/utils/timeutils.cpp')
-rw-r--r-- | src/modules/utils/timeutils.cpp | 44 |
1 files changed, 15 insertions, 29 deletions
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);
}
|