OSDN Git Service

Add Show "No Merge" and "First Parent Only" Option at Show ALL menu button
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameAppUtils.cpp
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "StdAfx.h"\r
20 #include "resource.h"\r
21 #include "TortoiseGitBlameAppUtils.h"\r
22 #include "Registry.h"\r
23 \r
24 CAppUtils::CAppUtils(void)\r
25 {\r
26 }\r
27 \r
28 CAppUtils::~CAppUtils(void)\r
29 {\r
30 }\r
31 \r
32 /**\r
33  * FUNCTION    :   FormatDateAndTime\r
34  * DESCRIPTION :   Generates a displayable string from a CTime object in\r
35  *                 system short or long format dependant on setting of option\r
36  *                                 as DATE_SHORTDATE or DATE_LONGDATE\r
37  *                                 If HKCU\Software\TortoiseGit\UseSystemLocaleForDates is 0 then use fixed format\r
38  *                                 rather than locale\r
39  * RETURN      :   CString containing date/time\r
40  */\r
41 CString CAppUtils::FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime /*=true*/  )\r
42 {\r
43         CString datetime;\r
44     // should we use the locale settings for formatting the date/time?\r
45         if (CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE))\r
46         {\r
47                 // yes\r
48                 SYSTEMTIME sysTime;\r
49                 cTime.GetAsSystemTime( sysTime );\r
50                 \r
51                 TCHAR buf[100];\r
52                 \r
53                 GetDateFormat(LOCALE_USER_DEFAULT, option, &sysTime, NULL, buf, \r
54                         sizeof(buf)/sizeof(TCHAR)-1);\r
55                 datetime = buf;\r
56                 if ( bIncludeTime )\r
57                 {\r
58                         datetime += _T(" ");\r
59                         GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, buf, sizeof(buf)/sizeof(TCHAR)-1);\r
60                         datetime += buf;\r
61                 }\r
62         }\r
63         else\r
64         {\r
65                 // no, so fixed format\r
66                 if ( bIncludeTime )\r
67                 {\r
68                         datetime = cTime.Format(_T("%Y-%m-%d %H:%M:%S"));\r
69                 }\r
70                 else\r
71                 {\r
72                         datetime = cTime.Format(_T("%Y-%m-%d"));\r
73                 }\r
74         }\r
75         return datetime;\r
76 }\r