//years\r
if(fabs(ts.GetTotalDays()) >= 3*365)\r
{\r
- answer.FormatMessage(_T("%1!d! Years ago"), (int)(ts.GetTotalDays()/365));\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalDays()/365, IDS_YEAR_AGO, IDS_YEARS_AGO );\r
}\r
//Months\r
if(fabs(ts.GetTotalDays()) >= 60)\r
{\r
- answer.FormatMessage( _T("%1!d! Months ago"), (int)(ts.GetTotalDays()/30) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalDays()/30, IDS_MONTH_AGO, IDS_MONTHS_AGO );\r
return answer;\r
}\r
//Weeks\r
if(fabs(ts.GetTotalDays()) >= 14)\r
{\r
- answer.FormatMessage(_T("%1!d! Weeks ago"), (int)(ts.GetTotalDays()/7) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalDays()/7, IDS_WEEK_AGO, IDS_WEEKS_AGO );\r
return answer;\r
}\r
//Days\r
if(fabs(ts.GetTotalDays()) >= 2)\r
{\r
- answer.FormatMessage(_T("%1!d! Days ago"), (int)(ts.GetTotalDays()) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalDays(), IDS_DAY_AGO, IDS_DAYS_AGO );\r
return answer;\r
}\r
//hours\r
if(fabs(ts.GetTotalHours()) >= 2)\r
{\r
- answer.FormatMessage(_T("%1!d! Hours ago"), (int)(ts.GetTotalHours()) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalHours(), IDS_HOUR_AGO, IDS_HOURS_AGO );\r
return answer;\r
}\r
//minutes\r
if(fabs(ts.GetTotalMinutes()) >= 2)\r
{\r
- answer.FormatMessage(_T("%1!d! Minutes ago"), (int)(ts.GetTotalMinutes()) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalMinutes(), IDS_MINUTE_AGO, IDS_MINUTES_AGO );\r
return answer;\r
}\r
//seconds\r
- answer.FormatMessage(_T("%1!d! Seconds ago"), (int)(ts.GetTotalSeconds()) );\r
+ answer = ExpandRelativeTime( (int)ts.GetTotalSeconds(), IDS_SECOND_AGO, IDS_SECONDS_AGO );\r
return answer;\r
}\r
\r
+/** \r
+ * Passed a value and two resource string ids\r
+ * if count is 1 then FormatString is called with format_1 and the value\r
+ * otherwise format_2 is used\r
+ * the formatted string is returned\r
+*/\r
+CString CAppUtils::ExpandRelativeTime( int count, UINT format_1, UINT format_n )\r
+{\r
+ CString answer;\r
+ if ( count == 1 )\r
+ {\r
+ answer.FormatMessage( format_1, count );\r
+ }\r
+ else\r
+ {\r
+ answer.FormatMessage( format_n, count );\r
+ }\r
+ return answer;\r
+}\r
+\r