OSDN Git Service

In log, format Author Date from regional settings. Added CAppUtils::FormatDateAndTime...
authorColin Law <colin@clanlaw.org.uk>
Wed, 28 Jan 2009 20:35:02 +0000 (20:35 +0000)
committerFrank Li <lznuaa@gmail.com>
Thu, 29 Jan 2009 14:43:30 +0000 (22:43 +0800)
src/TortoiseGitBlame/TortoiseGitBlameView.cpp
src/TortoiseGitBlame/TortoiseGitBlameView.h
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/FileDiffDlg.cpp
src/TortoiseProc/GitDiff.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h

index 4cb6c39..e2d9161 100644 (file)
@@ -27,6 +27,7 @@
 #include "MainFrm.h"\r
 #include "Balloon.h"\r
 #include "EditGotoDlg.h"\r
+#include "AppUtils.h"\r
 \r
 #ifdef _DEBUG\r
 #define new DEBUG_NEW\r
@@ -106,6 +107,16 @@ CTortoiseGitBlameView::CTortoiseGitBlameView()
 \r
     m_FindDialogMessage   =   ::RegisterWindowMessage(FINDMSGSTRING);   \r
        m_pFindDialog = NULL;\r
+       // get short/long datetime setting from registry\r
+       DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), FALSE);\r
+       if ( RegUseShortDateFormat )\r
+       {\r
+               m_DateFormat = DATE_SHORTDATE;\r
+       }\r
+       else\r
+       {\r
+               m_DateFormat = DATE_LONGDATE;\r
+       }\r
 }\r
 \r
 CTortoiseGitBlameView::~CTortoiseGitBlameView()\r
@@ -2606,7 +2617,7 @@ void CTortoiseGitBlameView::OnMouseHover(UINT nFlags, CPoint point)
                                CString str;\r
                                str.Format(_T("%s\n<b>%s</b>\n%s\n%s"),pRev->m_CommitHash,\r
                                                                                                           pRev->m_Subject,\r
-                                                                                                          pRev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),\r
+                                                                                                          CAppUtils::FormatDateAndTime( pRev->m_AuthorDate, m_DateFormat ), \r
                                                                                                           pRev->m_Body);\r
                                m_ToolTip.AddTool(this,str);\r
                                m_ToolTip.DisplayToolTip(&point);\r
index fd5f837..35d7ba7 100644 (file)
@@ -215,6 +215,7 @@ protected:
 \r
     CFindReplaceDialog          *m_pFindDialog;\r
 \r
+       DWORD                                           m_DateFormat;   // DATE_SHORTDATE or DATE_LONGDATE\r
 };\r
 \r
 #ifndef _DEBUG  // debug version in TortoiseGitBlameView.cpp\r
index f6ebd3f..456c419 100644 (file)
@@ -1592,4 +1592,31 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)
        }\r
 #endif\r
        return bRet;\r
-}
\ No newline at end of file
+}\r
+\r
+/**\r
+ * FUNCTION    :   FormatDateAndTime\r
+ * DESCRIPTION :   Generates a displayable string from a CTime object in\r
+ *                 system short or long format dependant on setting of option\r
+ *                                as DATE_SHORTDATE or DATE_LONGDATE   \r
+ * RETURN      :   CString containing date/time\r
+ */\r
+CString CAppUtils::FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime /*=true*/  )\r
+{\r
+    SYSTEMTIME sysTime;\r
+       cTime.GetAsSystemTime( sysTime );\r
+       CString datetime;\r
+\r
+    TCHAR buf[100];\r
+\r
+    GetDateFormat(LOCALE_USER_DEFAULT, option, &sysTime, NULL, buf, \r
+                                                           sizeof(buf)/sizeof(TCHAR)-1);\r
+    datetime = buf;\r
+       if ( bIncludeTime )\r
+       {\r
+               datetime += _T(" ");\r
+               GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf)/sizeof(TCHAR)-1);\r
+               datetime += buf;\r
+       }\r
+       return datetime;\r
+}\r
index 45fc0b0..626aaa8 100644 (file)
@@ -167,6 +167,16 @@ public:
        static bool IgnoreFile(CTGitPath &file, bool IsMask);\r
        static bool GitReset(CString *CommitHash,int type=1);\r
        static bool ConflictEdit(CTGitPath &file,bool bAlternativeTool=false);\r
