aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require_relative => requireAkira Matsuda2017-10-215-14/+14
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Fix formatting of `Time.use_zone` [ci skip]yuuji.yaginuma2017-10-041-4/+4
|
* Clarify intentions around method redefinitionsMatthew Draper2017-09-011-2/+2
| | | | | | | | | 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-015-14/+14
|
* 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.
* Move `to_time` to `DateTime` compatibility.rb fileAndrew White2017-03-161-0/+2
| | | | | | We are overriding it in `Time` and `ActiveSupport::TimeWithZone` so there's no point in having it in the `DateAndTime::Compatibility` module. Also add some docs for the `to_time` implementations.
* Merge pull request #28147 from kmcphillips/master-time-freezeAndrew White2017-03-161-1/+8
|\ | | | | Allow Time#to_time on frozen objects. Return frozen time rather than "RuntimeError: can't modify frozen Time"
| * Handle #to_time and memoization taking into account memoization, frozen ↵Kevin McPhillips2017-03-061-1/+8
| | | | | | | | state, and preserve_timezone flag.
* | Add `rfc3339` aliases to `xmlschema`Andrew White2017-03-031-0/+3
| | | | | | | | | | For naming consistency when using the RFC 3339 profile of ISO 8601 in applications.
* | 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.
* Remove deprecated time marshal core_ext fileAndrew White2016-11-131-3/+0
|
* 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-062-25/+25
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-066-22/+22
| | | | | 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.
* Add compatibility for Ruby 2.4 `to_time` changesAndrew White2016-04-231-0/+5
| | | | | | | | | | | | | | | In Ruby 2.4 the `to_time` method for both `DateTime` and `Time` will preserve the timezone of the receiver when converting to an instance of `Time`. Since Rails 5.0 will support Ruby 2.2, 2.3 and later we need to introduce a compatibility layer so that apps that upgrade do not break. New apps will have a config initializer file that defaults to match the new Ruby 2.4 behavior going forward. For information about the changes to Ruby see: https://bugs.ruby-lang.org/issues/12189 https://bugs.ruby-lang.org/issues/12271 Fixes #24617.
* Document scoping issue with Time.use_zoneAndrew White2016-01-231-1/+17
| | | | | | | | | | | | | | | | The Time.use_zone method will only affect ActiveSupport::TimeWithZone instances created inside of the block passed to Time.use_zone. This could be confusing when fetching a model and then reading the attribute before the block and it not changing afterwards because Active Record caches the conversion from the database value. Since changing the behavior of Active Record to recreate the value on every attribute read is an expensive operation the best we can do is to document the issue. Fixes #23195. [ci skip]
* delete code commented out (and replaced) in e93d0a5Tony Ta2015-12-151-1/+0
|
* Add days_in_year methodJon Pascoe2015-11-101-0/+6
|
* fixes #21815Maarten Jacobs2015-10-161-0/+1
| | | | | | | | | | | | | | | The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM. This commit adds: A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because - model couldn't be defined inline - transactional testing needed to be turned off to get it to pass the MySQL tests This seemed cleaner than putting it in an existing testcase file. It adds :usec as a dateformat that calculates datetime in microseconds It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
* 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 #21866 from tanmay3011/fix_documentationSean Griffin2015-10-041-1/+1
|\ \ | | | | | | Fix Time.now format in documentation [ci skip]
| * | Fix Time.now format in documentationTanmay Sinha2015-10-041-1/+1
| |/
* | 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
* | Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-10-041-1/+1
|\ \ | |/ |/|
| * Renamed ‘Return’ to ‘Returns’ [ci skip]Ronak Jangir2015-09-281-1/+1
| |
* | Improve readability of docs by using code tag [ci skip]Prakash Laxkar2015-09-291-1/+1
| |
* | Update docs for `formatted_offset` Ronak Jangir2015-09-291-1/+2
|/ | | Output of `formatted_offset` is depends on input so it’s not always in +HH:MM format. Possible outputs are “+5:30”, “+530” or provided alternate UTC string [ci skip]
* 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
| |
* | [skip ci] Lookup can be a noun but it is not a verbJon Atack2015-07-171-1/+2
|/ | | | Various grammar corrections and wrap to 80 characters.
* 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-292-38/+57
| | | | core_ext/time"
* Replace use of alias chains with prepend at core_ext/datePablo Herrero2015-05-042-57/+38
|
* 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
|
* s/around_filter/around_action/Akira Matsuda2015-02-211-1/+1
|
* Fix typo in Time#change docsJohn Duff2015-02-021-1/+1
|
* Remove unneeded Time patch to support Ruby 1.9Rafael Mendonça França2015-01-041-29/+2
|
* Remove some comments about Ruby 1.9 behaviorsRafael Mendonça França2015-01-041-3/+3
|
* Replace `#=>` with `# =>` [ci skip]claudiob2014-12-171-8/+8
| | | | | | | | @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 Time#find_zoneclaudiob2014-12-171-1/+16
| | | | | | Also improves docs for `Time#find_zone!` [ci skip]