Beispiel #1
0
void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
	for (auto &hContact : Contacts()) {
		char *proto = GetContactProto(hContact);
		if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULENAME, "StillAbsentNotified", 0) == 0))
		{
			db_set_b(hContact, MODULENAME, "StillAbsentNotified", 1);
			Skin_PlaySound("buddyExpectatorStillAbsent");

			wchar_t* message = TranslateT("has not returned after a long absence.");
			time_t tmpTime;
			wchar_t tmpBuf[251] = { 0 };
			tmpTime = getLastSeen(hContact);
			if (tmpTime != -1)
			{
				wcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
				message = tmpBuf;
			}
			else
			{
				tmpTime = getLastInputMsg(hContact);
				if (tmpTime != -1)
				{
					wcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime));
					message = tmpBuf;
				}
			}

			GoneNotify(hContact, message);
		}
	}
}
    static inline String formatString (const String& format, const struct tm* const tm)
    {
       #if JUCE_ANDROID
        typedef CharPointer_UTF8  StringType;
       #elif JUCE_WINDOWS
        typedef CharPointer_UTF16 StringType;
       #else
        typedef CharPointer_UTF32 StringType;
       #endif

        for (size_t bufferSize = 256; ; bufferSize += 256)
        {
            HeapBlock<StringType::CharType> buffer (bufferSize);

           #if JUCE_ANDROID
            const size_t numChars = strftime (buffer, bufferSize - 1, format.toUTF8(), tm);
           #elif JUCE_WINDOWS
            const size_t numChars = wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm);
           #else
            const size_t numChars = wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm);
           #endif

            if (numChars > 0 || format.isEmpty())
                return String (StringType (buffer),
                               StringType (buffer) + (int) numChars);
        }
    }
Beispiel #3
0
    static inline String formatString (const String& format, const std::tm* const tm)
    {
       #if JUCE_ANDROID
        typedef CharPointer_UTF8  StringType;
       #elif JUCE_WINDOWS
        typedef CharPointer_UTF16 StringType;
       #else
        typedef CharPointer_UTF32 StringType;
       #endif

       #ifdef JUCE_MSVC
        if (tm->tm_year < -1900 || tm->tm_year > 8099)
            return String();   // Visual Studio's library can only handle 0 -> 9999 AD
        #endif

        for (size_t bufferSize = 256; ; bufferSize += 256)
        {
            HeapBlock<StringType::CharType> buffer (bufferSize);

            const size_t numChars =
                           #if JUCE_ANDROID
                            strftime (buffer, bufferSize - 1, format.toUTF8(), tm);
                           #elif JUCE_WINDOWS
                            wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm);
                           #else
                            wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm);
                           #endif

            if (numChars > 0 || format.isEmpty())
                return String (StringType (buffer),
                               StringType (buffer) + (int) numChars);
        }
    }
Beispiel #4
0
int
main (void)
{
  wchar_t buf[BUF_SIZE];
  struct tm *tp;
  time_t time_list[NUM_OF_DATES] = {
	  500, 68200000, 694223999,
	  694224000, 704900000, 705000000,
	  705900000
  };
  char *locale_list[NUM_OF_LOCALES] = {
	  "C",
	  "fr_FR.ISO-8859-1",
	  "ja_JP.UTF-8"
  };
  int result = 0, ddd, lll;
  size_t n;

  for (lll = 0; lll < NUM_OF_LOCALES; lll++) {
	  printf ("\nUsing locale: %s\n", locale_list[lll]);
	  char* set = setlocale(LC_ALL, locale_list[lll]);
	  if (set == NULL) {
		  printf ("FAILED!\n\n");
		  continue;
	  } else
		  printf ("\n");
	  for (ddd = 0; ddd < NUM_OF_DATES; ddd++) {
		  tp = localtime(&time_list[ddd]);
		  printf ("%ld corresponds to ", time_list[ddd]);

		  n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
				L"%H:%M:%S  %Y-%m-%d%n", tp);
		  if (n != 21) {
			result = 1;
			printf ("FAILED!\n");
		  }

		  printf ("%ls", buf);

		  wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
			L"%tor, as %%D %%T: %D %T%n", tp);
		  printf ("%ls", buf);

		  wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A (%a)%n", tp);
		  printf ("The weekday was %ls", buf);

		  wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%B (%b) %Y%n", tp);
		  /* glibc bug? forgets aigu from french february février
		   * See s/printf (/wprintf (L/g */
		  //wprintf (L"Month was %ls", buf);
		  printf ("Month was %ls", buf);
	  }
  }
  return result;
}
void CAlarmMachine::SetAdemcoEvent(EventSource resource, 
								   int ademco_event, int zone, int subzone,
								   const time_t& timestamp, const time_t& recv_time,
								   const ademco::char_array_ptr& xdata
								   )
{
	AUTO_LOG_FUNCTION;
	std::lock_guard<std::mutex> lock(_lock4AdemcoEventList);
	ademco::AdemcoEventPtr ademcoEvent = std::make_shared<AdemcoEvent>(resource, ademco_event, zone, subzone, timestamp, recv_time, xdata);
	if (EVENT_PRIVATE_EVENT_BASE <= ademco_event && ademco_event <= EVENT_PRIVATE_EVENT_MAX) {
		// 内部事件立即处理
	} else {
#ifdef _DEBUG
		wchar_t wtime[32] = { 0 };
		struct tm tmtm;
		localtime_s(&tmtm, &recv_time);
		wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm);
		JLOG(L"param: %s\n", wtime);
#endif
		time_t now = time(nullptr);
		auto iter = _ademcoEventFilter.begin();
		while (iter != _ademcoEventFilter.end()) {
			const ademco::AdemcoEventPtr& oldEvent = *iter;
#ifdef _DEBUG
			localtime_s(&tmtm, &now);
			wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm);
			JLOG(L"now: %s\n", wtime);
			localtime_s(&tmtm, &oldEvent->_recv_time);
			wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm);
			JLOG(L"old: %s\n", wtime);
