EgtGeneral 1.6a2 :

- migliorie a CurrDateTime.
This commit is contained in:
Dario Sassi
2015-01-14 21:50:26 +00:00
parent 41e0f65aa7
commit e7695d89e5
2 changed files with 15 additions and 15 deletions
+15 -15
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : StringUtils.cpp Data : 17.03.14 Versione : 1.5c2
// File : StringUtils.cpp Data : 13.01.15 Versione : 1.6a2
// Contenuto : Implementazione delle funzioni di utilità per le stringhe.
//
//
@@ -10,6 +10,7 @@
// 02.12.13 DS Agg. FromString per Vector3d, Point3d e Point3d+W.
// 19.01.14 DS Tokenize con Atom ora funziona su più livelli.
// 17.03.14 DS Agg. CurrDateTime.
// 13.01.15 DS Agg. CurrDateTime.
//
//----------------------------------------------------------------------------
@@ -266,18 +267,17 @@ ReplaceString( std::string& sString, const std::string& sOld, const std::string&
const string
CurrDateTime( void)
{
time_t nClock ;
tm newTime ;
time( &nClock) ;
localtime_s( &newTime, &nClock) ;
char strDate[10] = { '\0'} ;
char strTime[10] = { '\0'} ;
_strdate_s( strDate) ;
_strtime_s( strTime) ;
string sDT = strDate + string( " ") + strTime ;
return sDT ;
// seconds elapsed since midnight, January 1, 1970
time_t _time ;
time( &_time) ;
// structured time
tm _tm ;
if ( localtime_s( &_tm, &_time) != 0)
return "time/date error" ;
// string format
const int DT_LEN = 24 ;
char szDateTime[DT_LEN] = { '\0'} ;
strftime( szDateTime, DT_LEN, "%Y/%m/%d %H:%M:%S", &_tm) ;
string sDateTime = szDateTime ;
return sDateTime ;
}