1. 26 3月, 2017 1 次提交
  2. 23 3月, 2017 2 次提交
  3. 22 3月, 2017 1 次提交
  4. 16 3月, 2017 1 次提交
  5. 15 3月, 2017 1 次提交
    • A
      Remove implicit coercion deprecation of durations · a91ea1d5
      Andrew White 提交于
      In #28204 we deprecated implicit conversion of durations to a
      numeric which represented the number of seconds in the duration
      because of unwanted side effects with calculations on durations
      and dates. This unfortunately had the side effect of forcing a
      explicit cast when configuring third-party libraries like
      expiration in Redis, e.g:
      
          redis.expire("foo", 5.minutes)
      
      To work around this we've removed the deprecation and added a
      private class that wraps the numeric and can perform calculation
      involving durations and ensure that they remain a duration
      irrespective of the order of operations.
      a91ea1d5
  6. 14 3月, 2017 1 次提交
  7. 11 3月, 2017 1 次提交
  8. 07 3月, 2017 3 次提交
  9. 04 3月, 2017 4 次提交
    • A
      Add `rfc3339` aliases to `xmlschema` · f0aeecda
      Andrew White 提交于
      For naming consistency when using the RFC 3339 profile
      of ISO 8601 in applications.
      f0aeecda
    • A
      Add `Time.rfc3339` parsing method · 08e05d4a
      Andrew White 提交于
      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.
      08e05d4a
    • A
      Add `ActiveSupport::TimeZone.rfc3339` parsing method · f61062c7
      Andrew White 提交于
      Previously there was no way to get a RFC 3339 timestamp
      into a specific timezone without either using `parse` or
      chaining methods. The new method allows parsing directly
      into the timezone, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.rfc3339("1999-12-31T14:00:00Z")
          => Fri, 31 Dec 1999 14:00:00 HST -10:00
      
      This new method has stricter semantics than the current
      `parse` method and will raise an `ArgumentError`
      instead of returning nil, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.rfc3339("foobar")
          ArgumentError: invalid date
          >> Time.zone.parse("foobar")
          => nil
      
      It will also raise an `ArgumentError` when either the
      time or offset components are missing, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.rfc3339("1999-12-31")
          ArgumentError: invalid date
          >> Time.zone.rfc3339("1999-12-31T14:00:00")
          ArgumentError: invalid date
      f61062c7
    • A
      Add `ActiveSupport::TimeZone.iso8601` parsing method · 4974b1a4
      Andrew White 提交于
      Previously there was no way to get a ISO 8601 timestamp into a specific
      timezone without either using `parse` or chaining methods. The new method
      allows parsing directly into the timezone, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.iso8601("1999-12-31T14:00:00Z")
          => Fri, 31 Dec 1999 14:00:00 HST -10:00
      
      If the timestamp is a ISO 8601 date (YYYY-MM-DD) then the time is set
      to midnight, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.iso8601("1999-12-31")
          => Fri, 31 Dec 1999 00:00:00 HST -10:00
      
      This new method has stricter semantics than the current `parse` method
      and will raise an `ArgumentError` instead of returning nil, e.g:
      
          >> Time.zone = "Hawaii"
          => "Hawaii"
          >> Time.zone.iso8601("foobar")
          ArgumentError: invalid date
          >> Time.zone.parse("foobar")
          => nil
      4974b1a4
  10. 02 3月, 2017 2 次提交
    • A
      Deprecate implicit coercion of `ActiveSupport::Duration` · 75924c45
      Andrew White 提交于
      Currently `ActiveSupport::Duration` implicitly converts to a seconds
      value when used in a calculation except for the explicit examples of
      addition and subtraction where the duration is the receiver, e.g:
      
          >> 2 * 1.day
          => 172800
      
      This results in lots of confusion especially when using durations
      with dates because adding/subtracting a value from a date treats
      integers as a day and not a second, e.g:
      
          >> Date.today
          => Wed, 01 Mar 2017
          >> Date.today + 2 * 1.day
          => Mon, 10 Apr 2490
      
      To fix this we're implementing `coerce` so that we can provide a
      deprecation warning with the intent of removing the implicit coercion
      in Rails 5.2, e.g:
      
          >> 2 * 1.day
          DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration
          to a Numeric is deprecated and will raise a TypeError in Rails 5.2.
          => 172800
      
      In Rails 5.2 it will raise `TypeError`, e.g:
      
          >> 2 * 1.day
          TypeError: ActiveSupport::Duration can't be coerced into Integer
      
      This is the same behavior as with other types in Ruby, e.g:
      
          >> 2 * "foo"
          TypeError: String can't be coerced into Integer
          >> "foo" * 2
          => "foofoo"
      
      As part of this deprecation add `*` and `/` methods to `AS::Duration`
      so that calculations that keep the duration as the receiver work
      correctly whether the final receiver is a `Date` or `Time`, e.g:
      
          >> Date.today
          => Wed, 01 Mar 2017
          >> Date.today + 1.day * 2
          => Fri, 03 Mar 2017
      
      Fixes #27457.
      75924c45
    • 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
  11. 26 2月, 2017 2 次提交
  12. 25 2月, 2017 5 次提交
  13. 24 2月, 2017 1 次提交
  14. 22 2月, 2017 1 次提交
  15. 21 2月, 2017 1 次提交
  16. 20 2月, 2017 1 次提交
  17. 08 2月, 2017 1 次提交
  18. 07 2月, 2017 2 次提交
  19. 04 2月, 2017 2 次提交
  20. 28 1月, 2017 1 次提交
  21. 17 1月, 2017 1 次提交
  22. 15 1月, 2017 2 次提交
  23. 10 1月, 2017 1 次提交
    • A
      Fix inconsistent results when parsing large durations and constructing durations from code · cb9d0e48
      Andrey Novikov 提交于
          ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true
      
      Duration parsing made independent from any moment of time:
      Fixed length in seconds is assigned to each duration part during parsing.
      
      Changed duration of months and years in seconds to more accurate and logical:
      
       1. The value of 365.2425 days in Gregorian year is more accurate
          as it accounts for every 400th non-leap year.
      
       2. Month's length is bound to year's duration, which makes
          sensible comparisons like `12.months == 1.year` to be `true`
          and nonsensical ones like `30.days == 1.month` to be `false`.
      
      Calculations on times and dates with durations shouldn't be affected as
      duration's numeric value isn't used in calculations, only parts are used.
      
      Methods on `Numeric` like `2.days` now use these predefined durations
      to avoid duplicating of duration constants through the codebase and
      eliminate creation of intermediate durations.
      cb9d0e48
  24. 22 12月, 2016 1 次提交
  25. 13 12月, 2016 1 次提交