Sha256: 195d0452d91a89ef2a23738a0fbde8235d4df88ae9284d2c010601adf86ec43b

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

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       => "YYYMMdd",
          :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("%B #{time.day.ordinalize}, %Y %H:%M") },
          :rfc822       => lambda { |clazz| clazz.pattern_formatter("%a, %d %b %Y %H:%M:%S #{time.formatted_offset(false)}") },
          :httpdate     => lambda { |clazz| clazz.pattern_formatter("EEE, dd MMM yyyy HH:mm:ss z", "GMT") }
        }
        
        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-1.0.2 lib/jactive_support/java_ext/sql_date/conversions.rb
jactive_support-1.0.1-universal-java-1.6 lib/jactive_support/java_ext/sql_date/conversions.rb