#endif
			if (now - oldEvent->_recv_time >= 6) {
				_ademcoEventFilter.erase(iter);
				iter = _ademcoEventFilter.begin();
				continue;
			} else if (oldEvent->operator== (*ademcoEvent)) {
				JLOG(L"same AdemcoEvent, delete it. ademco_id %06d, event %04d, zone %03d, gg %02d\n", 
					 _ademco_id, ademcoEvent->_event, ademcoEvent->_zone, ademcoEvent->_sub_zone);
				_ademcoEventFilter.erase(iter);
				_ademcoEventFilter.push_back(ademcoEvent);
				return;
			}
			iter++;
		}
		_ademcoEventFilter.push_back(ademcoEvent);
	}

	HandleAdemcoEvent(ademcoEvent);
}
Beispiel #6
0
/**
 * Format time of file
 * This function uses different date format string for recent and
 * old files
 *
 * @param __buf - buffer for result
 * @param __buf_size - size of buffer
 * @param __time - time of file
 */
void
format_file_time (wchar_t *__buf, size_t __buf_size, time_t __time)
{
  wchar_t *format;
  struct tm tm;
  time_t now;

  now = time (0);

  /* Convert time_t to struct tm */
  gmtime_r (&__time, &tm);

  /* Get format for date string */
  if (__time < now)
    {
      format = ((now - __time) < DEFAULT_RECENT_PAST * 3600) ?
              DEFAULT_DATE_FORMAT : DEFAULT_OLD_DATE_FORMAT;
    }
  else
    {
      format = ((__time - now) < DEFAULT_RECENT_FUTURE * 3600) ?
              DEFAULT_DATE_FORMAT : DEFAULT_OLD_DATE_FORMAT;
    }

  wcsftime (__buf, __buf_size, format, &tm);
}
Beispiel #7
0
void CPtnZler::OnMenuPattern()
{
	if (!IsBoardLegal())
	{
		window->MessageBox(L"盘面不合法", L"定形局", MB_ICONWARNING | MB_OK);
		return;
	}
	if (window->MessageBox(L"确定以当前盘面进行创作?", L"定形局", MB_ICONQUESTION | MB_OKCANCEL) != IDOK)
		return;

	g_pGameTable->SetZlerBase(this);
	g_pGameTable->SetAction(0);

	//进入Pattern目录
	TCHAR wcsPatternPath[_MAX_PATH];
	wsprintf(wcsPatternPath, L"%s\\Pattern", ModulePath);
	if (_waccess(wcsPatternPath, 0) == -1)
		_wmkdir(wcsPatternPath);
	_wchdir(wcsPatternPath);
	//创建文件夹
	time_t t = time(NULL);
	wcsftime(m_wcsTimeFolder, sizeof(m_wcsTimeFolder) / sizeof(TCHAR), L"%Y%m%d_%H%M%S", localtime(&t)); //Eg: 20130814_210517
	_wmkdir(m_wcsTimeFolder);
	//设置起始文件号
	m_nFileNumber = 1;
	if (!SavePtnTitle(wcsPatternPath))
		return;

	InitSwapRemain();
	ProcessPattern(true);
}
Beispiel #8
0
BOOL CMiniDump::GetDumpFileName(std::wstring& strDump)
{
	time_t timeExcep;
	TCHAR szTime[64] = {0}, szPath[MAX_PATH] = {0};
	TCHAR *pTmp;


	// 创建dump文件夹
	::GetModuleFileName(NULL, szPath, MAX_PATH * sizeof(TCHAR));
    pTmp = wcschr(szPath, '\\');
	if (pTmp != NULL)
		*pTmp = '\0';
	strDump = pTmp;
	strDump += L"Dump\\";
	CreateDirectory(strDump.c_str(), NULL);


	// 获取时间,组成dump文件名
	timeExcep = time(NULL);
	 wcsftime(szTime, sizeof(szTime), L"%Y%m%d%H%M%S", localtime(&timeExcep));
	 strDump += L"DumpFile_";
	 strDump += szTime;
	 strDump += L"_App";
	 strDump += L".dmp";

	return TRUE;
}
Beispiel #9
0
void debug(const wchar_t* format, ...)
{
	wchar_t tmpbuf[128];
	time_t rawtime;
	struct tm timeinfo;
	va_list valist;

	if (!DEBUG && EXECUTE_FROM_GPE)
		return;

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);
	wcsftime(tmpbuf, 128, L"%Y-%m-%d %H:%M:%S ", &timeinfo);

	va_start(valist, format);
	if (!EXECUTE_FROM_GPE){
		fwprintf_s(stdout, L"%ls", tmpbuf);
		vfwprintf_s(stdout, format, valist);
	}
	if (debugfh != NULL && DEBUG) {
		fwprintf_s(debugfh, L"%ls", tmpbuf);
		vfwprintf_s(debugfh, format, valist);
		fflush(debugfh);
	}
	va_end(valist);
}
Beispiel #10
0
/*
 * On win32, strftime() returns the encoding in CP_ACP, which is likely
 * different from SERVER_ENCODING. This is especially important in Japanese
 * versions of Windows which will use SJIS encoding, which we don't support
 * as a server encoding.
 *
 * Replace strftime() with a version that gets the string in UTF16 and then
 * converts it to the appropriate encoding as necessary.
 *
 * Note that this only affects the calls to strftime() in this file, which are
 * used to get the locale-aware strings. Other parts of the backend use
 * pg_strftime(), which isn't locale-aware and does not need to be replaced.
 */
