aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/numeric
Commit message (Collapse)AuthorAgeFilesLines
* Change 1.week to create 1 week durations instead of 7 days durations.Andrey Novikov2016-04-281-8/+8
| | | | This is just to remove astonishment from getting `3600 seconds` from typing `1.hour`.
* Revert "Change 1.week to create 1 week durations instead of 7 days durations."Jeremy Daer2016-04-271-8/+8
| | | | | | Regression: adding minutes/hours to a time would change its time zone This reverts commit 1bf9fe75a6473cb7501cae544cab772713e68cef.
* Change 1.week to create 1 week durations instead of 7 days durations.Andrey Novikov2016-04-181-8/+8
| | | | This is just to remove astonishment from getting `3600 seconds` from typing `1.hour`.
* Show correct return types for examples [ci skip]Gert Goet2016-02-201-49/+49
|
* Fix - to_s(:db) on Numeric rangeAkshay Vishnoi2015-12-291-1/+5
|
* Merge pull request #22822 from maclover7/fix-22805Richard Schneeman2015-12-281-0/+1
|\ | | | | Add a missing require to ActiveSupport::NumericWithFormat
| * Add a missing require to ActiveSupport::NumericWithFormatJon Moss2015-12-281-0/+1
| |
* | Add support for Petabyte and Exabyte in number to human sizeAkshay Vishnoi2015-12-221-0/+2
|/
* Merge pull request #20038 from imanel/numeric_prependSean Griffin2015-10-201-25/+12
|\ | | | | Use Module.prepend instead of alias_method and unify behavior of all Numeric extensions
| * Unify behavior of all Numeric extensions and use Module.prepend instead of ↵Bernard Potocki2015-05-281-25/+12
| | | | | | | | alias_method
* | Corrected numeric conversions output [ci skip]amitkumarsuroliya2015-09-191-2/+2
| |
* | Only define #positive? and #negative? on Ruby 2.2Rafael Mendonça França2015-05-191-0/+7
| | | | | | | | | | | | | | The feature was accepted and added to Ruby 2.3+ so we don't need to define it again. See https://bugs.ruby-lang.org/issues/11151
* | Move Integer#positive? and Integer#negative? query methods to Numeric classMehmet Emin İNAÇ2015-05-131-0/+19
|/ | | | By this way Integer, Rational, Float, Fixnum, Bignum classes have the same behaviour
* Remove reference to Numeric#from_now, as it is no longer supportednerdinand2015-03-231-15/+0
|
* fix dependencyJian Weihang2015-01-121-0/+2
|
* Add docs for Numeric time-related methodsclaudiob2014-12-171-0/+18
| | | | | | | Add docs for `minutes`, `hours`, `days`, `weeks` and `fortnights`. Fix docs for `in_milliseconds`. [ci skip]
* Replace `#=>` with `# =>` [ci skip]claudiob2014-12-171-7/+7
| | | | | | | | @rafaelfranca suggested in f7c7bcd9 that code examples should display the result after `# =>` and not after `#=>`. This commit replaces *all* the occurrences of `#=>` in the code documentation (mostly added by me :sob:) with the suggested `# =>`.
* Add docs for Numeric#*_bytes methodsclaudiob2014-12-171-0/+20
| | | | | | | Add docs for `kilobytes`, `megabytes`, `gigabytes`, `terabytes`, `petabytes` and `exabytes`. Fix docs for `bytes`. [ci skip]
* Prevent Numeric#to_s from allocating an arrayJean Boussier2014-11-281-9/+19
|
* :scissors: removed deprecated `Numeric#ago` and friendsGodfrey Chan2014-05-301-19/+1
| | | | | | | | | | | | | | Replacements: 5.ago => 5.seconds.ago 5.until => 5.seconds.until 5.since => 5.seconds.since 5.from_now => 5.seconds.from_now The removed tests does not affect coverage – we have equivalent test cases in the tests for `AS::Duration`. See #12389 for the history and rationale behind this.
* Deprecated Numeric#{ago,until,since,from_now}Godfrey Chan2013-11-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | The user is expected to explicitly convert the value into an AS::Duration, i.e. `5.ago` => `5.seconds.ago` This will help to catch subtle bugs like: def recent?(days = 3) self.created_at >= days.ago end The above code would check if the model is created within the last 3 **seconds**. In the future, `Numeric#{ago,until,since,from_now}` should be removed completely, or throw some sort of errors to indicate there are no implicit conversion from `Numeric` to `AS::Duration`. Also fixed & refactor the test cases for Numeric#{ago,since} and AS::Duration#{ago,since}. The original test case had the assertion flipped and the purpose of the test wasn't very clear.
* Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed ↵David Heinemeier Hansson2013-11-021-0/+6
| | | | them to JavaScript functions like getTime().
* Squashed commit of the following:Aaron Patterson2013-05-031-9/+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 unnecessary requiresRafael Mendonça França2013-01-031-2/+0
|
* Added ability to compare date/time with infinitybUg2013-01-041-0/+11
| | | | | | | | | | | | | | | | | 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.
* update some AS code examples to 1.9 hash syntax [ci skip]Francesco Rodriguez2012-09-122-67/+67
|
* Review requires from number helperCarlos Antonio da Silva2012-05-281-6/+6
| | | | | | | | Some of these requires are now only necessary in ActiveSupport::NumberHelper. Add hash/keys require due to symbolize_keys usage in number helpers. Also remove some whitespaces. Closes #6414
* Moving NumberHelpers from ActionView to ActiveSupportAndrew Mutz2012-05-271-0/+135
|
* Changes for numeric api for Time because Time.current works differentAlexey Gaziev2012-05-071-3/+3
|
* update stdlib doc urls in comments - ↵Trevor Wennblom2012-04-071-3/+3
| | | | | | active_support/core_ext/[integer|numeric]/time.rb http://stdlib.rubyonrails.org/ last updated in 2005
* add some missing requires for AS core_ext/numeric/time. Closes #1038Josh Kalderimis2011-05-181-0/+2
|
* Use `Time.current` to maintain consistency with AS::DurationPrem Sichanugrist2010-09-191-2/+2
| | | | | | | | | | In [32b82e4c6f5523cdf5ee78c3022c50b46e018351], the committer has switch methods in AS::Duration to use `Time.current` to return the correct duration based on the `Time.default_zone` instead of using `Time.now`. [#5607 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-9/+9
| | | | 's/[ \t]*$//' -i {} \;)
* Bytes calculation speed upLuca Guidi2009-06-131-8/+15
| | | | | | [#2800 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+2
|
* Convert Numeric bytes and time extension modules to class reopenJeremy Kemper2009-03-282-113/+100
|
* Move Numeric#to_utc_offset_s to TimeZone.seconds_to_utc_offsetJeremy Kemper2009-03-231-15/+0
|
* Convert Numeric extension module to a class reopenJeremy Kemper2009-03-211-17/+13
|
* Deprecated Float#years and Float#months, moved Numeric#years and ↵Tom Lea2008-10-131-10/+0
| | | | Numeric#months into Integer.
* Refactor number-to-HH:MM-string conversion logic from ↵Geoff Buesing2008-01-121-0/+19
| | | | | | TimeZone#formatted_offset to reusable Numeric#to_utc_offset_s method git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8635 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make 1.months and friends accurate by introducing a Duration class. #6835 ↵Michael Koziarski2007-01-151-11/+30
| | | | | | [eventualbuddha] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5940 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Fixnum#seconds for consistency, so you can say 5.minutes + 30.seconds ↵David Heinemeier Hansson2006-03-251-0/+5
| | | | | | instead of 5.minutes + 30 (closes #4389) [Francois Beausoleil] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4029 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Time#advance to do precise time time calculations for cases where a ↵David Heinemeier Hansson2006-03-161-0/+3
| | | | | | month being approximated to 30 days won't do (closes #1860) [Rick Olson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3887 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added a note to the documentation for the Date related Numeric extensions to ↵Michael Koziarski2006-03-091-1/+6
| | | | | | | | | indicate that they're approximations and shouldn't be used for critical calculations. [Koz]. Closes #4148. References #4146 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3821 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added petabytes and exebytes to numeric extensions (closes #2397) ↵David Heinemeier Hansson2005-10-261-0/+11
| | | | | | [timct@mac.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2746 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Increased accuracy of 1.year by accounting for leap years. The time ↵Jeremy Kemper2005-06-241-2/+2
| | | | | | extensions are not meant to be super-precise but this seems worth it since otherwise you lose a lot of days doing 40.years.ago. Closes #1488 [tuxie@dekadance.se] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1499 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Moved Active Support into its own gemDavid Heinemeier Hansson2005-02-152-0/+92
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@624 5ecf4fe2-1ee6-0310-87b1-e25e094e27de