Skip to content
This repository
Browse code

Add Time#all_* to AS guides.

  • Loading branch information...
commit 9387c70dbd8dece0796c3f3619a1421c06d10af7 1 parent 415f2e2
Sebastian Martinez authored June 14, 2011 fxn committed June 18, 2011
26  railties/guides/source/active_support_core_extensions.textile
Source Rendered
@@ -3354,6 +3354,32 @@ Active Support defines +Time.current+ to be today in the current time zone. That
3354 3354
 
3355 3355
 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+.
3356 3356
 
  3357
+h5. +all_day+, +all_week+, +all_month+, +all_quarter+ and +all_year+
  3358
+
  3359
+The method +all_day+ returns a range representing the whole day of the current time.
  3360
+
  3361
+<ruby>
  3362
+now = Time.now
  3363
+# => Mon, 09 Aug 2010 23:20:05 UTC +00:00
  3364
+now.all_day
  3365
+# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Mon, 09 Aug 2010 23:59:59 UTC +00:00
  3366
+</ruby>
  3367
+
  3368
+Analogously, +all_week+, +all_month+, +all_quarter+ and +all_year+ all serve the purpose of generating time ranges.
  3369
+
  3370
+<ruby>
  3371
+now = Time.now
  3372
+# => Mon, 09 Aug 2010 23:20:05 UTC +00:00
  3373
+now.all_week
  3374
+# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Sun, 15 Aug 2010 23:59:59 UTC +00:00
  3375
+now.all_month
  3376
+# => Sat, 01 Aug 2010 00:00:00 UTC +00:00..Tue, 31 Aug 2010 23:59:59 UTC +00:00
  3377
+now.all_quarter
  3378
+# => Thu, 01 Jul 2010 00:00:00 UTC +00:00..Thu, 30 Sep 2010 23:59:59 UTC +00:00
  3379
+now.all_year
  3380
+# => Fri, 01 Jan 2010 00:00:00 UTC +00:00..Fri, 31 Dec 2010 23:59:59 UTC +00:00
  3381
+</ruby>
  3382
+
3357 3383
 h4. Time Constructors
3358 3384
 
3359 3385
 Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user time zone defined, with fallback to +Time.now+:

0 notes on commit 9387c70

Please sign in to comment.
Something went wrong with that request. Please try again.