Property definitions

date $ Time :: defaultinit
# A time of the day, composed of an `hour`, a `minute` and a `second` count
class Time
	super Comparable
	redef type OTHER: Time

	# The hour part of this time, between 0 and 23
	var hour: Int

	# The minute within the hour, between 0 and 59
	var minute: Int

	# The second within the minute, between 0 and 59
	var second: Int

	# Get the current time of the day
	init now do
		var tm = new Tm.localtime
		init(tm.hour, tm.min, tm.sec)
	end

	# Get the difference between two times in second
	fun diff_time(other: Time): Int do
		return (hour * 3600 + minute * 60 + second) -
			(other.hour * 3600 + other.minute * 60 + other.second)
	end

	redef fun ==(d) do return d isa Time and time_eq(d)

	redef fun <(d) do return self.diff_time(d) < 0

	redef fun hash do return hour * 1024 + minute * 64 + second

	private fun time_eq(other: Time): Bool
	do
		return hour * 3600 + minute * 60 + second ==
			other.hour * 3600 + other.minute * 60 + other.second
	end
end
lib/date/date.nit:44,1--81,3