Sha256: 03f7f492b3c27e0cb23a7c169d3b828f52505dcb3c1939dd26d016cc58bf8704

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Localized

    class LocalizedTime < LocalizedDateTime
      def to_datetime(date)
        date_obj = date.is_a?(LocalizedDate) ? date.base_obj : date
        dt = DateTime.parse("#{date_obj.strftime("%Y-%m-%d")}T#{@base_obj.strftime("%H:%M:%S%z")}")
        LocalizedDateTime.new(dt, @locale, chain_params)
      end

      def to_time(base_time = Time.now)
        self
      end

      def to_date
        LocalizedDate.new(@base_obj, @locale, chain_params)
      end

      def gmtime
        LocalizedTime.new(@base_obj.gmtime, @locale, chain_params)
      end

      def localtime
        LocalizedTime.new(@base_obj.localtime, @locale, chain_params)
      end

      protected

      def base_in_timezone
        timezone_info.utc_to_local(@base_obj.utc)
      end

      def data_reader_for(type, options = {})
        TwitterCldr::DataReaders::TimeDataReader.new(
          locale, options.merge({
            :calendar_type => calendar_type,
            :type => type
          })
        )
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/localized/localized_time.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/localized/localized_time.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.2.1 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.2.0 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.1.2 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.1.1 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.1.0 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.0.10 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.0.9 lib/twitter_cldr/localized/localized_time.rb