Class: Lafcadio::DateTimeField

Inherits:
ObjectField show all
Defined in:
lib/lafcadio/objectField.rb

Overview

DateTimeField represents a DateTime.

Direct Known Subclasses

TimeStampField

Instance Attribute Summary

Attributes inherited from ObjectField

#db_field_name, #domain_class, #mock_value, #name, #not_nil

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectField

#<=>, #bind_write?, create_from_xml, create_with_args, creation_parameters, #db_column, #db_will_automatically_write?, #default_mock_value, #initialize, #prev_value, #process_before_verify, value_type, #verify, #verify_non_nil_value

Constructor Details

This class inherits a constructor from Lafcadio::ObjectField

Class Method Details

.mock_valueObject

:nodoc:



14
15
16
# File 'lib/lafcadio/test.rb', line 14

def DateTimeField.mock_value #:nodoc:
	Time.now
end

Instance Method Details

#value_for_sql(value) ⇒ Object

:nodoc:



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/lafcadio/objectField.rb', line 271

def value_for_sql(value) # :nodoc:
	if value
		year = value.year
		month = value.mon.to_s.pad( 2, "0" )
		day = value.day.to_s.pad( 2, "0" )
		hour = value.hour.to_s.pad( 2, "0" )
		minute = value.min.to_s.pad( 2, "0" )
		second = value.sec.to_s.pad( 2, "0" )
		"'#{year}-#{month}-#{day} #{hour}:#{minute}:#{second}'"
	else
		"null"
	end
end

#value_from_sql(dbi_value) ⇒ Object

:nodoc:



285
286
287
# File 'lib/lafcadio/objectField.rb', line 285

def value_from_sql( dbi_value ) # :nodoc:
	dbi_value ? dbi_value.to_time : nil
end