Sha256: c3577b8884242c004151a18a088bfe538b11f832f47da8bb498377a6c9328f2d

Contents?: true

Size: 494 Bytes

Versions: 19

Compression:

Stored size: 494 Bytes

Contents

module Seabright
	module Types
		module DateType
			
			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
			
			def score_date(val)
				val.to_time.to_i
			end
			
		end
		
		register_type :Date
		
	end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
redis_object-1.5.3 lib/redis_object/types/date.rb
redis_object-1.5.1 lib/redis_object/types/date.rb
redis_object-1.5.0 lib/redis_object/types/date.rb
redis_object-1.4.9 lib/redis_object/types/date.rb
redis_object-1.4.8 lib/redis_object/types/date.rb
redis_object-1.4.7 lib/redis_object/types/date.rb
redis_object-1.4.6 lib/redis_object/types/date.rb
redis_object-1.4.5 lib/redis_object/types/date.rb
redis_object-1.4.3 lib/redis_object/types/date.rb
redis_object-1.4.2 lib/redis_object/types/date.rb
redis_object-1.4.1 lib/redis_object/types/date.rb
redis_object-1.4.0 lib/redis_object/types/date.rb
redis_object-1.3.9 lib/redis_object/types/date.rb
redis_object-1.3.8 lib/redis_object/types/date.rb
redis_object-1.3.7 lib/redis_object/types/date.rb
redis_object-1.3.6 lib/redis_object/types/date.rb
redis_object-1.3.5 lib/redis_object/types/date.rb
redis_object-1.3.4 lib/redis_object/types/date.rb
redis_object-1.3.3 lib/redis_object/types/date.rb