reordered methods

This commit is contained in:
2010-07-27 17:35:24 +03:00
parent d4baf20040
commit b69c53776a

View File

@@ -16,13 +16,13 @@ class Time
# Short-hand for seconds_ago(1) # Short-hand for seconds_ago(1)
def prev_second def prev_second
seconds_ago(1) ago(1)
end end
alias :prev_sec :prev_second alias :prev_sec :prev_second
# Short-hand for seconds_since(1) # Short-hand for seconds_since(1)
def next_second def next_second
seconds_since(1) since(1)
end end
alias :next_sec :next_second alias :next_sec :next_second
@@ -31,7 +31,7 @@ class Time
minutes_ago(1) minutes_ago(1)
end end
alias :prev_min :prev_minute alias :prev_min :prev_minute
# Short-hand for minutes_since(1) # Short-hand for minutes_since(1)
def next_minute def next_minute
minutes_since(1) minutes_since(1)
@@ -42,7 +42,7 @@ class Time
def prev_hour def prev_hour
hours_ago(1) hours_ago(1)
end end
# Short-hand for hours_since(1) # Short-hand for hours_since(1)
def next_hour def next_hour
hours_since(1) hours_since(1)
@@ -52,30 +52,24 @@ class Time
def prev_day def prev_day
days_ago(1) days_ago(1)
end end
# Short-hand for days_since(1) # Short-hand for days_since(1)
def next_day def next_day
days_since(1) days_since(1)
end end
# Returns a new Time representing the time a number of specified seconds ago # Aliases to keep available method names to a standard pattern
def seconds_ago(seconds) alias :secs_ago :ago
advance(:seconds => -seconds) alias :seconds_ago :ago
end alias :secs_since :since
alias :secs_ago :seconds_ago alias :seconds_since :since
# Returns a new Time representing the time a number of specified seconds in the future
def seconds_since(seconds)
advance(:seconds => seconds)
end
alias :secs_since :seconds_since
# Returns a new Time representing the time a number of specified minutes ago # Returns a new Time representing the time a number of specified minutes ago
def minutes_ago(minutes) def minutes_ago(minutes)
advance(:minutes => -minutes) advance(:minutes => -minutes)
end end
alias :mins_ago :minutes_ago alias :mins_ago :minutes_ago
# Returns a new Time representing the time a number of specified minutes in the future # Returns a new Time representing the time a number of specified minutes in the future
def minutes_since(minutes) def minutes_since(minutes)
advance(:minutes => minutes) advance(:minutes => minutes)
@@ -86,7 +80,7 @@ class Time
def hours_ago(hours) def hours_ago(hours)
advance(:hours => -hours) advance(:hours => -hours)
end end
# Returns a new Time representing the time a number of specified hours in the future # Returns a new Time representing the time a number of specified hours in the future
def hours_since(hours) def hours_since(hours)
advance(:hours => hours) advance(:hours => hours)
@@ -96,37 +90,12 @@ class Time
def days_ago(days) def days_ago(days)
advance(:days => -days) advance(:days => -days)
end end
# Returns a new Time representing the time a number of specified days in the future # Returns a new Time representing the time a number of specified days in the future
def days_since(days) def days_since(days)
advance(:days => days) advance(:days => days)
end end
# Returns a new Time representing the start of the hour (XX:00:00)
def beginning_of_hour
change(:min => 0, :sec => 0, :usec => 0)
end
alias :at_beginning_of_hour :beginning_of_hour
# Returns a new Time representing the end of the hour, XX:59:59.999999 (.999999999 in ruby1.9)
def end_of_hour
change(:min => 59, :sec => 59, :usec => 999999.999)
end
# Returns a new Time representing the start of the minute (XX:XX:00)
def beginning_of_minute
change(:sec => 0, :usec => 0)
end
alias :beginning_of_min :beginning_of_minute
alias :at_beginning_of_min :beginning_of_minute
alias :at_beginning_of_minute :beginning_of_minute
# Returns a new Time representing the end of the hour, XX:XX:59.999999 (.999999999 in ruby1.9)
def end_of_minute
change(:sec => 59, :usec => 999999.999)
end
alias :end_of_min :end_of_minute
# Returns a new Time representing the start of the second, XX:XX:XX.000000 (.000000000 in ruby1.9) # Returns a new Time representing the start of the second, XX:XX:XX.000000 (.000000000 in ruby1.9)
def beginning_of_second def beginning_of_second
change(:usec => 0) change(:usec => 0)
@@ -134,35 +103,36 @@ class Time
alias :beginning_of_sec :beginning_of_second alias :beginning_of_sec :beginning_of_second
alias :at_beginning_of_sec :beginning_of_second alias :at_beginning_of_sec :beginning_of_second
alias :at_beginning_of_second :beginning_of_second alias :at_beginning_of_second :beginning_of_second
# Returns a new Time representing the end of the hour, XX:XX:XX.999999 (.999999999 in ruby1.9) # Returns a new Time representing the end of the hour, XX:XX:XX.999999 (.999999999 in ruby1.9)
def end_of_second def end_of_second
change(:usec => 999999.999) change(:usec => 999999.999)
end end
alias :end_of_sec :end_of_second alias :end_of_sec :end_of_second
# Returns a new Time representing the start of the minute (XX:XX:00)
def beginning_of_minute
change(:sec => 0, :usec => 0)
end
alias :beginning_of_min :beginning_of_minute
alias :at_beginning_of_min :beginning_of_minute
alias :at_beginning_of_minute :beginning_of_minute
# Returns a new Time representing the end of the hour, XX:XX:59.999999 (.999999999 in ruby1.9)
def end_of_minute
change(:sec => 59, :usec => 999999.999)
end
alias :end_of_min :end_of_minute
# Returns a new Time representing the start of the hour (XX:00:00)
def beginning_of_hour
change(:min => 0, :sec => 0, :usec => 0)
end
alias :at_beginning_of_hour :beginning_of_hour
# Returns a new Time representing the end of the hour, XX:59:59.999999 (.999999999 in ruby1.9)
def end_of_hour
change(:min => 59, :sec => 59, :usec => 999999.999)
end
end end