OSDN Git Service

Patch #1804762 continued
authorJochen Tucht <jtuc@users.sourceforge.net>
Sun, 14 Oct 2007 12:11:48 +0000 (12:11 +0000)
committerJochen Tucht <jtuc@users.sourceforge.net>
Sun, 14 Oct 2007 12:11:48 +0000 (12:11 +0000)
Src/DirCmpReport.cpp
Src/DirViewColItems.cpp
Src/locality.cpp
Src/locality.h

index a7f9f84..710e8ec 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "stdafx.h"
 #include <time.h>
-#include "UnicodeString.h"
+#include "locality.h"
 #include "DirCmpReport.h"
 #include "DirCmpReportDlg.h"
 #include "coretools.h"
@@ -29,7 +29,7 @@ static String GetCurrentTimeString()
        time_t nTime = 0;
        time(&nTime);
        _int64 nTime64 = nTime;
-       String str = TimeString(&nTime64);
+       String str = locality::TimeString(&nTime64);
        return str;
 }
 
index 3c15150..afa35f8 100644 (file)
@@ -268,7 +268,7 @@ static String ColTimeGet(const CDiffContext *, const void *p)
 {
        const __int64 &r = *static_cast<const __int64*>(p);
        if (r)
-               return TimeString(&r);
+               return locality::TimeString(&r);
        else
                return _T("");
 }
index 97ba117..537d5af 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "StdAfx.h"
 #include "locality.h"
+#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -129,5 +130,32 @@ String GetLocaleStr(LPCTSTR str, int decimalDigits)
        return out;
 }
 
+/**
+ * @brief Return time displayed appropriately, as string
+ */
+String TimeString(const __int64 * tim)
+{
+       USES_CONVERSION;
+       if (!tim) return _T("---");
+       // _tcsftime does not respect user date customizations from
+       // Regional Options/Configuration Regional; COleDateTime::Format does so.
+#if _MSC_VER < 1300
+               // MSVC6
+       COleDateTime odt = (time_t)*tim;
+#else
+               // MSVC7 (VC.NET)
+       COleDateTime odt = *tim;
+#endif
+       // If invalid, return DateTime resource string
+       if (odt.GetStatus() == COleDateTime::null)
+               return String();
+       if (odt.GetStatus() == COleDateTime::invalid)
+               return theApp.LoadString(AFX_IDS_INVALID_DATETIME);
+       COleVariant var;
+       // Don't need to trap error. Should not fail due to type mismatch
+       AfxCheckError(VarBstrFromDate(odt.m_dt, LANG_USER_DEFAULT, 0, &V_BSTR(&var)));
+       var.vt = VT_BSTR;
+       return OLE2CT(V_BSTR(&var));
+}
 
 }; // namespace locality
index 710d113..97ad90e 100644 (file)
@@ -14,6 +14,7 @@ namespace locality {
 String NumToLocaleStr(int n);
 String NumToLocaleStr(__int64 n);
 String GetLocaleStr(LPCTSTR str, int decimalDigits = 0);
+String TimeString(const __int64 * tim);
 
 };