static size_t
strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm *tm)
{
	size_t	len;
	wchar_t	wbuf[MAX_L10N_DATA];
	int		encoding;

	encoding = GetDatabaseEncoding();

	len = wcsftime(wbuf, MAX_L10N_DATA, format, tm);
	if (len == 0)
		/* strftime call failed - return 0 with the contents of dst unspecified */
		return 0;

	len = WideCharToMultiByte(CP_UTF8, 0, wbuf, len, dst, dstlen, NULL, NULL);
	if (len == 0)
		elog(ERROR,
			"could not convert string to UTF-8:error %lu", GetLastError());

	dst[len] = '\0';
	if (encoding != PG_UTF8)
	{
		char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding);
		if (dst != convstr)
		{
			strlcpy(dst, convstr, dstlen);
			len = strlen(dst);
		}
	}

	return len;
}
Beispiel #11
0
//##############################################################################
//# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//##############################################################################
xString xTime::format(xString format)
{
	int formatBaseSize = 16;
	xchar* buffer;
	size_t bufferSize;
	for(int i = 1;;i++)
	{
		bufferSize = format.size() + (formatBaseSize * i);
		buffer = (xchar*) malloc(bufferSize * sizeof(xchar));
		buffer[0] = _T('\1');
		
		#ifndef XTK_UNICODE
			size_t ret = strftime(buffer,bufferSize,format.c_str(),&m_time);
		#else
			size_t ret = wcsftime(buffer,bufferSize,format.c_str(),&m_time);
		#endif
		
		if(((ret < bufferSize) && ret != 0) || (ret == 0 && buffer[0] == _T('\0')))
		{
			xString s(buffer,ret);
			free((void*) buffer);
			return s;
		}
	}
}
Beispiel #12
0
static void GenerateFileName(wchar_t* buffer, size_t length)
{
    /* Generate the default filename from the current date */
    __time64_t t = _time64(NULL);
    struct tm* ltime = _localtime64(&t);
    wcsftime(buffer, length, L"screenshot_%Y-%m-%d_%H-%M-%S.png", ltime);
    free(ltime);
}
Beispiel #13
0
        std::wstring sql_time::to_wstring() const
        {
            wchar_t buf[500] = {0};

            switch (format_) {
                case sql_time::DATE:
                    wcsftime(buf, sizeof(buf), L"%Y-%m-%d", gmtime(&value_));
                    return buf;
                case sql_time::TIME:
                    wcsftime(buf, sizeof(buf), L"%H:%M:%S", gmtime(&value_));
                    return buf;
                case sql_time::TIMESTAMP:
                case sql_time::DATETIME:
                    wcsftime(buf, sizeof(buf), L"%Y-%m-%d %H:%M:%S", gmtime(&value_));
                    return buf;
            }
        }
		std::wstring Format( const DateTimeType & dateTime, const std::wstring & format )
		{
			wchar_t buffer[Utils::DATE_TIME_MAX_SIZE + 1] = { 0 };
			std::tm tm = boost::posix_time::to_tm( dateTime );
			size_t length = wcsftime( buffer, Utils::DATE_TIME_MAX_SIZE, format.c_str(), &tm );
			assert( length < Utils::DATE_TIME_MAX_SIZE );
			return std::wstring( buffer, buffer + length );
		}
