module TimeConstantMethods

def after( time )

## E.g., 10.minutes.after( header.expiration )
## Returns the Time number of seconds after the given +time+.
def after( time )
	return time + self
end

def ago

## expiration > 2.hours.ago )
## Returns the Time number of seconds ago. (e.g.,
def ago
	return self.before( ::Time.now )
end

def before( time )

## specified +time+. E.g., 2.hours.before( header.expiration )
## Returns the Time number of seconds before the
def before( time )
	return time - self
end

def days

## Returns the number of seconds in days
def days
	return self * 24.hours
end

def fortnights

## Returns the number of seconds in fortnights
def fortnights
	return self * 2.weeks
end

def from_now

Reads best without arguments: 10.minutes.from_now
def from_now
	return self.after( ::Time.now )
end

def hours

## Returns the number of seconds in hours
def hours
	return self * 60.minutes
end

def minutes

## Returns number of seconds in minutes
def minutes
	return self * 60
end

def months

## Returns the number of seconds in months (approximate)
def months
	return self * 30.days
end

def seconds

## Number of seconds (returns receiver unmodified)
def seconds
	return self
end

def weeks

## Return the number of seconds in weeks
def weeks
	return self * 7.days
end

def years

## Returns the number of seconds in years (approximate)
def years
	return (self * 365.25.days).to_i
end