+       /**\r
+        * FUNCTION    :   FormatDateAndTime\r
+        * DESCRIPTION :   Generates a displayable string from a CTime object in\r
+        *                 system short or long format dependant on setting of option\r
+        *                                 as DATE_SHORTDATE or DATE_LONGDATE. bIncludeTime (optional) includes time.\r
+        * RETURN      :   CString containing date/time\r
+        */\r
+       static CString FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime=true );\r
+\r
+       \r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
        static bool GetMimeType(const CTGitPath& file, CString& mimetype);\r
index 6bf152a..428e3a9 100644 (file)
@@ -889,8 +889,10 @@ void CFileDiffDlg::SetURLLabels()
        SetDlgItemText(IDC_FIRSTURL, m_rev1.m_Subject+CString(_T("\r\n"))+m_rev1.m_CommitHash);\r
        SetDlgItemText(IDC_SECONDURL,m_rev2.m_Subject+CString(_T("\r\n"))+m_rev2.m_CommitHash);\r
 \r
-       m_tooltips.AddTool(IDC_FIRSTURL,  m_rev1.m_AuthorDate.Format(_T("%Y-%m-%d  "))+m_rev1.m_AuthorName);\r
-       m_tooltips.AddTool(IDC_SECONDURL, m_rev2.m_AuthorDate.Format(_T("%Y-%m-%d  "))+m_rev2.m_AuthorName);\r
+       m_tooltips.AddTool(IDC_FIRSTURL,  \r
+               CAppUtils::FormatDateAndTime( m_rev1.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev1.m_AuthorName);\r
+       m_tooltips.AddTool(IDC_SECONDURL, \r
+               CAppUtils::FormatDateAndTime( m_rev2.m_AuthorDate, DATE_SHORTDATE, false )+_T("  ")+m_rev2.m_AuthorName);\r
 \r
 }\r
 \r
index ff446c1..2da12e5 100644 (file)
@@ -88,7 +88,7 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, gi
        if(rev2 != GIT_REV_ZERO)\r
        {\r
                \r
-               file2.Format(_T("%s\\%s_%s%s"),\r
+               file2.Format(_T("%s%s_%s%s"),\r
                                temppath,                                               \r
                                pPath2->GetBaseFilename(),\r
                                rev2.Left(6),\r
index da63694..7d69050 100644 (file)
@@ -47,7 +47,6 @@
 #include "..\\TortoiseShell\\Resource.h"\r
 \r
 \r
-\r
 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)\r
 \r
 CGitLogListBase::CGitLogListBase():CHintListCtrl()\r
@@ -96,6 +95,16 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        {\r
                m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));\r
        }\r
+       // get short/long datetime setting from registry\r
+       DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), FALSE);\r
+       if ( RegUseShortDateFormat )\r
+       {\r
+               m_DateFormat = DATE_SHORTDATE;\r
+       }\r
+       else\r
+       {\r
+               m_DateFormat = DATE_LONGDATE;\r
+       }\r
 }\r
 \r
 CGitLogListBase::~CGitLogListBase()\r
@@ -891,7 +900,9 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                break;\r
        case this->LOGLIST_DATE: //Date\r
                if (pLogEntry)\r
-                       lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);\r
+                       lstrcpyn(pItem->pszText,\r
+                               CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ), \r
+                               pItem->cchTextMax);\r
                break;\r
                \r
        case 5:\r
@@ -1184,7 +1195,7 @@ void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
                                sLogCopyText.Format(_T("%s: %s\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),\r
                                        (LPCTSTR)sRev, pLogEntry->m_CommitHash,\r
                                        (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,\r
-                                       (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),\r
+                                       (LPCTSTR)sDate, (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ),\r
                                        (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,\r
                                        (LPCTSTR)sPaths);\r
                                sClipdata +=  sLogCopyText;\r
index 16b99f0..9b27658 100644 (file)
@@ -223,6 +223,7 @@ protected:
        CString                         m_CurrentBranch;\r
        \r
        COLORREF                        m_LineColors[Lanes::COLORS_NUM];\r
+       DWORD                           m_DateFormat;   // DATE_SHORTDATE or DATE_LONGDATE\r
 };\r
 \r
 \r