lib/timeliness/parser.rb in timeliness-0.3.3 vs lib/timeliness/parser.rb in timeliness-0.3.4

- old
+ new

@@ -21,25 +21,23 @@ end def make_time(time_array, zone_option=nil) return nil unless fast_date_valid_with_fallback(*time_array[0..2]) - zone_or_offset = time_array.delete_at(7) - zone, offset = zone_and_offset(zone_or_offset) if zone_or_offset + zone, offset = zone_and_offset(time_array[7]) if time_array[7] - value = create_time_in_zone(time_array, zone || zone_option) - value = time_in_zone(value, zone_option) if zone + value = create_time_in_zone(time_array[0..6].compact, zone || zone_option) + value = shift_time_to_zone(value, zone_option) if zone offset ? value + (value.utc_offset - offset) : value rescue ArgumentError, TypeError nil end def _parse(string, type=nil, options={}) if options[:strict] && type - set = Definitions.send("#{type}_format_set") - set.match(string, options[:format]) + Definitions.send("#{type}_format_set").match(string, options[:format]) else values = nil Definitions.format_sets(type, string).find {|set| values = set.match(string, options[:format]) } values end @@ -94,11 +92,11 @@ else Time.use_zone(zone) { Time.current } end end - def time_in_zone(time, zone=nil) + def shift_time_to_zone(time, zone=nil) zone ||= Timeliness.default_timezone case zone when :utc, :local time.send("get#{zone}") when :current @@ -110,10 +108,10 @@ def create_time_in_zone(time_array, zone=nil) zone ||= Timeliness.default_timezone case zone when :utc, :local - time_with_datetime_fallback(zone, *time_array.compact) + time_with_datetime_fallback(zone, *time_array) when :current Time.zone.local(*time_array) else Time.use_zone(zone) { Time.zone.local(*time_array) } end