Class: Neo4j::Shared::TypeConverters::DateConverter

Inherits:
BaseConverter
  • Object
show all
Defined in:
lib/neo4j/shared/type_converters.rb

Overview

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

Class Method Summary collapse

Methods inherited from BaseConverter

converted?, #supports_array?

Class Method Details

.convert_typeObject



143
144
145
# File 'lib/neo4j/shared/type_converters.rb', line 143

def convert_type
  Date
end

.db_typeObject



147
148
149
# File 'lib/neo4j/shared/type_converters.rb', line 147

def db_type
  Integer
end

.to_db(value) ⇒ Object



151
152
153
# File 'lib/neo4j/shared/type_converters.rb', line 151

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

.to_ruby(value) ⇒ Object



155
156
157
# File 'lib/neo4j/shared/type_converters.rb', line 155

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