From c79aba0735e670694241c2f107db8caadc512202 Mon Sep 17 00:00:00 2001 From: Colin Law Date: Wed, 28 Jan 2009 21:15:15 +0000 Subject: [PATCH] Add support for 'Use system locale for date/time'. --- src/TortoiseProc/AppUtils.cpp | 45 ++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 456c419..8d680b4 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -1598,25 +1598,44 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool) * FUNCTION : FormatDateAndTime * DESCRIPTION : Generates a displayable string from a CTime object in * system short or long format dependant on setting of option - * as DATE_SHORTDATE or DATE_LONGDATE + * as DATE_SHORTDATE or DATE_LONGDATE + * If HKCU\Software\TortoiseGit\UseSystemLocaleForDates is 0 then use fixed format + * rather than locale * RETURN : CString containing date/time */ CString CAppUtils::FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime /*=true*/ ) { - SYSTEMTIME sysTime; - cTime.GetAsSystemTime( sysTime ); CString datetime; - - TCHAR buf[100]; - - GetDateFormat(LOCALE_USER_DEFAULT, option, &sysTime, NULL, buf, - sizeof(buf)/sizeof(TCHAR)-1); - datetime = buf; - if ( bIncludeTime ) + // should we use the locale settings for formatting the date/time? + if (CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE)) + { + // yes + SYSTEMTIME sysTime; + cTime.GetAsSystemTime( sysTime ); + + TCHAR buf[100]; + + GetDateFormat(LOCALE_USER_DEFAULT, option, &sysTime, NULL, buf, + sizeof(buf)/sizeof(TCHAR)-1); + datetime = buf; + if ( bIncludeTime ) + { + datetime += _T(" "); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf)/sizeof(TCHAR)-1); + datetime += buf; + } + } + else { - datetime += _T(" "); - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf)/sizeof(TCHAR)-1); - datetime += buf; + // no, so fixed format + if ( bIncludeTime ) + { + datetime = cTime.Format(_T("%Y-%m-%d %H:%M:%S")); + } + else + { + datetime = cTime.Format(_T("%Y-%m-%d")); + } } return datetime; } -- 2.11.0