Module: Seabright::Types::DateType

Defined in:
lib/redis_object/types/date.rb

Instance Method Summary collapse

Instance Method Details

#format_date(val) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/redis_object/types/date.rb', line 5

def format_date(val)
	begin
		val.is_a?(DateTime) || val.is_a?(Date) || val.is_a?(Time) ? val : ( val.is_a?(String) ? DateTime.parse(val) : nil )
	rescue StandardError => e
		Log.debug "Could not parse value as date using Date.parse. Returning nil instead. Value: #{val.inspect}\nError: #{e.inspect}"
		nil
	end
end

#score_date(val) ⇒ Object



14
15
16
# File 'lib/redis_object/types/date.rb', line 14

def score_date(val)
	val.to_time.to_i
end