Sha256: 7e4817d29e8a9ebf31f60dac042c2120d28c2a458c51231f199b67f22763c9ac

Contents?: true

Size: 548 Bytes

Versions: 14

Compression:

Stored size: 548 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 'date'

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

14 entries across 14 versions & 1 rubygems

Version Path
utopia-0.9.56 lib/utopia/extensions/date.rb
utopia-0.9.55 lib/utopia/extensions/date.rb
utopia-0.9.54 lib/utopia/extensions/date.rb
utopia-0.9.53 lib/utopia/extensions/date.rb
utopia-0.9.52 lib/utopia/extensions/date.rb
utopia-0.9.51 lib/utopia/extensions/date.rb
utopia-0.9.50 lib/utopia/extensions/date.rb
utopia-0.9.49 lib/utopia/extensions/date.rb
utopia-0.9.48 lib/utopia/extensions/date.rb
utopia-0.9.47 lib/utopia/extensions/date.rb
utopia-0.9.46 lib/utopia/extensions/date.rb
utopia-0.9.45 lib/utopia/extensions/date.rb
utopia-0.9.43 lib/utopia/extensions/date.rb
utopia-0.9.42 lib/utopia/extensions/date.rb