From 48f113ad596804ed5c6d0e97de2a1a6ff5ae58e8 Mon Sep 17 00:00:00 2001 From: Jochen Tucht Date: Sun, 14 Oct 2007 12:11:48 +0000 Subject: [PATCH] Patch #1804762 continued --- Src/DirCmpReport.cpp | 4 ++-- Src/DirViewColItems.cpp | 2 +- Src/locality.cpp | 28 ++++++++++++++++++++++++++++ Src/locality.h | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Src/DirCmpReport.cpp b/Src/DirCmpReport.cpp index a7f9f8439..710e8ecf8 100644 --- a/Src/DirCmpReport.cpp +++ b/Src/DirCmpReport.cpp @@ -10,7 +10,7 @@ #include "stdafx.h" #include -#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; } diff --git a/Src/DirViewColItems.cpp b/Src/DirViewColItems.cpp index 3c151507a..afa35f814 100644 --- a/Src/DirViewColItems.cpp +++ b/Src/DirViewColItems.cpp @@ -268,7 +268,7 @@ static String ColTimeGet(const CDiffContext *, const void *p) { const __int64 &r = *static_cast(p); if (r) - return TimeString(&r); + return locality::TimeString(&r); else return _T(""); } diff --git a/Src/locality.cpp b/Src/locality.cpp index 97ba11713..537d5afd2 100644 --- a/Src/locality.cpp +++ b/Src/locality.cpp @@ -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 diff --git a/Src/locality.h b/Src/locality.h index 710d1135a..97ad90ec7 100644 --- a/Src/locality.h +++ b/Src/locality.h @@ -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); }; -- 2.11.0