1. 11 11月, 2015 1 次提交
  2. 16 10月, 2015 1 次提交
    • M
      fixes #21815 · 86d2924a
      Maarten Jacobs 提交于
      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
      86d2924a
  3. 07 6月, 2015 1 次提交
  4. 01 6月, 2015 1 次提交
  5. 06 1月, 2015 1 次提交
    • P
      DateTime#<=> return nil when compare to the invalid String as Time. · 0599bfa2
      pocke 提交于
      before:
      
          p Time.now ==  'a'  # => false
          p Time.now <=> 'a'  # => nil
      
          require 'active_support'
          require 'active_support/core_ext'
      
          p Time.now ==  'a'  # => false
          p Time.now <=> 'a'  # => invalid date (ArgumentError)
      
      and on ruby 2.2, Time.now == 'a' warning.
      
          warning: Comparable#== will no more rescue exceptions of #<=> in the next release.
          warning: Return nil in #<=> if the comparison is inappropriate or avoid such comparison.
      
      after:
      
      - Error handling.
      - Quiet warnings.
      0599bfa2
  6. 14 9月, 2014 1 次提交
  7. 05 9月, 2014 1 次提交
  8. 18 6月, 2014 1 次提交
  9. 29 7月, 2013 3 次提交
  10. 09 7月, 2013 3 次提交
    • A
      Return local time for backwards compatibility · c42260a3
      Andrew White 提交于
      c42260a3
    • A
      Retain UTC offset when using Time.at_with_coercion · 1b387373
      Andrew White 提交于
      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.
      1b387373
    • N
      Fix microsecond precision of Time#at_with_coercion · 48425351
      Neer Friedman 提交于
      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
      48425351
  11. 03 7月, 2013 1 次提交
  12. 08 6月, 2013 1 次提交
    • A
      Override Time.at to work with Time-like values · b7f9de27
      Andrew White 提交于
      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.
      b7f9de27
  13. 15 5月, 2013 1 次提交
    • R
      Maintain proleptic gregorian in Time#advance · 0c6ddbe7
      Riley Lynch 提交于
      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.
      0c6ddbe7
  14. 04 5月, 2013 1 次提交
    • A
      Squashed commit of the following: · 4c242e6d
      Aaron Patterson 提交于
      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 38f28dca.
      
          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 dd3360e0.
      
      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 7003e71c.
      4c242e6d
  15. 22 2月, 2013 1 次提交
  16. 21 1月, 2013 1 次提交
    • A
      Standardise the return value of `to_time` · b79adc43
      Andrew White 提交于
      This commit standardises the return value of `to_time` to an instance
      of `Time` in the local system timezone, matching the Ruby core and
      standard library behavior.
      
      The default form for `String#to_time` has been changed from :utc to
      :local but research seems to suggest the latter is the more common form.
      
      Also fix an edge condition with `String#to_time` where the string has
      a timezone offset in it and the mode is :local. e.g:
      
        # Before:
        >> "2000-01-01 00:00:00 -0500".to_time(:local)
        => 2000-01-01 05:00:00 -0500
      
        # After:
        >> "2000-01-01 00:00:00 -0500".to_time(:local)
        => 2000-01-01 00:00:00 -0500
      
      Closes #2453
      b79adc43
  17. 04 1月, 2013 2 次提交
    • R
      Remove assert_nothing_raised · 59e0c262
      Rafael Mendonça França 提交于
      59e0c262
    • B
      Added ability to compare date/time with infinity · 38f28dca
      bUg 提交于
      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.
      38f28dca
  18. 11 12月, 2012 1 次提交
    • A
      Deprecate obsolete Time to DateTime fallback methods · 48583f8b
      Andrew White 提交于
      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.
      48583f8b
  19. 29 11月, 2012 1 次提交
  20. 05 8月, 2012 1 次提交
    • P
      Refactored common date and time calculations. · b530fd10
      Pan Thomakos 提交于
      * Added the `DateAndTime::Calculations` module that is included in Time
        and Date. It houses common calculations to reduce duplicated code.
      * Simplified and cleaned-up the calculation code.
      * Removed duplication in tests by adding a behavior module for shared
        tests. I also added some missing tests.
      b530fd10
  21. 01 7月, 2012 1 次提交
  22. 20 6月, 2012 1 次提交
  23. 19 5月, 2012 1 次提交
  24. 18 5月, 2012 1 次提交
    • V
      respect nsec in TimeWithZone · dcdde7da
      Vasiliy Ermolovich + Sergey Nartimov 提交于
      when we pass fractional usec to Time methods we should use Rational
      instead of Float because of accuracy problem
      
          Time.local(2011,6,12,23,59,59,999999.999).nsec
          # => 999999998
      
          Time.local(2011,6,12,23,59,59,Rational(999999999, 1000)).nsec
          # => 999999999
      dcdde7da
  25. 17 5月, 2012 1 次提交
  26. 04 5月, 2012 1 次提交
  27. 22 2月, 2012 1 次提交
  28. 05 2月, 2012 1 次提交
  29. 26 1月, 2012 1 次提交
  30. 06 1月, 2012 1 次提交
  31. 05 1月, 2012 1 次提交
  32. 26 11月, 2011 1 次提交
  33. 23 11月, 2011 1 次提交
  34. 07 11月, 2011 1 次提交
    • H
      Removed argument throwing warnings when running tests. · 9a7d916c
      Henrik Hodne 提交于
      The last argument to DateTime.new/civil is the Julian day number for
      when the calendar reform occured. DateTime ignores it if it's 0, and
      sets it to the default of DateTime::ITALY instead, so we could just
      leave it out. This also removes the warnings while running the
      ActiveSupport tests (there still are some for the setup though).
      9a7d916c
  35. 08 9月, 2011 1 次提交