Beispiel #15
0
  void ceefit_call_spec FIXTURE::GetSummaryReport(DYNARRAY<SUMMARYITEM>& reportList)
  {
    SUMMARYITEM aItem;

    aItem.Title = "Counts";
    aItem.Value = CountsObj->ToString();
    reportList.Add(aItem);

    aItem.Title = "Input file";
    aItem.Value = SummaryObj->InputFile;
    reportList.Add(aItem);

    wchar_t timeChar[128];
    timeChar[0] = L'\0';
    wcsftime(timeChar, 128, L"%a %b %d %H:%M:%S %X %Y", gmtime(&SummaryObj->InputUpdate));

    aItem.Title = "Input last updated";
    aItem.Value = timeChar;
    reportList.Add(aItem);

    aItem.Title = "Output file";
    aItem.Value = SummaryObj->OutputFile;
    reportList.Add(aItem);

    timeChar[0] = L'\0';
    wcsftime(timeChar, 128, L"%a %b %d %H:%M:%S %X %Y", gmtime(&SummaryObj->RunDate.time));

    aItem.Title = "Run date";
    aItem.Value = timeChar;
    reportList.Add(aItem);

    if(SummaryObj->RunElapsedTime != null)
    {
      aItem.Title = "Run elapsed time";
      aItem.Value = SummaryObj->RunElapsedTime->ToString();
      reportList.Add(aItem);
    }

    if(SummaryObj->CountsRun != null)
    {
      aItem.Title = "counts run";
      aItem.Value = SummaryObj->CountsRun->ToString();
      reportList.Add(aItem);
    }
  }
