Skip to content

Latest commit

 

History

History
114 lines (43 loc) · 1.21 KB

DateConverter.rst

File metadata and controls

114 lines (43 loc) · 1.21 KB

DateConverter

Converts Date objects to Java long types. Must be timezone UTC.

Constants

Files

Methods

.convert_type

def convert_type
  Date
end

.converted?

def converted?(value)
  value.is_a?(db_type)
end

.db_type

def db_type
  Integer
end

.to_db

def to_db(value)
  Time.utc(value.year, value.month, value.day).to_i
end

.to_ruby

def to_ruby(value)
  value.respond_to?(:to_date) ? value.to_date : Time.at(value).utc.to_date
end