Sha256: 4d04d53685e2eec65e0714ebc4181cd369e40f63d519ad1e1c5d5a944c3426f9

Contents?: true

Size: 596 Bytes

Versions: 14

Compression:

Stored size: 596 Bytes

Contents

require 't/cli'
require 'time'

module T
  class << self

    # Convert time to local time by applying the `utc_offset` setting.
    def local_time(time)
      utc_offset ? (time.utc + utc_offset) : time.localtime
    end

    # UTC offset in seconds to apply time instances before displaying.
    # If not set, time instances are displayed in default local time.
    attr_reader :utc_offset

    def utc_offset=(offset)
      @utc_offset = case offset
      when String
        Time.zone_offset(offset)
      when NilClass
        nil
      else
        offset.to_i
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
t-1.7.2 lib/t.rb
t-1.7.1 lib/t.rb
t-1.7.0 lib/t.rb
t-1.6.0 lib/t.rb
t-1.5.1 lib/t.rb
t-1.5.0 lib/t.rb
t-1.4.0 lib/t.rb
t-1.3.1 lib/t.rb
t-1.3.0 lib/t.rb
t-1.2.0 lib/t.rb
t-1.1.1 lib/t.rb
t-1.1.0 lib/t.rb
t-1.0.1 lib/t.rb
t-1.0.0 lib/t.rb