WCHAR *buildTimestampString(long long timestamp)
{
    WCHAR *buffer = new WCHAR[60];
	tm date;
	timestamp /= 1000;
    localtime_s(&date, &timestamp);
	wcsftime(buffer, 60, L"%Y.%m.%d - %H:%M:%S", &date);
    return buffer;
}
Beispiel #17
0
void Log::endlog(Tlsdata &tlsd, Level clvl)
{
    wchar_t buf[128];
    time_t now_sec;
    usec_t now_usec;
    wstring &strbuf(tlsd.strbuf);

    lck.Enter();
    if (!ffd.open())
        ffd.open(ffd.file());
    ffd.lock();
    now_usec = microtime();
    now_sec = (unsigned)(now_usec / 1000000);
    if (now_sec != last_sec)
    {
        wchar_t *p;
        struct tm *tm;

        tm = localtime(&now_sec);
        wcsftime(buf, sizeof (buf) / sizeof (wchar_t), fmt, tm);
        if (last_fmt != NULL)
            free(last_fmt);
        last_fmt = wcsdup(buf);
        last_sec = now_sec;
        p = wcsstr(last_fmt, USubst);
        upos = p ? (int)(p - last_fmt) : -1;
    }
    strbuf = last_fmt;
    if (upos != -1)
    {
        wsprintf(buf, L"%06u", (unsigned)(now_usec % 1000000));
        strbuf.replace(upos, 2, buf);
    }
    if (!strbuf.empty())
        strbuf += ' ';
    strbuf += LevelStr[clvl];
    if (clvl == Err)
        strbuf += ' ';
    strbuf += ' ';
    if (!tlsd.prefix.empty())
    {
        strbuf += tlsd.prefix;
        strbuf += ' ';
    }
    strbuf.append(tlsd.strm.str(), (unsigned)tlsd.strm.size());
    if (strbuf.at(strbuf.length() - 1) != '\n') {
        strbuf += '\r';
        strbuf += '\n';
    }
    ffd.write(strbuf.c_str(), (unsigned)strbuf.size());
    ffd.unlock();
    lck.Leave();
    tlsd.clvl = None;
    tlsd.space = false;
    tlsd.strm.reset();
}
/// <summary>
/// Helper function to retrieve the local current time
/// </summary>
inline PWCHAR GetLocalCurrentTime(PWCHAR buffer, UINT length)
{
    __time64_t currentTime = _time64(nullptr);
    tm localTime;
    _localtime64_s(&localTime, &currentTime);

    wcsftime(buffer, length, L"%#I:%M %p", &localTime);

    return buffer;
}
Beispiel #19
0
std::wstring FileDescription(const VfsFile& file)
{
	wchar_t timestamp[25];
	const time_t mtime = file.MTime();
	wcsftime(timestamp, ARRAY_SIZE(timestamp), L"%a %b %d %H:%M:%S %Y", localtime(&mtime));

	wchar_t buf[200];
	swprintf_s(buf, ARRAY_SIZE(buf), L"(%c; %6lu; %ls) %ls", file.Loader()->LocationCode(), (unsigned long)file.Size(), timestamp, file.Name().string().c_str());
	return buf;
}
Beispiel #20
0
_WCRTLINK size_t _wstrftime_ms( CHAR_TYPE *s, size_t maxsize, const char *format, const struct tm *timeptr )
{
    wchar_t     *auto_buf;
    int         length;

    length = _mbslen( (unsigned char *)format ) + 1;
    auto_buf = (wchar_t *)alloca( length * CHARSIZE );
    mbstowcs( auto_buf, format, length );
    return( wcsftime( s, maxsize, auto_buf, timeptr ) );
}
Beispiel #21
0
LRESULT CLogSourceInfoDlg::OnInitDialog(HWND , LPARAM)
{
	CDialogResize<CLogSourceInfoDlg>::DlgResize_Init();
	m_list.SubclassWindow(GetDlgItem(IDC_LIST));
	m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);

	struct
	{
		LPCWSTR name;
		int width;
	}columnInfo[] =
	{
		L"进程", 160,
		L"连接时间", 120, 
		L"进程路径", 400,
	};
	for (int i = 0; i < _countof(columnInfo); i++)
	{
		m_list.AddColumn(columnInfo[i].name, i);
		m_list.SetColumnWidth(i, columnInfo[i].width);
	}

	m_image.Create(16, 16, ILC_COLOR32|ILC_MASK, 2, 2);
	m_list.SetImageList(m_image, LVSIL_SMALL);

	int index = 0;
	for (lsds_t::const_iterator it = m_lsds.begin(); it != m_lsds.end(); ++it, ++index)
	{
		int iconIndex = 0;
		HICON hIcon = ::ExtractIconW(ModuleHelper::GetModuleInstance(), it->ppath, 0);
		if (hIcon)
		{
			iconIndex = m_image.AddIcon(hIcon);
			::DestroyIcon(hIcon);
		}

		m_list.AddItem(0, 0, L"", iconIndex);

		struct tm tt;
		localtime_s(&tt, &it->joinTime);
		wchar_t timebuf[256];
		wcsftime(timebuf, _countof(timebuf), L"%Y-%m-%d %H:%M:%S", &tt);

		wchar_t pidbuf[1024];
		swprintf_s(pidbuf, L"%s(%u)", (LPCWSTR)it->pname, it->pid);

		m_list.SetItemText(0, 0, pidbuf);
		m_list.SetItemText(0, 1, timebuf);
		m_list.SetItemText(0, 2, it->ppath);
	}

	CenterWindow(GetParent());

	return 0;
}
Beispiel #22
0
 int doFTime (CharPointer_UTF32 dest, const size_t maxChars, const String& format, const struct tm* const tm) noexcept
 {
    #if JUCE_ANDROID
     HeapBlock <char> tempDest;
     tempDest.calloc (maxChars + 2);
     const int result = (int) strftime (tempDest, maxChars, format.toUTF8(), tm);
     if (result > 0)
         dest.writeAll (CharPointer_UTF8 (tempDest.getData()));
     return result;
    #elif JUCE_WINDOWS
     HeapBlock <wchar_t> tempDest;
     tempDest.calloc (maxChars + 2);
     const int result = (int) wcsftime (tempDest, maxChars, format.toWideCharPointer(), tm);
     if (result > 0)
         dest.writeAll (CharPointer_UTF16 (tempDest.getData()));
     return result;
    #else
     return (int) wcsftime (dest.getAddress(), maxChars, format.toUTF32(), tm);
    #endif
 }
