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



140
141
142
# File 'lib/neo4j/shared/type_converters.rb', line 140

def convert_type
  Date
end

.db_typeObject



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

def db_type
  Integer
end

.to_db(value) ⇒ Object



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

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

.to_ruby(value) ⇒ Object



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

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