lucene-lucene-net-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1094726 - in /incubator/lucene.net/trunk/C#/src/Lucene.Net: Document/DateField.cs SupportClass.cs
Date Mon, 18 Apr 2011 20:11:21 GMT
Author: digy
Date: Mon Apr 18 20:11:21 2011
New Revision: 1094726

URL: http://svn.apache.org/viewvc?rev=1094726&view=rev
Log:
[LUCENENET-409] Invalid Base exception in DateField.StringToTime()

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/DateField.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/DateField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Document/DateField.cs?rev=1094726&r1=1094725&r2=1094726&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/DateField.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Document/DateField.cs Mon Apr 18 20:11:21
2011
@@ -123,12 +123,16 @@ namespace Lucene.Net.Documents
 		/// <summary>Converts a string-encoded date into a millisecond time. </summary>
 		public static long StringToTime(System.String s)
 		{
-            return System.Convert.ToInt64(s, SupportClass.Character.MAX_RADIX);
+            return SupportClass.Number.Parse(s, SupportClass.Number.MAX_RADIX);
 		}
 		/// <summary>Converts a string-encoded date into a Date object. </summary>
-		public static System.DateTime StringToDate(System.String s)
-		{
-			return new System.DateTime(StringToTime(s));
-		}
+        public static System.DateTime StringToDate(System.String s)
+        {
+            long ticks = StringToTime(s) * TimeSpan.TicksPerMillisecond;
+            System.DateTime date = new System.DateTime(1970, 1, 1);
+            date = date.AddTicks(ticks);
+            date = date.Add(TimeZone.CurrentTimeZone.GetUtcOffset(date));
+            return date;
+        }
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/SupportClass.cs?rev=1094726&r1=1094725&r2=1094726&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/SupportClass.cs Mon Apr 18 20:11:21 2011
@@ -699,7 +699,7 @@ public class SupportClass
         public static long ToInt64(System.String s)
         {
             long number = 0;
-            int factor;
+            long factor;
 
             // handle negative number
             if (s.StartsWith("-"))



Mime
View raw message