aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/calculations.rb
Commit message (Collapse)AuthorAgeFilesLines
* No dup nor delete from optionsKrzysztof Rybka2019-01-181-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memory comparison: Options: {:years=>1, :months=>1, :weeks=>1, :days=>1} Calculating ------------------------------------- master 576.000 memsize ( 0.000 retained) 5.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 288.000 memsize ( 0.000 retained) 4.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 288 allocated master: 576 allocated - 2.00x more Options: {:years=>1} Calculating ------------------------------------- master 264.000 memsize ( 0.000 retained) 2.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 72.000 memsize ( 0.000 retained) 1.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 72 allocated master: 264 allocated - 3.67x more Options: {:weeks=>1} Calculating ------------------------------------- master 264.000 memsize ( 0.000 retained) 2.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) advance_no_dup 72.000 memsize ( 0.000 retained) 1.000 objects ( 0.000 retained) 0.000 strings ( 0.000 retained) Comparison: advance_no_dup: 72 allocated master: 264 allocated - 3.67x more Peformance comparison: Options: {:years=>1, :months=>1, :weeks=>1, :days=>1} Warming up -------------------------------------- master 27.740k i/100ms advance_no_dup 37.705k i/100ms Calculating ------------------------------------- master 338.511k (± 5.9%) i/s - 1.692M in 5.020333s advance_no_dup 572.980k (± 3.7%) i/s - 2.866M in 5.008680s Comparison: advance_no_dup: 572979.7 i/s master: 338510.9 i/s - 1.69x slower Options: {:years=>1} Warming up -------------------------------------- master 53.313k i/100ms advance_no_dup 115.016k i/100ms Calculating ------------------------------------- master 639.715k (± 1.7%) i/s - 3.199M in 5.001851s advance_no_dup 1.579M (± 6.4%) i/s - 7.936M in 5.053876s Comparison: advance_no_dup: 1579251.7 i/s master: 639714.8 i/s - 2.47x slower Options: {:weeks=>1} Warming up -------------------------------------- master 57.353k i/100ms advance_no_dup 129.141k i/100ms Calculating ------------------------------------- master 674.113k (± 3.4%) i/s - 3.384M in 5.025973s advance_no_dup 1.911M (± 2.5%) i/s - 9.556M in 5.004496s Comparison: advance_no_dup: 1910739.3 i/s master: 674112.6 i/s - 2.83x slower
* Move implementation of `before?` and `after?` to `DateAndTime::Calculations`bogdanvlviv2018-03-311-2/+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/+2
| | | | | | | | 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.
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-5/+5
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-5/+5
|
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Improve readability of docs by using code tag [ci skip]Prakash Laxkar2015-09-291-1/+1
|
* Revert "Replace use of alias chains with prepend at core_ext/date and ↵Roque Pinel2015-05-291-2/+32
| | | | core_ext/time"
* Replace use of alias chains with prepend at core_ext/datePablo Herrero2015-05-041-32/+2
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-08-171-1/+1
|\ | | | | | | | | | | | | | | Conflicts: actionview/README.rdoc activerecord/lib/active_record/migration.rb guides/source/development_dependencies_install.md guides/source/getting_started.md
| * Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-1/+1
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
| * Minor refactor - Uses Enumerable#to_a instead of iterate and add to anPablo Cantero2013-07-271-1/+1
| | | | | | | | array
* | Added Time#middle_of_dayAnatoli Makarevich2013-07-281-1/+11
|/ | | | Added middle_of_day method to Date and DateTime
* The behavior we had in place in rc1 was actually to convert to DateTime and ↵David Heinemeier Hansson2013-06-031-2/+2
| | | | use <=> from there. Restore that.
* Allow Date to be compared with Time (like it was possible to compare Time ↵David Heinemeier Hansson2013-06-031-0/+11
| | | | with Date)
* Revert some warning removals related to Ruby 2.0Carlos Antonio da Silva2013-01-071-2/+0
| | | | | | | | | | | | | | | | | | These warnings were actually a bug in Ruby 2.0, the accessors should not be raising such warnings, they are only meant for ivars. - Revert "fix warnings in Ruby 2.0" This reverts commit 26702a6d3461f4a1c75165030b96886514ecb877. - Revert "Merge pull request #8282 from arunagw/warning_removed_for_ruby2" This reverts commit f63d6544e45e78cda29c0c56fbdf3d9e1f405340, reversing changes made to 3a890681fad8218305585036abed6d7463a44e41.
* Deprecate Date#to_time_in_current_zoneAndrew White2012-12-111-4/+4
| | | | | | | | | | | | | 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.
* Add missing at_end_of_* aliasesAndrew White2012-12-111-0/+1
|
* fix warnings in Ruby 2.0Aaron Patterson2012-11-071-0/+2
|
* keys.include? -> key?Xavier Noria2012-10-091-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-211-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: actionmailer/lib/action_mailer/base.rb activesupport/lib/active_support/configurable.rb activesupport/lib/active_support/core_ext/module/deprecation.rb guides/source/action_controller_overview.md guides/source/active_support_core_extensions.md guides/source/ajax_on_rails.textile guides/source/association_basics.textile guides/source/upgrading_ruby_on_rails.md While resolving conflicts, I have chosen to ignore changes done in docrails at some places - these will be most likely 1.9 hash syntax changes.
| * update AS/core_ext docs [ci skip]Francesco Rodriguez2012-09-121-2/+2
| |
* | Date.beginning_of_week thread local and beginning_of_week application config ↵gregolsen2012-09-181-0/+23
|/ | | | option added (default is Monday)
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-011-0/+1
|\
| * copy edits [ci skip]Vijay Dev2012-09-011-1/+1
| |
| * Expand documentation for change() method in Time, Date, and DateTimeJeff Shantz2012-08-291-0/+1
| |
* | Refactored common date and time calculations.Pan Thomakos2012-08-041-181/+2
|/ | | | | | | | * 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/+11
|
* Clean Date#beginning_of_month descriptionAlexey Vakhov2012-05-251-1/+1
| | | | | Unnecessary peace of text was injected at 507da04a149b44e20c5a0ba72a218fe1762b6baf by mistake.
* removing unnecessary 'examples' noise from activesupportFrancesco Rodriguez2012-05-131-2/+0
|
* AS core_ext refactoringAlexey Gaziev2012-04-291-15/+37
|
* Adding :last_week, :last_month, and :last_year aliases to Time and DateMatt Bridges2012-02-211-0/+7
| | | | core extensions
* remove date methods that are present in 1.9 rubySergey Nartimov2011-12-251-20/+0
|
* Initial pass at removing dead 1.8.x code from Active Support.José Valim2011-12-201-18/+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.
* Convert aliases monday and sunday to methodsVijay Dev2011-11-261-2/+12
| | | | | | | | A recent change to beginning_of_week and end_of_week added an argument that can be used to specify the week's starting day as a symbol. Now these methods were aliased as monday and sunday respectively which as a consequence of the argument addition, made calls like obj.monday(:sunday) possible. This commit makes them methods on their own.
* minor doc changesVijay Dev2011-11-261-3/+3
|
* some tweaks to PR#3547. [Closes #3547]Xavier Noria2011-11-251-7/+12
|
* API docstrings updated with default value infogregolsen2011-11-251-3/+3
|
* beginning_of_week extended in both Time and Date so that to return week ↵gregolsen2011-11-251-8/+16
| | | | start based on start day that is monday by default
* updating API docstring so that user can infer default valuegregolsen2011-11-171-2/+2
|
* Remove extra white spaces on ActiveSupport docs.Sebastian Martinez2011-05-231-1/+1
|
* Removed some redundant Time#change time options from beginning_of_ methods ↵Chris Kalafarski2011-03-131-3/+3
| | | | in Date and Time
* updated Time, Date and DateTime current methods in AS to use Time.zone and ↵Josh Kalderimis2011-02-281-2/+2
| | | | | | not Time.zone_default. [#6410 state:committed]
* implements weeks_ago and prev_week for Date/DateTime/Time [#5122 ↵Rob Zolkos & Xavier Noria2010-10-161-2/+14
| | | | state:committed]
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-2/+2
| | | | 's/[ \t]*$//' -i {} \;)
* itsy bitsy changes to documentationNeeraj Singh2010-07-281-13/+13
|