2009-07-23 Adam Wendt <adam@awendtconsulting.com>
- * Comparison.cs (Compare): Parse string if other object is DateTime
- regardless of which side the DateTime is on.
+ * Comparison.cs (Compare): Parse string if other object is DateTime
+ regardless of which side the DateTime is on.
2008-08-18 Marek Habersack <mhabersack@novell.com>
// DateTime is always CultureInfo.InvariantCulture
o1 = (IComparable) DateTime.Parse ((string)o1, CultureInfo.InvariantCulture);
}
+ else if (o2 is DateTime && o1 is string && Thread.CurrentThread.CurrentCulture != CultureInfo.InvariantCulture) {
+ // DateTime is always CultureInfo.InvariantCulture
+ o1 = (IComparable) DateTime.Parse ((string)o1, CultureInfo.InvariantCulture);
+ }
if (o1.GetType () != o2.GetType ())
o2 = (IComparable)Convert.ChangeType (o2, o1.GetType ());
2009-07-23 Adam Wendt <adam@awendtconsulting.com>
- * DateComparisonTest.cs
- (TestDateComparisonRight, TestDateComparisonLeft): Test case to
- check that comparison of date and string works regardless of which
- side the existing date is.
+ * DateComparisonTest.cs
+ (TestDateComparisonRight, TestDateComparisonLeft): Test case to
+ check that comparison of date and string works regardless of which
+ side the existing date is.
2007-06-06 Nagappan A <anagappan@novell.com>
using System.Data;
using NUnit.Framework;
+namespace Monotests_Mono.Data.SqlExpressions
+{
+ [TestFixture]
+ public class DateComparisonTest
+ {
+ private DataSet dataSet;
+
+ [SetUp]
+ public void SetUp()
+ {
+ dataSet = new DataSet();
+ dataSet.ReadXml("dateComparisonTest.xml", XmlReadMode.InferSchema);
+ }
+
+ [Test]
+ public void TestDateComparisonRight()
+ {
+ DataView dataView = new DataView(dataSet.Tables["thing"], "#2009-07-19 00:01:00# = start", "", DataViewRowState.CurrentRows);
+ Assert.AreEqual (1, dataView.Count);
+ }
+
+ [Test]
+ public void TestDateComparisonLeft()
+ {
+ DataView dataView = new DataView(dataSet.Tables["thing"], "start = #2009-07-19 00:01:00#", "", DataViewRowState.CurrentRows);
+ Assert.AreEqual (1, dataView.Count);
+ }
+ }
+}
+using System;
+using System.Data;
+using NUnit.Framework;
+
namespace Monotests_Mono.Data.SqlExpressions
{
[TestFixture]
<start>2009-08-19 00:01</start>
</thing>
</things>
+<?xml version="1.0" encoding="utf-8" ?>
+<things>
+<thing>
+ <title>bar</title>
+ <start>2009-07-19 00:01</start>
+</thing>
+<thing>
+ <title>foo</title>
+ <start>2009-08-19 00:01</start>
+</thing>
+</things>