aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/zones.rb
blob: c1b3934722bd458437e9de07cd954077652f080c (plain) (tree)
1
2
3
4
5
6
7
8
9



                                            


                                                                                
                             
                  




                                         
   
require 'date'
require 'active_support/core_ext/time/zones'

class Date
  # Converts Date to a TimeWithZone in the current zone if <tt>Time.zone</tt> or
  # <tt>Time.zone_default</tt> is set, otherwise converts Date to a Time via
  # Date#to_time.
  def to_time_in_current_zone
    if ::Time.zone
      ::Time.zone.local(year, month, day)
    else
      to_time
    end
  end
end