aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/numeric/time.rb
Commit message (Collapse)AuthorAgeFilesLines
* Simplify API documentation of methods that return a Durationbogdanvlviv2017-10-241-17/+5
| | | | Related to #30972
* Make clear that Time core extensions are split between Numeric and IntegerJoão Fernandes2017-10-241-6/+8
| | | | | | | The documentation wrongly suggests that Time extensions to Numeric include methods months and years, when these belong to Integer. Update both classes and guides.
* [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
|
* Add duration constructors for use in Numeric extensionsAndrew White2017-01-121-6/+6
| | | | | The Numeric extensions like 1.day, 1.month, etc. shouldn't know how the internals of ActiveSupport::Duration works.
* Fix inconsistent results when parsing large durations and constructing ↵Andrey Novikov2017-01-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | durations from code ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true Duration parsing made independent from any moment of time: Fixed length in seconds is assigned to each duration part during parsing. Changed duration of months and years in seconds to more accurate and logical: 1. The value of 365.2425 days in Gregorian year is more accurate as it accounts for every 400th non-leap year. 2. Month's length is bound to year's duration, which makes sensible comparisons like `12.months == 1.year` to be `true` and nonsensical ones like `30.days == 1.month` to be `false`. Calculations on times and dates with durations shouldn't be affected as duration's numeric value isn't used in calculations, only parts are used. Methods on `Numeric` like `2.days` now use these predefined durations to avoid duplicating of duration constants through the codebase and eliminate creation of intermediate durations.
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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`.
* 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]
* :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().
* update some AS code examples to 1.9 hash syntax [ci skip]Francesco Rodriguez2012-09-121-3/+3
|
* 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 {} \;)
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+2
|
* Convert Numeric bytes and time extension modules to class reopenJeremy Kemper2009-03-281-75/+69
|
* Deprecated Float#years and Float#months, moved Numeric#years and ↵Tom Lea2008-10-131-10/+0
| | | | Numeric#months into Integer.
* 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
* 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-151-0/+59
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@624 5ecf4fe2-1ee6-0310-87b1-e25e094e27de