Sha256: ae4d22e15a81c3ee074dc6858ec598c7f6905a58a9302e3a7732b58a73530538

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 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
        LocalizedDateTime.new(DateTime.parse("#{date_obj.strftime("%Y-%m-%d")}T#{@base_obj.strftime("%H:%M:%S%z")}"), @locale, :calendar_type => @calendar_type)
      end

      def to_time(base_time = Time.now)
        self
      end

      def gmtime
        LocalizedTime.new(@base_obj.gmtime, @locale, :calendar_type => @calendar_type)
      end

      def localtime
        LocalizedTime.new(@base_obj.localtime, @locale, :calendar_type => @calendar_type)
      end

      protected

      def formatter_const
        TwitterCldr::Formatters::TimeFormatter
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter_cldr-2.2.0 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-2.1.1 lib/twitter_cldr/localized/localized_time.rb
twitter_cldr-2.1.0 lib/twitter_cldr/localized/localized_time.rb