errno_t __cdecl _tctime64_s ( _TSCHAR * buffer, size_t sizeInChars, const __time64_t *timp ) { struct tm tmtemp; errno_t e; _VALIDATE_RETURN_ERRCODE( ( ( buffer != NULL ) && ( sizeInChars > 0 ) ), EINVAL ) _RESET_STRING(buffer, sizeInChars); _VALIDATE_RETURN_ERRCODE( ( timp != NULL ), EINVAL ) _VALIDATE_RETURN_ERRCODE_NOEXC( ( *timp >= 0 ), EINVAL ) e = _localtime64_s(&tmtemp, timp); if ( e == 0 ) { e = _tasctime_s(buffer, sizeInChars, &tmtemp); } return e; }
//----------------------------------------------------------------------------- // 設定視窗標題 void SetConsoleWindowTile(IN const nstring &szTitle, IN const nstring &szVer, IN const nstring &szFile) { nstring szWindowTile; if(szTitle.empty() == false) szWindowTile += nsoutf(__T("{} ")) << szTitle; if(szVer.empty() == false) szWindowTile += nsoutf(__T("[Ver:{}]")) << szVer; if(szFile.empty() == false) { struct _stat sStat; struct tm sTMTime; TCHAR szTime[32]; _tstat(szFile.c_str(), &sStat); localtime_s(&sTMTime, &sStat.st_mtime); _tasctime_s(szTime, _countof(szTime), &sTMTime); szWindowTile += nsoutf(__T("[FileTime:{}]")) << szTime; }//if szWindowTile += nsoutf(__T("[PID:{}]")) << _getpid(); SetConsoleTitle(szWindowTile.c_str()); }
_TSCHAR * __cdecl _tasctime ( const struct tm *tb ) { _TSCHAR *p = buf; errno_t e = 0; _TSCHAR *retval; /* holds retval pointer */ _ptiddata ptd = _getptd_noexit(); /* Use per thread buffer area (malloc space, if necessary) */ if (ptd) { #ifdef _UNICODE if ( (ptd->_wasctimebuf != NULL) || ((ptd->_wasctimebuf = (wchar_t *)_calloc_crt(_ASCBUFSIZE, sizeof(wchar_t))) != NULL) ) p = ptd->_wasctimebuf; #else /* _UNICODE */ if ( (ptd->_asctimebuf != NULL) || ((ptd->_asctimebuf = (char *)_calloc_crt(_ASCBUFSIZE, sizeof(char))) != NULL) ) p = ptd->_asctimebuf; #endif /* _UNICODE */ } retval = p; /* save return value for later */ e = _tasctime_s( p, _ASCBUFSIZE, tb ); if ( e != 0 ) { return NULL; } return (retval); }
/****************************************************************************** * \name _tctime_s * \brief Converts a time_t value into a string. * \param buffer Buffer that receives the string (26 characters). * \param numberOfElements Size of the buffer in characters. * \param time Pointer to the UTC time. */ errno_t _tctime_s(_TCHAR *buffer, size_t numberOfElements, const time_t *time) { struct tm _tm; if (localtime_s(&_tm, time) == EINVAL) { return EINVAL; } return _tasctime_s(buffer, numberOfElements, &_tm); }