add AddNumberSuffix

This commit is contained in:
Glenn Maynard
2005-03-31 02:26:37 +00:00
parent b29790f307
commit 9e663cba1e
2 changed files with 19 additions and 0 deletions
+18
View File
@@ -166,6 +166,24 @@ CString Commify( int iNum )
return sReturn;
}
CString AddNumberSuffix( int i )
{
CString sSuffix;
switch( i%10 )
{
case 1: sSuffix = "st"; break;
case 2: sSuffix = "nd"; break;
case 3: sSuffix = "rd"; break;
default: sSuffix = "th"; break;
}
// "11th", "113th", etc.
if( ((i%100) / 10) == 1 )
sSuffix = "th";
return ssprintf("%i", i) + sSuffix;
}
struct tm GetLocalTime()
{
const time_t t = time(NULL);
+1
View File
@@ -198,6 +198,7 @@ CString SecondsToMMSSMsMsMs( float fSecs );
CString PrettyPercent( float fNumerator, float fDenominator );
inline CString PrettyPercent( int fNumerator, int fDenominator ) { return PrettyPercent( float(fNumerator), float(fDenominator) ); }
CString Commify( int iNum );
CString AddNumberSuffix( int i );
struct tm GetLocalTime();