DARN YOU RUBY 1.8.7 AND YOUR DIFFERENT TIME.TO_S METHOD
This commit is contained in:
parent
d958fd5679
commit
425885460f
|
@ -40,8 +40,16 @@ def location(folder, direction)
|
||||||
[before || '.', after || '.']
|
[before || '.', after || '.']
|
||||||
end
|
end
|
||||||
|
|
||||||
def seconds_agnostic_time(datetime = Time.now)
|
def seconds_agnostic_datetime(datetime = Time.now)
|
||||||
date, time, zone = datetime.strftime("%Y-%m-%d %H:%M %z").split(" ")
|
pieces = datetime.to_s.split(" ")
|
||||||
|
if pieces.size == 6 # Ruby 1.8.7
|
||||||
|
date = pieces[0..2].join(" ")
|
||||||
|
time = seconds_agnostic_time(pieces[3])
|
||||||
|
zone = pieces[4..5].join(" ")
|
||||||
|
else # Ruby 1.9.1 or greater
|
||||||
|
date, time, zone = pieces
|
||||||
|
time = seconds_agnostic_time(time)
|
||||||
|
end
|
||||||
[
|
[
|
||||||
Regexp.escape(date),
|
Regexp.escape(date),
|
||||||
"#{time}:\\d{2}",
|
"#{time}:\\d{2}",
|
||||||
|
@ -49,5 +57,13 @@ def seconds_agnostic_time(datetime = Time.now)
|
||||||
].join("\\ ")
|
].join("\\ ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def seconds_agnostic_time(time)
|
||||||
|
if time.is_a? Time
|
||||||
|
time = time.strftime("%H:%M:%S")
|
||||||
|
end
|
||||||
|
hour, minutes, _ = time.split(":")
|
||||||
|
"#{hour}:#{minutes}"
|
||||||
|
end
|
||||||
|
|
||||||
# work around "invalid option: --format" cucumber bug (see #296)
|
# work around "invalid option: --format" cucumber bug (see #296)
|
||||||
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
||||||
|
|
Loading…
Reference in New Issue