Sha256: 7961a1449ebd21cf20999dcbf4286c98fc4586187813a9d25eb450fc50005d45

Contents?: true

Size: 1.68 KB

Versions: 13

Compression:

Stored size: 1.68 KB

Contents

module EtOrbi

  class << self

    def platform_info

      etos = Proc.new { |k, v| "#{k}:#{v.inspect}" }

      h = {
        'etz' => ENV['TZ'],
        'tnz' => Time.now.zone,
        'tziv' => tzinfo_version,
        'tzidv' => tzinfo_data_version,
        'rv' => RUBY_VERSION,
        'rp' => RUBY_PLATFORM,
        'win' => Gem.win_platform?,
        'rorv' => (Rails::VERSION::STRING rescue nil),
        'astz' => ([ Time.zone.class, Time.zone.tzinfo.name ] rescue nil),
        'eov' => EtOrbi::VERSION,
        'eotnz' => '???',
        'eotnfz' => '???',
        'eotlzn' => '???' }
      if ltz = EtOrbi::EoTime.local_tzone
        h['eotnz'] = EtOrbi::EoTime.now.zone
        h['eotnfz'] = EtOrbi::EoTime.now.strftime('%z')
        h['eotnfZ'] = EtOrbi::EoTime.now.strftime('%Z')
        h['eotlzn'] = ltz.name
      end

      "(#{h.map(&etos).join(',')},#{gather_tzs.map(&etos).join(',')})"
    end

    # For `make info`
    #
    def _make_info

      puts render_nozone_time(Time.now.to_f)
      puts platform_info
    end

    def render_nozone_time(seconds)

      t =
        Time.utc(1970) + seconds
      ts =
        t.strftime('%Y-%m-%d %H:%M:%S') +
        ".#{(seconds % 1).to_s.split('.').last}"
      tz =
        EtOrbi.determine_local_tzone
      z =
        tz ? tz.period_for_local(t).abbreviation.to_s : nil

      "(secs:#{seconds},utc~:#{ts.inspect},ltz~:#{z.inspect})"
    end

    protected

    def tzinfo_version

      #TZInfo::VERSION
      Gem.loaded_specs['tzinfo'].version.to_s
    rescue => err
      err.inspect
    end

    def tzinfo_data_version

      #TZInfo::Data::VERSION rescue nil
      Gem.loaded_specs['tzinfo-data'].version.to_s rescue nil
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
et-orbi-1.2.11 lib/et-orbi/info.rb
et-orbi-1.2.10 lib/et-orbi/info.rb
et-orbi-1.2.9 lib/et-orbi/info.rb
et-orbi-1.2.8 lib/et-orbi/info.rb
et-orbi-1.2.7 lib/et-orbi/info.rb
et-orbi-1.2.6 lib/et-orbi/info.rb
et-orbi-1.2.5 lib/et-orbi/info.rb
et-orbi-1.2.4 lib/et-orbi/info.rb
et-orbi-1.2.3 lib/et-orbi/info.rb
et-orbi-1.2.2 lib/et-orbi/info.rb
et-orbi-1.2.1 lib/et-orbi/info.rb
et-orbi-1.2.0 lib/et-orbi/info.rb
et-orbi-1.1.8 lib/et-orbi/info.rb