OSDN Git Service

Fixes to TortoiseGitBlame for date format from locale. TortoiseGitBlameView and GitDi...
authorColin Law <colin@clanlaw.org.uk>
Thu, 29 Jan 2009 13:56:54 +0000 (13:56 +0000)
committerFrank Li <lznuaa@gmail.com>
Thu, 29 Jan 2009 14:43:34 +0000 (22:43 +0800)
src/TortoiseGitBlame/TortoiseGitBlame.vcproj
src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp [new file with mode: 0644]
src/TortoiseGitBlame/TortoiseGitBlameAppUtils.h [new file with mode: 0644]

index 03c18b0..19157b7 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\TortoiseGitBlameAppUtils.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\TortoiseGitBlameDoc.cpp"\r
                                >\r
                        </File>\r
diff --git a/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp b/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp
new file mode 100644 (file)
index 0000000..752c1e7
--- /dev/null
@@ -0,0 +1,98 @@
+// TortoiseGit - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2003-2008 - TortoiseGit\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#include "StdAfx.h"\r
+#include "resource.h"\r
+//#include "TortoiseProc.h"\r
+//#include "PathUtils.h"\r
+#include "TortoiseGitBlameAppUtils.h"\r
+//#include "GitProperties.h"\r
+//#include "StringUtils.h"\r
+//#include "MessageBox.h"\r
+#include "Registry.h"\r
+//#include "TGitPath.h"\r
+//include "Git.h"\r
+//#include "RepositoryBrowser.h"\r
+//#include "BrowseFolder.h"\r
+//#include "UnicodeUtils.h"\r
+//#include "ExportDlg.h"\r
+//#include "ProgressDlg.h"\r
+//#include "GitAdminDir.h"\r
+//#include "ProgressDlg.h"\r
+//#include "BrowseFolder.h"\r
+//#include "DirFileEnum.h"\r
+//#include "MessageBox.h"\r
+//#include "GitStatus.h"\r
+//#include "CreateBranchTagDlg.h"\r
+//#include "GitSwitchDlg.h"\r
+//#include "ResetDlg.h"\r
+//#include "commctrl.h"\r
+\r
+CAppUtils::CAppUtils(void)\r
+{\r
+}\r
+\r
+CAppUtils::~CAppUtils(void)\r
+{\r
+}\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
+ *                                If HKCU\Software\TortoiseGit\UseSystemLocaleForDates is 0 then use fixed format\r
+ *                                rather than locale\r
+ * RETURN      :   CString containing date/time\r
+ */\r
+CString CAppUtils::FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime /*=true*/  )\r
+{\r
+       CString datetime;\r
+    // should we use the locale settings for formatting the date/time?\r
+       if (CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE))\r
+       {\r
+               // yes\r
+               SYSTEMTIME sysTime;\r
+               cTime.GetAsSystemTime( sysTime );\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
+       }\r
+       else\r
+       {\r
+               // no, so fixed format\r
+               if ( bIncludeTime )\r
+               {\r
+                       datetime = cTime.Format(_T("%Y-%m-%d %H:%M:%S"));\r
+               }\r
+               else\r
+               {\r
+                       datetime = cTime.Format(_T("%Y-%m-%d"));\r
+               }\r
+       }\r
+       return datetime;\r
+}\r
diff --git a/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.h b/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.h
new file mode 100644 (file)
index 0000000..ca38bac
--- /dev/null
@@ -0,0 +1,41 @@
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2003-2008 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+/**\r
+ * \ingroup TortoiseGitBlame\r
+ * An utility class with static functions.\r
+ */\r
+class CAppUtils\r
+{\r
+public:\r
+       CAppUtils(void);\r
+       ~CAppUtils(void);\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. 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
+};\r