Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 29 lines (23 sloc) 0.596 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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
Something went wrong with that request. Please try again.