Sha256: 0959a0a75e038c7843693f9d79c7544da9beb6a99c9191a484a51e6117915e4e

Contents?: true

Size: 726 Bytes

Versions: 5

Compression:

Stored size: 726 Bytes

Contents

require 'date'

module Eye::Utils
  autoload :Tail,           'eye/utils/tail'
  autoload :AliveArray,     'eye/utils/alive_array'
  autoload :CelluloidChain, 'eye/utils/celluloid_chain'

  def self.deep_clone(value)
    case
      when value.is_a?(Array) then value.map{|v| deep_clone(v) }
      when value.is_a?(Hash) then value.inject({}){|r, (k, v)| r[ deep_clone(k) ] = deep_clone(v); r }
      else value
    end
  end

  D1 = '%H:%M'
  D2 = '%b%d'

  def self.human_time(unix_time)
    time = Time.at(unix_time.to_i)
    d1 = time.to_date
    d2 = Time.now.to_date
    time.strftime (d1 == d2) ? D1 : D2
  end

  DF = '%d %b %H:%M'

  def self.human_time2(unix_time)
    Time.at(unix_time.to_i).strftime(DF)
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
reel-eye-0.5.2.1 lib/eye/utils.rb
reel-eye-0.5.2 lib/eye/utils.rb
eye-0.5.2 lib/eye/utils.rb
reel-eye-0.5.1 lib/eye/utils.rb
eye-0.5.1 lib/eye/utils.rb