aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time/calculations.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-6/+6
| | | | 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-6/+6
|
* Add additional options to time `change` methodsAndrew White2017-04-141-15/+21
| | | | | | | Support `:offset` in `Time#change` and `:zone` or `:offset` in `ActiveSupport::TimeWithZone#change`. Fixes #28723.
* Add `Time.rfc3339` parsing methodAndrew White2017-03-031-0/+23
| | | | | | | The `Time.xmlschema` and consequently its alias `iso8601` accepts timestamps without a offset in contravention of the RFC 3339 standard. This method enforces that constraint and raises an `ArgumentError` if it doesn't.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-15/+15
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-7/+7
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Introduce Date#all_dayHenrik Nyh2016-05-111-5/+0
| | | | | | | | | 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.
* Change Time#sec_fraction to use subsecAndrew White2016-04-231-2/+2
| | | | Time instances can have fractional parts smaller than a nanosecond.
* Add Time#sec_fractionAndrew White2016-04-231-0/+7
| | | | | Mirrors the DateTime#sec_fraction method by returning the fraction of the second as a Rational.
* delete code commented out (and replaced) in e93d0a5Tony Ta2015-12-151-1/+0
|
* Add days_in_year methodJon Pascoe2015-11-101-0/+6
|
* Merge pull request #21868 from tanmay3011/fix_time_class_documentationVijay Dev2015-10-051-3/+3
|\ | | | | [ci skip] Fix #seconds_since_midnight documentation output it will al…
| * [ci skip] Fix #seconds_since_midnight documentation output it will always ↵Tanmay Sinha2015-10-051-3/+3
| | | | | | | | return floating pointnumber
* | Merge pull request #21863 from tanmay3011/use_applications_yearSean Griffin2015-10-041-1/+1
|\ \ | | | | | | Use #current instead of #now to prevent zone issues and use new ruby …
| * | Use Time#current instead of Time#now to prevent zone issue inorder to use ↵Tanmay Sinha2015-10-041-1/+1
| |/ | | | | | | application's time zone
* / Renamed ‘Return’ to ‘Returns’ [ci skip]Ronak Jangir2015-09-281-1/+1
|/
* Merge pull request #20534 from qnm/activesupport-require-issueYves Senn2015-09-071-0/+1
|\ | | | | Add require to ensure Time#advance works without implicit required
| * Add missing require to ensure #advance will work without being implicity ↵Rob Sharp2015-06-121-0/+1
| | | | | | | | required
* | [ci skip] Update Time#advance documentation with examplesMichael Stock2015-08-021-0/+6
|/
* Fix a range of values for parameters of the Time#changeNikolay Kondratyev2015-06-011-1/+1
| | | | | Passing 999999000 < `:nsec` < 999999999 and 999999 < `:usec` < 1000000 to change a time with utc_offset doesn't throw an `ArgumentError`.
* Revert "Replace use of alias chains with prepend at core_ext/date and ↵Roque Pinel2015-05-291-2/+57
| | | | core_ext/time"
* Replace use of alias chains with prepend at core_ext/datePablo Herrero2015-05-041-57/+2
|
* Only coerce time when comparing if necessaryAaron Jensen2015-03-311-2/+4
| | | | | | In dev, ActiveSupport::FileUpdateChecker#max_mtime triggers many time comparisons. Time#to_time is quite a bit slower than not doing it, so we should avoid it if possible.
* [ci skip] Update documentation for Time#seconds_since_midnightAnton Davydov2015-03-061-1/+5
|
* Fix typo in Time#change docsJohn Duff2015-02-021-1/+1
|
* Remove some comments about Ruby 1.9 behaviorsRafael Mendonça França2015-01-041-3/+3
|
* Time#change can now change nanoseconds (:nsec)Agis-2014-09-141-6/+13
| | | | Closes #16392.
* Time#change throws exception with an out-of-range :usecAgis-2014-09-041-0/+1
| | | | | | | | | | https://github.com/rails/rails/commit/98b46bf5e201307cae56ee14bf41363a539779c5 did not properly handled out-of-range `:usec`s. Passing a `:usec` that's out of range now throws an `ArgumentError` as it should. Fixes #16759.
* Merge pull request #10634 from teleological/time_advance_gregorianAndrew White2014-01-051-4/+6
|\ | | | | Maintain proleptic gregorian in Time#advance
| * Maintain proleptic gregorian in Time#advanceRiley Lynch2013-05-151-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Time#advance uses Time#to_date and Date#advance to calculate a new date. The Date object returned by Time#to_date is constructed with the assumption that the Time object represents a proleptic gregorian date, but it is configured to observe the default julian calendar reform date (2299161j) for purposes of calculating month, date and year: Time.new(1582, 10, 4).to_date.to_s # => "1582-09-24" Time.new(1582, 10, 4).to_date.gregorian.to_s # => "1582-10-04" This patch ensures that when the intermediate Date object is advanced to yield a new Date object, that the Time object for return is contructed with a proleptic gregorian month, date and year.
* | Added Date#all_week/month/quarter/year for generating date rangesDimko2013-12-031-21/+0
| |
* | 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-0/+10
| |/ | | | | | | Added middle_of_day method to Date and DateTime
* | Return local time for backwards compatibilityAndrew White2013-07-091-1/+1
| |
* | Retain UTC offset when using Time.at_with_coercionAndrew White2013-07-091-3/+8
| | | | | | | | | | | | | | | | | | | | The standard Ruby behavior for Time.at is to return the same type of time when passing an instance of Time as a single argument. Since the an ActiveSupport::TimeWithZone instance may be a different timezone than the system timezone and DateTime just understands offsets the best we can do is to return an instance of Time with the correct offset. Fixes #11350.
* | Fix microsecond precision of Time#at_with_coercionNeer Friedman2013-07-091-1/+1
| | | | | | | | | | | | | | | | When Time.at_with_coercion (wraps Time.at) is called with a single argument that "acts_like?(:time)" it is coerced to integer thus losing it's microsecond percision. This commits changes this to use `#to_f` to prevent the problem
* | Removed unsued deprecation requireRashmi Yadav2013-07-041-1/+0
| |
* | Remove deprecated `Time#time_with_datetime_fallback`, `Time#utc_time`Vipul A M2013-07-031-35/+0
| | | | | | | | and `Time#local_time` in favour of `Time#utc` and `Time#local`
* | Override Time.at to work with Time-like valuesAndrew White2013-06-081-0/+12
|/ | | | | | | Time.at allows passing a single Time argument which is then converted to an integer. The conversion code since 1.9.3r429 explicitly checks for an instance of Time so we need to override it to allow DateTime and ActiveSupport::TimeWithZone values.
* Correct comment for (beginning|end)_of_minuteGert Goet2013-02-221-2/+2
|
* Added beginning_of_minute support to core_ext calculations for Time and DateTimeGagan Awhad2013-02-211-0/+15
|
* Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-0/+10
| | | | | | | 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.
* Add missing at_end_of_* aliasesAndrew White2012-12-111-0/+2
|
* Add #seconds_until_end_of_day to DateTime and TimeOlek Janiszewski2012-11-291-0/+9
|
* Hash Syntax changes to 1.9 formatAvnerCohen2012-10-201-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-211-7/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.