aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time
Commit message (Collapse)AuthorAgeFilesLines
* 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]
* Time includes DateAndTime::Zones acts_like(:time)betesh2014-11-091-0/+1
|
* 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.
* [ci skip] builtin -> built-inAkshay Vishnoi2014-04-201-1/+1
|
* 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
| |
* | Refactor Date, Time, DateTime timezone methodsGilad Zohari2013-08-011-20/+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-0/+10
| |/ | | | | | | Added middle_of_day method to Date and DateTime
* | Fix handling of offsets with Time#to_s(:iso8601)Andrew White2013-07-291-1/+2
| | | | | | | | | | | | 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.
* | Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format ↵David Heinemeier Hansson2013-07-281-1/+2
| | | | | | | | for easy Javascript date parsing
* | Return local time for backwards compatibilityAndrew White2013-07-091-1/+1
| |