Beispiel #23
0
 template<class msg_type> void operator()(msg_type & msg) const {
     char_type buffer[64];
     ::time_t t = ::time (nullptr);
     ::tm t_details = m_localtime ? *localtime( &t) : *gmtime( &t);
 #ifdef HPX_LOG_USE_WCHAR_T
     if (0 != wcsftime (buffer, sizeof (buffer), m_format.c_str (), &t_details))
 #else
     if (0 != strftime (buffer, sizeof (buffer), m_format.c_str (), &t_details))
 #endif
         convert::write(buffer, msg);
 }
Beispiel #24
0
std::wstring get_current_timestamp()
{
	const time_t raw_time = time(nullptr);
	tm local_time;
	localtime_s(&local_time, &raw_time);

	std::wstring buffer;
	buffer.resize(100);
	wcsftime(&buffer[0], buffer.size(), L"[%H:%M:%S]", &local_time);
	return buffer;
}
CStringW CTime::FormatGmt(LPCWSTR pFormat) const
{
	CStringW str;
	struct tm Time;
	if (localtime_s(&Time,&m_time))
		return szEmpty;

	wcsftime(str.GetBuffer(1000),1000,pFormat,&Time);
	str.FreeExtra();
	return str;
}
CStringW CTime::FormatGmtW(UINT nFormatID) const
{
	CStringW str,str2;
	struct tm Time;
	if (gmtime_s(&Time,&m_time))
		return szEmpty;

	str2.LoadString(nFormatID);
	wcsftime(str.GetBuffer(1000),1000,str2,&Time);
	str.FreeExtra();
	return str;
}
Beispiel #27
0
String __internal_to_string(struct tm time)
{
   // YYYY-MM-DD hh:mm:ss

#ifndef HX_UTF8_STRINGS
   wchar_t buf[100];
   wcsftime(buf,100,L"%Y-%m-%d %H:%M:%S", &time);
#else
   char buf[100];
   strftime(buf,100, "%Y-%m-%d %H:%M:%S", &time);
#endif
   return String(buf).dup();
}
Beispiel #28
0
String __hxcpp_to_string(double inSeconds)
{
   time_t t = (time_t)inSeconds;
   struct tm *time = localtime(&t);
#ifndef HX_UTF8_STRINGS
   wchar_t buf[100];
   wcsftime(buf,100,L"%Y-%m-%d %H:%M:%S", time);
#else
   char buf[100];
   strftime(buf,100,"%Y-%m-%d %H:%M:%S", time);
#endif
   return String(buf).dup();
}
TEST(wchar, wcsftime) {
  setenv("TZ", "UTC", 1);

  struct tm t;
  memset(&t, 0, sizeof(tm));
  t.tm_year = 200;
  t.tm_mon = 2;
  t.tm_mday = 10;

  wchar_t buf[64];

  EXPECT_EQ(24U, wcsftime(buf, sizeof(buf), L"%c", &t));
  EXPECT_STREQ(L"Sun Mar 10 00:00:00 2100", buf);
}
Beispiel #30
0
/**
 * Converts a date/time into a human-readable string
 * using the ISO 8601 standard.
 * @param time Value in timestamp format.
 * @return String pair with date and time.
 */
std::pair<std::wstring, std::wstring> timeToString(time_t time)
{
	wchar_t localDate[25], localTime[25];

/*#ifdef _WIN32
	LARGE_INTEGER li;
	li.QuadPart = time;
	FILETIME ft;
	ft.dwHighDateTime = li.HighPart;
	ft.dwLowDateTime = li.LowPart;
	SYSTEMTIME st;
	FileTimeToLocalFileTime(&ft, &ft);
	FileTimeToSystemTime(&ft, &st);

	GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, localDate, 25);
	GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, localTime, 25);
#endif*/

	struct tm *timeinfo = localtime(&(time));
	wcsftime(localDate, 25, L"%Y-%m-%d", timeinfo);
	wcsftime(localTime, 25, L"%H:%M", timeinfo);

	return std::make_pair(localDate, localTime);
}