Sha256: 36c307f4fa00de23fd33d804a747e888742f7c54fefb9110bc571315dd697e3d

Contents?: true

Size: 558 Bytes

Versions: 9

Compression:

Stored size: 558 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is licensed under the GNU AGPLv3.
#	Copyright 2010 Samuel Williams. All rights reserved.
#	See <utopia.rb> for licensing details.

require 'active_support'

class Date
	alias_method :old_cmp, :<=>
	
	def <=> (other)
		# Comparing a Date with something that has a time component truncates the time
		# component, thus we need to check if the other object has a more exact comparison
		# function.
		if other.respond_to?(:hour)
			return (other <=> self) * -1
		else
			old_cmp(other)
		end
	end	
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
utopia-0.9.40 lib/utopia/extensions/date.rb
utopia-0.9.39 lib/utopia/extensions/date.rb
utopia-0.9.38 lib/utopia/extensions/date.rb
utopia-0.9.37 lib/utopia/extensions/date.rb
utopia-0.9.36 lib/utopia/extensions/date.rb
utopia-0.9.35 lib/utopia/extensions/date.rb
utopia-0.9.34 lib/utopia/extensions/date.rb
utopia-0.9.33 lib/utopia/extensions/date.rb
utopia-0.9.32 lib/utopia/extensions/date.rb