Skip to content

Commit

Permalink
remove unneeeded Date#to_time and DateTime#to_time methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyredrick committed Dec 20, 2009
1 parent 210a72d commit 445afd0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
14 changes: 0 additions & 14 deletions lib/ri_cal/core_extensions/date/conversions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ def to_date
self
end if RUBY_VERSION < '1.9'

# Converts a Date instance to a Time, where the time is set to the beginning of the day.
# The timezone can be either :local or :utc (default :local).
#
# ==== Examples
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
#
# date.to_time # => Sat Nov 10 00:00:00 0800 2007
# date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007
#
# date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
def to_time(form = :local)
::Time.send("#{form}_time", year, month, day)
end

# Converts a Date instance to a DateTime, where the time is set to the beginning of the day
# and UTC offset is set to 0.
#
Expand Down
6 changes: 0 additions & 6 deletions lib/ri_cal/core_extensions/date_time/conversions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ def to_date
::Date.new(year, month, day)
end

# Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class
# If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time
def to_time
self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec) : self
end

# To be able to keep Times, Dates and DateTimes interchangeable on conversions
def to_datetime
self
Expand Down

0 comments on commit 445afd0

Please sign in to comment.