lib/timing/time_in_zone.rb in timing-0.0.7 vs lib/timing/time_in_zone.rb in timing-0.0.8
- old
+ new
@@ -1,11 +1,11 @@
module Timing
class TimeInZone
extend Forwardable
- REGEXP = /[+-]\d\d:?\d\d/
+ REGEXP = /[+-]\d\d:?\d\d$/
def_delegators :time, :to_i, :to_f, :to_date, :to_datetime, :between?, :==, :<, :<=, :>, :>=, :<=>, :hash
def_delegators :time_with_offset, :year, :month, :day, :hour, :min, :sec, :wday, :yday
attr_reader :zone_offset
@@ -115,10 +115,10 @@
def self.at(seconds, zone_offset=nil)
new Time.at(seconds), zone_offset
end
def self.parse(text)
- match = REGEXP.match text
+ match = text.length > 10 ? REGEXP.match(text) : nil
zone_offset = match ? match.to_s : nil
new Time.parse(text), zone_offset
end
private
\ No newline at end of file