1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <kopano/platform.h>
- #include <pthread.h>
- #include <mapix.h>
- #include <ctime>
- #include <iostream>
- #include "ECMapiUtils.h"
- namespace KC {
- FILETIME vmimeDatetimeToFiletime(vmime::datetime dt) {
- FILETIME sFiletime;
- struct tm when;
- int iYear, iMonth, iDay, iHour, iMinute, iSecond, iZone;
- time_t lTmpTime;
- dt.getDate( iYear, iMonth, iDay );
- dt.getTime( iHour, iMinute, iSecond, iZone );
- when.tm_hour = iHour;
- when.tm_min = iMinute - iZone;
- when.tm_sec = iSecond;
- when.tm_mon = iMonth - 1;
- when.tm_mday = iDay;
- when.tm_year = iYear - 1900;
- when.tm_isdst = -1;
- lTmpTime = timegm(&when);
- UnixTimeToFileTime(lTmpTime, &sFiletime);
- return sFiletime;
- }
- vmime::datetime FiletimeTovmimeDatetime(FILETIME ft) {
- time_t tmp;
- struct tm convert;
- FileTimeToUnixTime(ft, &tmp);
- gmtime_safe(&tmp, &convert);
- return vmime::datetime(convert.tm_year + 1900, convert.tm_mon + 1, convert.tm_mday, convert.tm_hour, convert.tm_min, convert.tm_sec);
- }
- }
|