summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-02-06 08:03:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-02-06 08:03:47 +0000
commit5807edebd5ed84ab394f8c8fde5654ada00d4ed8 (patch)
tree21a0bb892329de0a308ca988391066640d5630fb /plugins
parent8e15570c5ba9955d20fb7f4898ee2be59c014ff3 (diff)
crash fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@3448 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/AutoShutdown/src/utils.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp
index 2bd70e83bc..21f3349b6d 100644
--- a/plugins/AutoShutdown/src/utils.cpp
+++ b/plugins/AutoShutdown/src/utils.cpp
@@ -126,32 +126,34 @@ char* GetWinErrorDescription(DWORD dwLastError)
BOOL SystemTimeToTimeStamp(SYSTEMTIME *st,time_t *timestamp)
{
struct tm ts;
- ts.tm_isdst=-1; /* daylight saving time (-1=compute) */
- ts.tm_sec=st->wSecond; /* 0-59 */
- ts.tm_min=st->wMinute; /* 0-59 */
- ts.tm_hour=st->wHour; /* 0-23 */
- ts.tm_mday=st->wDay; /* 1-31 */
- ts.tm_wday=st->wDayOfWeek; /* 0-6 (Sun-Sat) */
- ts.tm_mon=st->wMonth-1; /* 0-11 (Jan-Dec) */
- ts.tm_year=st->wYear-1900; /* current year minus 1900 */
+ ts.tm_isdst = -1; /* daylight saving time (-1=compute) */
+ ts.tm_sec = st->wSecond; /* 0-59 */
+ ts.tm_min = st->wMinute; /* 0-59 */
+ ts.tm_hour = st->wHour; /* 0-23 */
+ ts.tm_mday = st->wDay; /* 1-31 */
+ ts.tm_wday = st->wDayOfWeek; /* 0-6 (Sun-Sat) */
+ ts.tm_mon = st->wMonth-1; /* 0-11 (Jan-Dec) */
+ ts.tm_year = st->wYear-1900; /* current year minus 1900 */
ts.tm_yday=0; /* 0-365 (Jan1=0) */
- *timestamp=mktime(&ts);
+ *timestamp = mktime(&ts);
return (*timestamp!=-1);
}
BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st)
{
- struct tm *ts = {0};
- localtime_s(ts, &timestamp); /* statically alloced, local time correction */
- if(ts==NULL) return FALSE;
- st->wMilliseconds=0; /* 0-999 (not given in tm) */
- st->wSecond=(WORD)ts->tm_sec; /* 0-59 */
- st->wMinute=(WORD)ts->tm_min; /* 0-59 */
- st->wHour=(WORD)ts->tm_hour; /* 0-23 */
- st->wDay=(WORD)ts->tm_mday; /* 1-31 */
- st->wDayOfWeek=(WORD)ts->tm_wday; /* 0-6 (Sun-Sat) */
- st->wMonth=(WORD)(ts->tm_mon+1); /* 1-12 (Jan-Dec) */
- st->wYear=(WORD)(ts->tm_year+1900); /* 1601-30827 */
+ struct tm ts = {0};
+ errno_t err = localtime_s(&ts, &timestamp); /* statically alloced, local time correction */
+ if (err != 0)
+ return FALSE;
+
+ st->wMilliseconds = 0; /* 0-999 (not given in tm) */
+ st->wSecond = (WORD)ts.tm_sec; /* 0-59 */
+ st->wMinute = (WORD)ts.tm_min; /* 0-59 */
+ st->wHour = (WORD)ts.tm_hour; /* 0-23 */
+ st->wDay = (WORD)ts.tm_mday; /* 1-31 */
+ st->wDayOfWeek = (WORD)ts.tm_wday; /* 0-6 (Sun-Sat) */
+ st->wMonth = (WORD)(ts.tm_mon+1); /* 1-12 (Jan-Dec) */
+ st->wYear = (WORD)(ts.tm_year+1900); /* 1601-30827 */
return TRUE;
}