Sha256: 9867b348db04793f38359004995497fca4f5af9a023b979bedf20c60327ab567

Contents?: true

Size: 375 Bytes

Versions: 6

Compression:

Stored size: 375 Bytes

Contents

require 'core_ext/string/conversions'
require 'core_ext/time/zones'

class String
  # Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default
  # is set, otherwise converts String to a Time via String#to_time
  def in_time_zone(zone = ::Time.zone)
    if zone
      ::Time.find_zone!(zone).parse(self)
    else
      to_time
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
core_ext-0.0.6 lib/core_ext/string/zones.rb
core_ext-0.0.5 lib/core_ext/string/zones.rb
core_ext-0.0.4 lib/core_ext/string/zones.rb
core_ext-0.0.3 lib/core_ext/string/zones.rb
core_ext-0.0.2 lib/core_ext/string/zones.rb
core_ext-0.0.1 lib/core_ext/string/zones.rb