Sha256: 465420f06e2e88b23638a355ad45835cad6f53fa1f9e1d296d60d3da82726de9

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

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 formatter_const
        TwitterCldr::Formatters::TimeFormatter
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-3.0.0.beta1 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-2.4.2 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-2.4.1 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-2.4.0 lib/twitter_cldr/localized/localized_time.rb