IDS_GIT_LOG_TAB "Git Log"\r
END\r
\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_YEAR_AGO\r
+ "%1!d! Year ago"\r
+ IDS_YEARS_AGO\r
+ "%1!d! Years ago"\r
+ IDS_MONTH_AGO\r
+ "%1!d! Month ago"\r
+ IDS_MONTHS_AGO\r
+ "%1!d! Months ago"\r
+ IDS_WEEK_AGO\r
+ "%1!d! Week ago"\r
+ IDS_WEEKS_AGO\r
+ "%1!d! Weeks ago"\r
+ IDS_DAY_AGO\r
+ "%1!d! Day ago"\r
+ IDS_DAYS_AGO\r
+ "%1!d! Days ago"\r
+ IDS_HOUR_AGO\r
+ "%1!d! Hour ago"\r
+ IDS_HOURS_AGO\r
+ "%1!d! Hours ago"\r
+ IDS_MINUTE_AGO\r
+ "%1!d! Minute ago"\r
+ IDS_MINUTES_AGO\r
+ "%1!d! minutes ago"\r
+ IDS_SECOND_AGO\r
+ "%1!d! Second ago"\r
+ IDS_SECONDS_AGO\r
+ "%1!d! Seconds ago"\r
+END\r
+\r
#endif // English (U.S.) resources\r
/////////////////////////////////////////////////////////////////////////////\r
\r
#define IDD_GOTODLG 221\r
#define IDC_LINENUMBER 222\r
\r
+#define IDS_YEAR_AGO 9605\r
+#define IDS_YEARS_AGO 9606\r
+#define IDS_MONTH_AGO 9607\r
+#define IDS_MONTHS_AGO 9608\r
+#define IDS_WEEK_AGO 9609\r
+#define IDS_WEEKS_AGO 9610\r
+#define IDS_DAY_AGO 9611\r
+#define IDS_DAYS_AGO 9612\r
+#define IDS_HOUR_AGO 9613\r
+#define IDS_HOURS_AGO 9614\r
+#define IDS_MINUTE_AGO 9615\r
+#define IDS_MINUTES_AGO 9616\r
+#define IDS_SECOND_AGO 9617\r
+#define IDS_SECONDS_AGO 9618\r
\r
#define IDS_STATUS_PANE1 20122\r
#define IDS_STATUS_PANE2 20123\r
//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
+ answer.LoadString(9604);\r
+ answer.LoadString(9605);\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
* Generates a display string showing the relative time between the two given times as COleDateTimes\r
*/\r
static CString ToRelativeTimeString(COleDateTime time,COleDateTime RelativeTo);\r
+ static CString ExpandRelativeTime( int count, UINT format_1, UINT format_n );\r
};\r
//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
* Generates a display string showing the relative time between the two given times as COleDateTimes\r
*/\r
static CString ToRelativeTimeString(COleDateTime time,COleDateTime RelativeTo);\r
+ static CString ExpandRelativeTime( int count, UINT format_1, UINT format_n );\r
};\r
}\r
// get relative time display setting from registry\r
DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);\r
- m_bRelativeTimes = regRelativeTimes;\r
+ m_bRelativeTimes = (regRelativeTimes != 0);\r
}\r
\r
CGitLogListBase::~CGitLogListBase()\r
\r
COLORREF m_LineColors[Lanes::COLORS_NUM];\r
DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE\r
- BOOL m_bRelativeTimes; // Show relative times\r
+ bool m_bRelativeTimes; // Show relative times\r
};\r
\r
\r