aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/date_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Delete `DateAndTime` method definition in rails that is compatible with ruby ↵soartec-lab2019-06-161-16/+0
| | | | | | | | | | | | definition Tests are also only on the `Time` class Update doc forgetting to erase when moved Update guide `Date` class to `Time` class and defined file Update guide correction omission
* Move implementation of `before?` and `after?` to `DateAndTime::Calculations`bogdanvlviv2018-03-311-12/+0
| | | | | | | | This prevents duplication of code. Prevent duplication of tests by moving them to `DateAndTimeBehavior`. Related to #32185.
* Add `before?` and `after?` methods to date and time classesNick Holden2018-03-061-0/+12
| | | | | | | | Equality comparisons between dates and times can take some extra time to comprehend. I tend to think of a date or time as "before" or "after" another date or time, but I naturally read `<` and `>` as "less than" and "greater than." This change seeks to make date/time comparisons more human readable.
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-2/+2
|
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-3/+3
| | | | Follow up of #31432.
* Allows pass argument for `Time#prev_year` and `Time#next_year`.bogdanvlviv2017-10-241-4/+0
|
* Allows pass argument for `Time#prev_month` and `Time#next_month`bogdanvlviv2017-10-241-4/+0
|
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add tests for `blank?`kenta-s2017-02-061-0/+4
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-71/+71
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+0
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-22/+22
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-25/+25
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Don't blank pad day of the month when formatting datesSean Griffin2016-06-021-0/+11
| | | | | | | | | | | We are currently using `%e` which adds a space before the result if the digit is a single number. This leads to strings like `February 2, 2016` which is undesireable. I've opted to replace with 0 padding instead of removing the padding entirely, to preserve compatibility for those relying on the fact that the width is constant, and to be consistent with time formatting. Fixes #25251.
* Introduce Date#all_dayHenrik Nyh2016-05-111-0/+17
| | | | | | | | | Useful for queries like: Item.where(created_at: Date.current.all_day) There was already a Time#all_day with the same behaviour, but for queries like the above, Date is more convenient.
* Raise `ArgumentError` when an invalid form is passed to `Date#to_time`yui-knk2016-04-171-0/+4
| | | | | | | | Before this commit `NoMethodError: undefined method `form_name' for Time:Class` is raised when an invalid argument is passed. It is better to raise `ArgumentError` and show list of valid arguments to developers.
* Removed mocha stubbing in active_supportRonak Jangir2015-06-071-14/+19
|
* Extract out with_env_tz helper method.Zuhao Wan2014-06-181-16/+2
| | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* Added Date#all_week/month/quarter/year for generating date rangesDimko2013-12-031-0/+17
|
* Merge pull request #10879 from makaroni4/masterAndrew White2013-07-291-0/+4
|\ | | | | Added Time#middle_of_day method
| * Added Time#middle_of_dayAnatoli Makarevich2013-07-281-0/+4
| | | | | | | | Added middle_of_day method to Date and DateTime
* | Fix handling of offsets with Time#to_s(:iso8601)Andrew White2013-07-291-0/+1
| | | | | | | | | | | | Use a lambda to ensure that the generated string respects the offset of the time value. Also add DateTime#to_s(:iso8601) and Date#to_s(:iso8601) for completeness.
* | Remove deprecated `Date#to_time_in_current_zone`Vipul A M2013-07-021-7/+0
|/
* Allow Date to be compared with Time (like it was possible to compare Time ↵David Heinemeier Hansson2013-06-031-0/+4
| | | | with Date)
* Squashed commit of the following:Aaron Patterson2013-05-031-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 2683de5da85135e8d9fe48593ff6167db9d64b18 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:29:20 2013 -0700 cannot support infinite ranges right now commit cebb6acef2c3957f975f6db4afd849e535126253 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:26:12 2013 -0700 reverting infinity comparison commit 385f7e6b4efd1bf9b89e8d607fcb13e5b03737ea Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:23:28 2013 -0700 Revert "Added ability to compare date/time with infinity" This reverts commit 38f28dca3aa16efd6cc3af6453f2e6b9e9655ec1. Conflicts: activesupport/CHANGELOG.md activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb activesupport/test/core_ext/date_ext_test.rb activesupport/test/core_ext/date_time_ext_test.rb activesupport/test/core_ext/numeric_ext_test.rb activesupport/test/core_ext/time_ext_test.rb activesupport/test/core_ext/time_with_zone_test.rb commit 0d799a188dc12b18267fc8421675729917610047 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:53 2013 -0700 Revert "Refactor infinite comparable definition a bit" This reverts commit dd3360e05e4909f2f0c74a624cccc2def688f828. commit 42dec90e49745bbfae546f0560b8783f6b48b074 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:47 2013 -0700 Revert "Require 'active_support/core_ext/module/aliasing' in the infinite_comparable module" This reverts commit 7003e71c13c53ec3d34250560fbf80b8381df693.
* Standardise the return value of `to_time`Andrew White2013-01-211-2/+6
| | | | | | | | | | | | | | | | | | | | | | This commit standardises the return value of `to_time` to an instance of `Time` in the local system timezone, matching the Ruby core and standard library behavior. The default form for `String#to_time` has been changed from :utc to :local but research seems to suggest the latter is the more common form. Also fix an edge condition with `String#to_time` where the string has a timezone offset in it and the mode is :local. e.g: # Before: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 05:00:00 -0500 # After: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 00:00:00 -0500 Closes #2453
* Remove assert_nothing_raisedRafael Mendonça França2013-01-031-4/+2
|
* Added ability to compare date/time with infinitybUg2013-01-041-0/+7
| | | | | | | | | | | | | | | | | Date, DateTime, Time and TimeWithZone can now be compared to infinity, so it's now possible to create ranges with one infinite bound and date/time object as another bound. Ex.: @range = Range.new(Date.today, Float::INFINITY) Also it's possible to check inclusion of date/time in range with conversion. Ex.: @range.include?(Time.now + 1.year) # => true @range.include?(DateTime.now + 1.year) # => true Ability to create date/time ranges with infinite bound is required for handling postgresql range types.
* Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-1/+1
| | | | | | | The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.
* Deprecate Date#to_time_in_current_zoneAndrew White2012-12-111-0/+8
| | | | | | | | | | | | | The to_time_in_current_zone method doesn't match the naming of the methods for converting to ActiveSupport::TimeWithZone on Time and DateTime. Since DateTime inherits from Date that has led to confusion with some users using the to_time_in_current_zone method with DateTime instances and having the time part dropped and the UTC offset lost. This commit fixes this by deprecating the old method and adding a new in_time_zone method which matches the naming for DateTime and Time. This should prevent accidently dropping times and UTC offsets when converting DateTime instances to ActiveSupport::TimeWithZone.
* Refactored common date and time calculations.Pan Thomakos2012-08-041-158/+15
| | | | | | | | * Added the `DateAndTime::Calculations` module that is included in Time and Date. It houses common calculations to reduce duplicated code. * Simplified and cleaned-up the calculation code. * Removed duplication in tests by adding a behavior module for shared tests. I also added some missing tests.
* Add prev_quarter and next_quarter method in Time/Date/DateTimeparanoiase Kang2012-06-201-0/+12
|
* respect nsec in TimeWithZoneVasiliy Ermolovich + Sergey Nartimov2012-05-181-2/+2
| | | | | | | | | | | when we pass fractional usec to Time methods we should use Rational instead of Float because of accuracy problem Time.local(2011,6,12,23,59,59,999999.999).nsec # => 999999998 Time.local(2011,6,12,23,59,59,Rational(999999999, 1000)).nsec # => 999999999
* Adding :last_week, :last_month, and :last_year aliases to Time and DateMatt Bridges2012-02-211-0/+24
| | | | core extensions
* use AS::TestCase as the base classAaron Patterson2012-01-051-1/+1
|
* Initial pass at removing dead 1.8.x code from Active Support.José Valim2011-12-201-10/+0
| | | | | | There are a bunch of other implicit branches that adds 1.8.x specific code that still needs to be removed. Pull requests for those cases are welcome.
* add more tests for monday and sunday methodsVijay Dev2011-11-261-0/+2
|
* Tests added for monday and sunday Arun Agrawal2011-11-261-0/+8
| | | | | Reference commits : a8f2860d0e7db86c61bb70935006100b04667ab1 80ac4dc6d0632937ccf61b38bc15fc2f6e27b18b
* Allow a Date to be frozen more than once without an error in Ruby 1.8.xBradley Buda2011-06-081-0/+6
|
* removing stubs. 1.9.3 implements Date.today in C so mocking the return value ↵Aaron Patterson2011-03-071-9/+4
| | | | of Time.now does nothing
* updated Time, Date and DateTime current methods in AS to use Time.zone and ↵Josh Kalderimis2011-02-281-16/+16
| | | | | | not Time.zone_default. [#6410 state:committed]
* Add Date#rfc3339 and Date#iso8601 to ASSantiago Pastorino2011-02-131-0/+10
|
* implements weeks_ago and prev_week for Date/DateTime/Time [#5122 ↵Rob Zolkos & Xavier Noria2010-10-161-0/+16
| | | | state:committed]
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-8/+8
| | | | 's/[ \t]*$//' -i {} \;)
* Date#since, #ago, #beginning_of_day, #end_of_day, #xmlschema return ↵Geoff Buesing2010-06-121-1/+50
| | | | | | TimeWithZone when Time.zone_default is set Signed-off-by: Xavier Noria <fxn@hashref.com>
* oops, two cancelling errors made a previous test pass, fixing itXavier Noria2010-06-071-1/+1
|
* the order in which we apply deltas in Date#advance matters, add test ↵Xavier Noria2010-06-071-0/+10
| | | | coverage for that