aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date
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-214-10/+10
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Clarify intentions around method redefinitionsMatthew Draper2017-09-011-9/+5
| | | | | | | | | Don't use remove_method or remove_possible_method just before a new definition: at best the purpose is unclear, and at worst it creates a race condition. Instead, prefer redefine_method when practical, and silence_redefinition_of_method otherwise.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-115-0/+5
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-095-0/+5
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-014-10/+10
|
* Add missing periodsJon Moss2017-04-171-2/+2
| | | | [ci skip]
* Add (more) documentation to to_timeKen Mayer2017-04-171-0/+3
| | | | | There's a difference in the results between `Date#to_time(:local)` and `Date#in_time_zone` but it is subtle and can confuse users (like me :-).
* `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
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-7/+7
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-065-20/+20
| | | | | 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-3/+3
| | | | | | | | | | | 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.
* Raise `ArgumentError` when an invalid form is passed to `Date#to_time`yui-knk2016-04-171-0/+1
| | | | | | | | 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.
* Improve readability of docs by using code tag [ci skip]Prakash Laxkar2015-09-291-1/+1
|
* Short-circuit `blank?` on date and time valuesAndrew White2015-09-211-0/+12
| | | | | | | The concept of a blank date or time doesn't make sense so we can short circuit the calls for `blank?` on these classes to gain small speed boost. Fixes #21657
* Corrected `to_time` output in ActiveSupport Date Conversion docs.Since ↵amitkumarsuroliya2015-09-181-3/+3
| | | | | https://github.com/rails/rails/commit/48583f8bf74d1cefefea3cd6591bd546a9eaff6c, to_time returns times formatted as YYYY-MM-DD HH:MM:SS UTC [ci skip] `to_time` method now returns in `YYYY-MM-DD HH:MM:SS UTC` format.
* Revert "Replace use of alias chains with prepend at core_ext/date and ↵Roque Pinel2015-05-292-18/+32
| | | | core_ext/time"
* Merge pull request #19878 from pabloh/replace_alias_chains_with_prependRafael Mendonça França2015-05-282-32/+18
|\ | | | | Replace use of alias chains with prepend at core_ext/date and core_ext/time
| * Replace use of alias chains with prepend at core_ext/datePablo Herrero2015-05-042-32/+18
| |
* | [skip ci] Update documentation for Date classAnton Davydov2015-05-211-0/+6
|/
* Avoid raising a NameError on FreeBSD using DateRobin Dupret2014-01-011-2/+5
| | | | | | | | | | | | The Date object has a xmlschema method starting with Ruby 1.9 so we were assuming that we could safely remove this method and redefine it later but the call to remove_method throws a NameError on FreeBSD so we should rely on remove_possible_method instead. This call is actually needed to avoid warnings when running the test suite. Fixes #11723
* doc: date/conversions.rb should talk about date format not time format.Yves Senn2013-12-101-2/+2
| | | | | | Closes #13245. [ci skip]
* 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.
* | Refactor Date, Time, DateTime timezone methodsGilad Zohari2013-08-011-18/+2
| | | | | | | | | | | | Similar implementations of #in_time_zone exists for Date, Time and DateTime so method is extracted into its own module. Also some logic is extracted into private method.
* | Merge pull request #10879 from makaroni4/masterAndrew White2013-07-291-0/+10
|\ \ | | | | | | Added Time#middle_of_day method
| * | Added Time#middle_of_dayAnatoli Makarevich2013-07-281-1/+11
| | | | | | | | | | | | Added middle_of_day method to Date and DateTime
* | | Fix handling of offsets with Time#to_s(:iso8601)Andrew White2013-07-291-1/+3
| |/ |/| | | | | | | | | 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.
* | Minor refactor - Uses Enumerable#to_a instead of iterate and add to anPablo Cantero2013-07-271-1/+1
| | | | | | | | array
* | Remove deprecated `Date#to_time_in_current_zone`Vipul A M2013-07-021-15/+0
|/
* 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)
* 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.
* remove unused requireTomohiko Himura2013-04-251-1/+0
| | | | not used remove_possible_method
* remove_possible_method -> remove_methodNihad Abbasov2013-01-111-2/+2
| | | | Date#to_time and Date#xmlschema methods defined in Ruby 1.9.3
* 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.
* Added ability to compare date/time with infinitybUg2013-01-041-0/+5
| | | | | | | | | | | | | | | | | 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-113-5/+27
| | | | | | | | | | | | | 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-213-5/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-123-5/+6
| |
* | 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
| |