[mapguide-commits] r8304 - in trunk/MgDev: . Common/Foundation/System Common/MapGuideCommon/Controller
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 16 05:06:53 PDT 2014
Author: jng
Date: 2014-07-16 05:06:53 -0700 (Wed, 16 Jul 2014)
New Revision: 8304
Modified:
trunk/MgDev/
trunk/MgDev/Common/Foundation/System/Util.cpp
trunk/MgDev/Common/Foundation/System/Util.h
trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
Log:
Merged revision(s) 8303 from branches/2.6/MgDev:
#2467: Fix MgOutOfRangeException in v2.6 QUERYMAPFEATURES when working with dates pre-1970. The default ToXmlString() cannot handle dates before unix epoch. The fix is to manually write out the MgDateTime in yyyy-mm-dd hh:mm:ss format. This submission includes a new MgUtil::PadLeft() method to assist in writing out dates in this particular format.
........
Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286,8288-8292,8297,8299,8301
/sandbox/jng/convenience_apis:8263
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163
+ /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286,8288-8292,8297,8299,8301,8303
/sandbox/jng/convenience_apis:8263
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163
Modified: trunk/MgDev/Common/Foundation/System/Util.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.cpp 2014-07-16 12:03:49 UTC (rev 8303)
+++ trunk/MgDev/Common/Foundation/System/Util.cpp 2014-07-16 12:06:53 UTC (rev 8304)
@@ -1253,3 +1253,9 @@
className = qualifiedClassName.substr(index + 1);
}
}
+
+void MgUtil::PadLeft(REFSTRING str, const size_t numChars, wchar_t ch)
+{
+ if (numChars > str.size())
+ str.insert(0, numChars - str.size(), ch);
+}
\ No newline at end of file
Modified: trunk/MgDev/Common/Foundation/System/Util.h
===================================================================
--- trunk/MgDev/Common/Foundation/System/Util.h 2014-07-16 12:03:49 UTC (rev 8303)
+++ trunk/MgDev/Common/Foundation/System/Util.h 2014-07-16 12:06:53 UTC (rev 8304)
@@ -538,6 +538,8 @@
///
static bool GetLinuxMemoryStatus(MgLinuxMemoryStatus* pMemoryStatus);
+ static void PadLeft(REFSTRING str, const size_t numChars, wchar_t ch);
+
static void Int32ToLocaleSpecificString(INT32 val, string& str);
static void Int32ToString(INT32 val, string& str);
Modified: trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp 2014-07-16 12:03:49 UTC (rev 8303)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp 2014-07-16 12:06:53 UTC (rev 8304)
@@ -583,7 +583,41 @@
{
Ptr<MgDateTime> dt = reader->GetDateTime(i);
xmlOut.append(L"<Value>");
- xmlOut.append(dt->ToXmlString());
+ //ToXmlString() won't work with dates before Jan 1, 1970, so use yyyy-mm-dd hh:mm:ss
+ STRING dateStr;
+ STRING str;
+ if (dt->IsDate())
+ {
+ MgUtil::Int32ToString(dt->GetYear(), str);
+ dateStr += str;
+ MgUtil::Int32ToString(dt->GetMonth(), str);
+ dateStr += L"-";
+ MgUtil::PadLeft(str, 2, L'0');
+ dateStr += str;
+ MgUtil::Int32ToString(dt->GetDay(), str);
+ dateStr += L"-";
+ MgUtil::PadLeft(str, 2, L'0');
+ dateStr += str;
+ }
+ if (dt->IsTime())
+ {
+ if (dt->IsDate())
+ {
+ dateStr += L" ";
+ }
+ MgUtil::Int32ToString(dt->GetHour(), str);
+ MgUtil::PadLeft(str, 2, L'0');
+ dateStr += str;
+ MgUtil::Int32ToString(dt->GetMinute(), str);
+ dateStr += L":";
+ MgUtil::PadLeft(str, 2, L'0');
+ dateStr += str;
+ MgUtil::Int32ToString(dt->GetSecond(), str);
+ dateStr += L":";
+ MgUtil::PadLeft(str, 2, L'0');
+ dateStr += str;
+ }
+ xmlOut.append(dateStr);
xmlOut.append(L"</Value>\n");
}
break;
More information about the mapguide-commits
mailing list