aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/zones.rb
diff options
context:
space:
mode:
authorGonçalo Silva <goncalossilva@gmail.com>2010-07-10 17:36:10 +0100
committerGonçalo Silva <goncalossilva@gmail.com>2010-07-10 17:36:10 +0100
commitcd2bbed9846d84a1230a1b9e52843eedca17b28d (patch)
tree5214b7855f3d102e4c22239b9d62bc5717cb3547 /activesupport/lib/active_support/core_ext/date/zones.rb
parentd2c633ba0bfb7baacdee89a46d7d036d24c68817 (diff)
parent80e47d7b88dcc732ebeb5290faab6e529829dac6 (diff)
downloadrails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.tar.gz
rails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.tar.bz2
rails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.zip
Merge branch 'master' of http://github.com/rails/rails
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/zones.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/zones.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/zones.rb b/activesupport/lib/active_support/core_ext/date/zones.rb
new file mode 100644
index 0000000000..3a83af6be2
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/date/zones.rb
@@ -0,0 +1,14 @@
+require 'date'
+require 'active_support/core_ext/time/zones'
+
+class Date
+ # Converts Date to a TimeWithZone in the current zone if Time.zone_default is set,
+ # otherwise converts Date to a Time via Date#to_time
+ def to_time_in_current_zone
+ if ::Time.zone_default
+ ::Time.zone.local(year, month, day)
+ else
+ to_time
+ end
+ end
+end