Sha256: 8d6dd55fd61a76c3933b39e2c1df456f26f68e614535ad3c8a9edcbdda714a72

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

require 'active_support/core_ext/object/blank'

module JactiveSupport #:nodoc:
  module JavaExtensions #:nodoc:
    module SqlDate #:nodoc:
      # Converting dates to formatted strings, times, and datetimes.
      module Conversions
        DATE_FORMATS = {
          :db           => "yyyy-MM-dd",
          :i18n         => lambda { |clazz, locale| 
                              format = I18n.translate(:"formats.date", :default=>'')
                              !format.blank? ? clazz.pattern_formatter(format) : clazz.date_instance(:default, locale)
                            },
          :number       => "yyyyMMdd",
          :full         => lambda { |clazz, locale| clazz.date_instance(:full, locale) },
          :long         => lambda { |clazz, locale| clazz.date_instance(:long, locale) },
          :medium       => lambda { |clazz, locale| clazz.date_instance(:medium, locale) },
          :short        => lambda { |clazz, locale| clazz.date_instance(:short, locale) },
          :default      => lambda { |clazz, locale| clazz.date_instance(:default, locale) },
          :long_ordinal => lambda { |clazz| clazz.pattern_formatter("MMMMMM #{time.day.ordinalize}, yyyy HH:mm") },
          :rfc822       => "EEE, dd MMM yyyy HH:mm:ss Z",
          :httpdate     => lambda { |clazz| clazz.pattern_formatter("EEE, dd MMM yyyy HH:mm:ss z", "GMT", "EN") }
        }
        
        def to_java_sqldate
          self
        end
        
        def acts_like_time?
          false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jactive_support-2.1.2 lib/jactive_support/java_ext/sql_date/conversions.rb
jactive_support-2.1.1 lib/jactive_support/java_ext/sql_date/conversions.rb