mirror of
https://github.com/jimeh/time_ext.git
synced 2026-02-19 13:26:39 +00:00
reordered methods
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
@@ -58,17 +58,11 @@ class Time
|
|||||||
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)
|
||||||
@@ -102,16 +96,19 @@ class Time
|
|||||||
advance(:days => days)
|
advance(:days => days)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a new Time representing the start of the hour (XX:00:00)
|
# Returns a new Time representing the start of the second, XX:XX:XX.000000 (.000000000 in ruby1.9)
|
||||||
def beginning_of_hour
|
def beginning_of_second
|
||||||
change(:min => 0, :sec => 0, :usec => 0)
|
change(:usec => 0)
|
||||||
end
|
end
|
||||||
alias :at_beginning_of_hour :beginning_of_hour
|
alias :beginning_of_sec :beginning_of_second
|
||||||
|
alias :at_beginning_of_sec :beginning_of_second
|
||||||
|
alias :at_beginning_of_second :beginning_of_second
|
||||||
|
|
||||||
# Returns a new Time representing the end of the hour, XX:59:59.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_hour
|
def end_of_second
|
||||||
change(:min => 59, :sec => 59, :usec => 999999.999)
|
change(:usec => 999999.999)
|
||||||
end
|
end
|
||||||
|
alias :end_of_sec :end_of_second
|
||||||
|
|
||||||
# Returns a new Time representing the start of the minute (XX:XX:00)
|
# Returns a new Time representing the start of the minute (XX:XX:00)
|
||||||
def beginning_of_minute
|
def beginning_of_minute
|
||||||
@@ -127,42 +124,15 @@ class Time
|
|||||||
end
|
end
|
||||||
alias :end_of_min :end_of_minute
|
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 hour (XX:00:00)
|
||||||
def beginning_of_second
|
def beginning_of_hour
|
||||||
change(:usec => 0)
|
change(:min => 0, :sec => 0, :usec => 0)
|
||||||
end
|
end
|
||||||
alias :beginning_of_sec :beginning_of_second
|
alias :at_beginning_of_hour :beginning_of_hour
|
||||||
alias :at_beginning_of_sec :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:59:59.999999 (.999999999 in ruby1.9)
|
||||||
def end_of_second
|
def end_of_hour
|
||||||
change(:usec => 999999.999)
|
change(:min => 59, :sec => 59, :usec => 999999.999)
|
||||||
end
|
end
|
||||||
alias :end_of_sec :end_of_second
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user