Skip to content

Commit ed5d7c6

Browse files
jamespriorbarmintor
authored andcommitted
Accept either time format, avoid ends_with?
1 parent 402c14f commit ed5d7c6

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

lib/oai/provider/model/activerecord_wrapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def parse_to_local(time)
187187
time_obj = time
188188
else
189189
begin
190-
if time.ends_with?("Z")
190+
if time[-1] == "Z"
191191
time_obj = Time.strptime(time, "%Y-%m-%dT%H:%M:%SZ")
192192
else
193193
time_obj = Time.strptime(time, "%Y-%m-%d")

lib/oai/provider/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def externalize(value)
9191
def parse_date(value)
9292
return value if value.respond_to?(:strftime)
9393

94-
if provider.granularity == OAI::Const::Granularity::HIGH
94+
if value[-1] == "Z"
9595
Time.strptime(value, "%Y-%m-%dT%H:%M:%SZ").utc
9696
else
9797
Time.strptime(value, "%Y-%m-%d").utc

test/client/helpers/provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ComplexClientProvider < OAI::Provider::Base
1010
source_model ComplexModel.new(100)
1111
end
1212

13-
attr_reader :consumed, :server, :provider
13+
attr_reader :consumed, :server
1414

1515
def initialize(port, mount_point)
1616
@consumed = []

test/client/tc_list_identifiers.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def test_list_full
4747
end
4848

4949
def test_list_with_date_range
50-
$provider_server.provider.class.update_granularity OAI::Const::Granularity::LOW
5150
client = OAI::Client.new 'http://localhost:3333/oai'
5251
from_date = Date.new(1998,1,1)
5352
until_date = Date.new(2002,1,1)

0 commit comments

Comments
 (0)