public: avoid useless copy in Q_timestamp
This commit is contained in:
parent
87775faeca
commit
a758dffbc1
1 changed files with 6 additions and 9 deletions
|
@ -288,7 +288,6 @@ const char* Q_timestamp( int format )
|
||||||
static string timestamp;
|
static string timestamp;
|
||||||
time_t crt_time;
|
time_t crt_time;
|
||||||
const struct tm *crt_tm;
|
const struct tm *crt_tm;
|
||||||
string timestring;
|
|
||||||
|
|
||||||
time( &crt_time );
|
time( &crt_time );
|
||||||
crt_tm = localtime( &crt_time );
|
crt_tm = localtime( &crt_time );
|
||||||
|
@ -297,33 +296,31 @@ const char* Q_timestamp( int format )
|
||||||
{
|
{
|
||||||
case TIME_FULL:
|
case TIME_FULL:
|
||||||
// Build the full timestamp (ex: "Apr03 2007 [23:31.55]");
|
// Build the full timestamp (ex: "Apr03 2007 [23:31.55]");
|
||||||
strftime( timestring, sizeof( timestring ), "%b%d %Y [%H:%M.%S]", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%b%d %Y [%H:%M.%S]", crt_tm );
|
||||||
break;
|
break;
|
||||||
case TIME_DATE_ONLY:
|
case TIME_DATE_ONLY:
|
||||||
// Build the date stamp only (ex: "Apr03 2007");
|
// Build the date stamp only (ex: "Apr03 2007");
|
||||||
strftime( timestring, sizeof( timestring ), "%b%d %Y", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%b%d %Y", crt_tm );
|
||||||
break;
|
break;
|
||||||
case TIME_TIME_ONLY:
|
case TIME_TIME_ONLY:
|
||||||
// Build the time stamp only (ex: "23:31.55");
|
// Build the time stamp only (ex: "23:31.55");
|
||||||
strftime( timestring, sizeof( timestring ), "%H:%M.%S", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%H:%M.%S", crt_tm );
|
||||||
break;
|
break;
|
||||||
case TIME_NO_SECONDS:
|
case TIME_NO_SECONDS:
|
||||||
// Build the time stamp exclude seconds (ex: "13:46");
|
// Build the time stamp exclude seconds (ex: "13:46");
|
||||||
strftime( timestring, sizeof( timestring ), "%H:%M", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%H:%M", crt_tm );
|
||||||
break;
|
break;
|
||||||
case TIME_YEAR_ONLY:
|
case TIME_YEAR_ONLY:
|
||||||
// Build the date stamp year only (ex: "2006");
|
// Build the date stamp year only (ex: "2006");
|
||||||
strftime( timestring, sizeof( timestring ), "%Y", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%Y", crt_tm );
|
||||||
break;
|
break;
|
||||||
case TIME_FILENAME:
|
case TIME_FILENAME:
|
||||||
// Build a timestamp that can use for filename (ex: "Nov2006-26 (19.14.28)");
|
// Build a timestamp that can use for filename (ex: "Nov2006-26 (19.14.28)");
|
||||||
strftime( timestring, sizeof( timestring ), "%b%Y-%d_%H.%M.%S", crt_tm );
|
strftime( timestamp, sizeof( timestamp ), "%b%Y-%d_%H.%M.%S", crt_tm );
|
||||||
break;
|
break;
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_strncpy( timestamp, timestring, sizeof( timestamp ));
|
|
||||||
|
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue