Created
December 9, 2008 18:49
-
-
Save bjhess/34028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When I want to get beginning of day in the time zone set for | |
# the request, not the local machine's time zone. | |
class ::Date | |
def beginning_of_day_in_zone | |
Time.zone.parse(self.to_s) | |
end | |
alias_method :at_beginning_of_day_in_zone, :beginning_of_day_in_zone | |
alias_method :midnight_in_zone, :beginning_of_day_in_zone | |
alias_method :at_midnight_in_zone, :beginning_of_day_in_zone | |
def end_of_day_in_zone | |
Time.zone.parse((self+1).to_s) - 1 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment