Skip to content

Instantly share code, notes, and snippets.

@davidguttman
Created August 17, 2011 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidguttman/1150534 to your computer and use it in GitHub Desktop.
Save davidguttman/1150534 to your computer and use it in GitHub Desktop.
class Time
def to_half_hour_start
if self.min >= 30
self.to_hour_end - 30.minutes
else
self.to_hour_start
end
end
def to_half_hour_end
if self.min >= 30
self.to_hour_end
else
self.to_hour_end - 30.minutes
end
end
def to_hour_start
self.round - self.min.minutes - self.round.sec.seconds
end
def to_hour_end
self.to_hour_start + 1.hour
end
def to_day_begin
self.round - self.hour.hours - self.min.minutes - self.round.sec.seconds
end
def to_day_end
self.to_day_begin + 1.day
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment