From 67acd5e2439c24c9a5ec53d4f63b0afa57fdc906 Mon Sep 17 00:00:00 2001 From: Andreas Ronge Date: Fri, 16 Jan 2009 03:33:48 -0800 Subject: [PATCH] Fixed timezone lucene bug [#20 state:resolved] --- lib/lucene/field_info.rb | 7 ++++--- test/lucene/field_info_spec.rb | 1 - test/lucene/index_spec.rb | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/lucene/field_info.rb b/lib/lucene/field_info.rb index 01c5bb315..169d6fa3b 100644 --- a/lib/lucene/field_info.rb +++ b/lib/lucene/field_info.rb @@ -54,9 +54,10 @@ def convert_to_ruby(value) when Date.to_s return value if value.kind_of? Date return nil if value.nil? - date = org.apache.lucene.document.DateTools.stringToDate(value) - seconds_since_1970 = date.getTime / 1000 - Date.new(*Time.at(seconds_since_1970).to_a[3 .. 5].reverse) + year = value[0..3].to_i + month = value[4..5].to_i + day = value[6..7].to_i + Date.new year,month,day when DateTime.to_s return value if value.kind_of? DateTime return nil if value.nil? diff --git a/test/lucene/field_info_spec.rb b/test/lucene/field_info_spec.rb index 1e05b29a7..8f87a62b4 100644 --- a/test/lucene/field_info_spec.rb +++ b/test/lucene/field_info_spec.rb @@ -57,7 +57,6 @@ end it "should convert Dates from lucene" do - pending "There is a bug with timezone and dates probably" f = FieldInfo.new f[:type] = Date d = f.convert_to_ruby('20081215') diff --git a/test/lucene/index_spec.rb b/test/lucene/index_spec.rb index 0a3e09957..0f6ac07d6 100644 --- a/test/lucene/index_spec.rb +++ b/test/lucene/index_spec.rb @@ -419,7 +419,6 @@ it "can be used to convert and store Date field" do - pending "There is a bug with timezone and dates probably" #given @index.field_infos[:since][:store] = true @index.field_infos[:since][:type] = Date