+ //Weeks\r
+ if(fabs(ts.GetTotalDays()) >= 14)\r
+ {\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 = 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 = 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 = ExpandRelativeTime( (int)ts.GetTotalMinutes(), IDS_MINUTE_AGO, IDS_MINUTES_AGO );\r
+ return answer;\r
+ }\r
+ //seconds\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
+bool CAppUtils::IsSSHPutty()\r
+{\r
+ CString sshclient=CRegString(_T("Software\\TortoiseGit\\SSH"));\r
+ sshclient=sshclient.MakeLower();\r
+ if(sshclient.Find(_T("plink.exe"),0)>=0)\r
+ {\r
+ return true;\r
+ }\r
+ return false;\r
+}\r
+\r
+CString CAppUtils::GetClipboardLink()\r
+{\r
+ if (!OpenClipboard(NULL))\r
+ return CString();\r
+\r
+ CString sClipboardText;\r
+ HGLOBAL hglb = GetClipboardData(CF_TEXT);\r
+ if (hglb)\r
+ {\r
+ LPCSTR lpstr = (LPCSTR)GlobalLock(hglb);\r
+ sClipboardText = CString(lpstr);\r
+ GlobalUnlock(hglb); \r
+ }\r
+ hglb = GetClipboardData(CF_UNICODETEXT);\r
+ if (hglb)\r
+ {\r
+ LPCTSTR lpstr = (LPCTSTR)GlobalLock(hglb);\r
+ sClipboardText = lpstr;\r
+ GlobalUnlock(hglb); \r
+ }\r
+ CloseClipboard();\r
+\r
+ if(!sClipboardText.IsEmpty())\r
+ {\r
+ if(sClipboardText[0] == _T('\"') && sClipboardText[sClipboardText.GetLength()-1] == _T('\"'))\r
+ sClipboardText=sClipboardText.Mid(1,sClipboardText.GetLength()-2);\r
+\r
+ if(sClipboardText.Find( _T("http://")) == 0)\r
+ return sClipboardText;\r
+ \r
+ if(sClipboardText.Find( _T("https://")) == 0)\r
+ return sClipboardText;\r
+\r
+ if(sClipboardText.Find( _T("git://")) == 0)\r
+ return sClipboardText;\r
+\r
+ if(sClipboardText.Find( _T("ssh://")) == 0)\r
+ return sClipboardText;\r
+\r
+ if(sClipboardText.GetLength()>=2)\r
+ if( sClipboardText[1] == _T(':') )\r
+ if( (sClipboardText[0] >= 'A' && sClipboardText[0] <= 'Z') \r
+ || (sClipboardText[0] >= 'a' && sClipboardText[0] <= 'z') )\r
+ return sClipboardText;\r
+ }\r
+\r
+ return CString(_T(""));\r
+}\r
+\r
+CString CAppUtils::ChooseRepository(CString *path)\r
+{\r
+ CBrowseFolder browseFolder;\r
+ browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
+ CString strCloneDirectory;\r
+ if(path)\r
+ strCloneDirectory=*path;\r
+\r
+ CString title;\r
+ title.LoadString(IDS_CHOOSE_REPOSITORY);\r
+\r
+ browseFolder.SetInfo(title);\r
+\r
+ if (browseFolder.Show(NULL, strCloneDirectory) == CBrowseFolder::OK) \r
+ {\r
+ return strCloneDirectory;\r
+ \r
+ }else\r
+ {\r
+ return CString();\r
+ }\r
+ \r