aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Martinez <sebastian@wyeworks.com>2011-06-14 10:53:38 -0300
committerSebastian Martinez <sebastian@wyeworks.com>2011-06-14 10:53:38 -0300
commit10c203508415767eb0a15f9da3a48e56f552c1ce (patch)
tree82363f101d6425b941a791d09089fd10f0fa7bfa
parent9db268db651bcd4d8a2ee5af7e37b4d2aeab98ec (diff)
downloadrails-10c203508415767eb0a15f9da3a48e56f552c1ce.tar.gz
rails-10c203508415767eb0a15f9da3a48e56f552c1ce.tar.bz2
rails-10c203508415767eb0a15f9da3a48e56f552c1ce.zip
Add Time#all_* to AS guides.
-rw-r--r--railties/guides/source/active_support_core_extensions.textile26
1 files changed, 26 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index f9f7f2d83c..763e0d585b 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -3322,6 +3322,32 @@ Active Support defines +Time.current+ to be today in the current time zone. That
When making Time comparisons using methods which honor the user time zone, make sure to use +Time.current+ and not +Time.now+. There are cases where the user time zone might be in the future compared to the system time zone, which +Time.today+ uses by default. This means +Time.now+ may equal +Time.yesterday+.
+h5. +all_day+, +all_week+, +all_month+, +all_quarter+ and +all_year+
+
+The method +all_day+ returns a range representing the whole day of the current time.
+
+<ruby>
+now = Time.now
+# => Mon, 09 Aug 2010 23:20:05 UTC +00:00
+now.all_day
+# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Mon, 09 Aug 2010 23:59:59 UTC +00:00
+</ruby>
+
+Analogously, +all_week+, +all_month+, +all_quarter+ and +all_year+ all serve the purpose of generating time ranges.
+
+<ruby>
+now = Time.now
+# => Mon, 09 Aug 2010 23:20:05 UTC +00:00
+now.all_week
+# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Sun, 15 Aug 2010 23:59:59 UTC +00:00
+now.all_month
+# => Sat, 01 Aug 2010 00:00:00 UTC +00:00..Tue, 31 Aug 2010 23:59:59 UTC +00:00
+now.all_quarter
+# => Thu, 01 Jul 2010 00:00:00 UTC +00:00..Thu, 30 Sep 2010 23:59:59 UTC +00:00
+now.all_year
+# => Fri, 01 Jan 2010 00:00:00 UTC +00:00..Fri, 31 Dec 2010 23:59:59 UTC +00:00
+</ruby>
+
h4. Time Constructors
Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user time zone defined, with fallback to +Time.now+: