OSDN Git Service

Add support for 'Use system locale for date/time'.
authorColin Law <colin@clanlaw.org.uk>
Wed, 28 Jan 2009 21:15:15 +0000 (21:15 +0000)
committerFrank Li <lznuaa@gmail.com>
Thu, 29 Jan 2009 14:43:33 +0000 (22:43 +0800)
src/TortoiseProc/AppUtils.cpp

index 456c419..8d680b4 100644 (file)
@@ -1598,25 +1598,44 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)
  * 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
+ *                                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
-    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
+    // 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
-               datetime += _T(" ");\r
-               GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf)/sizeof(TCHAR)-1);\r
-               datetime += buf;\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