OSDN Git Service

In log, format Author Date from regional settings. Added CAppUtils::FormatDateAndTime...
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / AppUtils.cpp
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