1. 07 3月, 2018 1 次提交
    • N
      Add `before?` and `after?` methods to date and time classes · 20fa0d92
      Nick Holden 提交于
      Equality comparisons between dates and times can take some extra time to
      comprehend. I tend to think of a date or time as "before" or "after"
      another date or time, but I naturally read `<` and `>` as "less than"
      and "greater than." This change seeks to make date/time comparisons more
      human readable.
      20fa0d92
  2. 11 7月, 2017 1 次提交
  3. 09 7月, 2017 1 次提交
  4. 02 7月, 2017 1 次提交
  5. 01 7月, 2017 1 次提交
  6. 02 3月, 2017 1 次提交
    • A
      Update `DateTime#change` to support usec and nsec · b5af7515
      Andrew White 提交于
      Adding support for these options now allows us to update the
      `DateTime#end_of` methods to match the equivalent `Time#end_of`
      methods, e.g:
      
          datetime = DateTime.now.end_of_day
          datetime.nsec == 999999999 # => true
      
      Fixes #21424.
      b5af7515
  7. 07 8月, 2016 2 次提交
  8. 24 4月, 2016 3 次提交
    • A
      Make getlocal and getutc always return instances of Time · ee5e476a
      Andrew White 提交于
      Previously these methods could return either a DateTime or a Time
      depending on how the ActiveSupport::TimeWithZone instance had
      been constructed. Changing to always return an instance of Time
      eliminates a possible stack level too deep error in to_time where
      it was wrapping a DateTime instance.
      
      As a consequence of this the internal time value is now always an
      instance of Time in the UTC timezone, whether that's as the UTC
      time directly or a representation of the local time in the timezone.
      
      There should be no consequences of this internal change and if
      there are it's a bug due to leaky abstractions.
      ee5e476a
    • A
      Add DateTime#subsec · a424bbb2
      Andrew White 提交于
      Mirrors the Time#subsec method by returning the fraction
      of the second as a Rational.
      a424bbb2
    • A
      Add additional aliases for DateTime#utc · dbc7a7cb
      Andrew White 提交于
      dbc7a7cb
  9. 23 4月, 2016 1 次提交
    • Y
      Move `DateTime#getlocal` to `/core_ext/date_time/calculations.rb` · 941eee5c
      yui-knk 提交于
      `DateTime#getlocal` is newly added public API.
      It's responsible is same as `DateTime#utc`, so `calculations.rb` is
      a best plase to define this method.
      For keeping consistency with `DateTime#utc`, defines `#localtime` and
      defines `getlocal` as an alias method.
      941eee5c
  10. 04 4月, 2016 1 次提交
    • A
      Call super instead of returning nil for DateTime#<=> · 08073125
      Andrew White 提交于
      The native DateTime#<=> implementation can be used to compare instances
      with numeric values being considered as astronomical julian day numbers
      so we should call that instead of returning nil.
      
      Fixes #24228.
      08073125
  11. 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
  12. 05 12月, 2014 1 次提交
  13. 07 8月, 2014 1 次提交
  14. 10 1月, 2014 1 次提交
  15. 30 8月, 2013 1 次提交
  16. 31 7月, 2013 1 次提交
  17. 29 7月, 2013 1 次提交
  18. 05 7月, 2013 1 次提交
  19. 04 7月, 2013 1 次提交
  20. 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
  21. 02 5月, 2013 1 次提交
  22. 25 2月, 2013 1 次提交
  23. 23 2月, 2013 1 次提交
  24. 22 2月, 2013 1 次提交
  25. 10 1月, 2013 1 次提交
  26. 04 1月, 2013 1 次提交
    • 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
  27. 11 12月, 2012 1 次提交
  28. 29 11月, 2012 1 次提交
  29. 30 10月, 2012 1 次提交
  30. 13 9月, 2012 1 次提交
  31. 30 8月, 2012 1 次提交
  32. 14 5月, 2012 1 次提交
  33. 04 5月, 2012 1 次提交
  34. 29 4月, 2012 1 次提交
  35. 26 1月, 2012 1 次提交
  36. 18 1月, 2012 1 次提交
  37. 07 1月, 2012 1 次提交