aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2017-03-03 19:21:08 +0000
committerAndrew White <andrew.white@unboxed.co>2017-03-03 21:53:13 +0000
commitf61062c70f27059375a927caadfee458b7037c20 (patch)
tree92f23481d0b1e29a970d0381e7bd3afae95e488b /activesupport/test/core_ext/time_ext_test.rb
parent4974b1a483774f67fc2ac6595c3f492bad608605 (diff)
downloadrails-f61062c70f27059375a927caadfee458b7037c20.tar.gz
rails-f61062c70f27059375a927caadfee458b7037c20.tar.bz2
rails-f61062c70f27059375a927caadfee458b7037c20.zip
Add `ActiveSupport::TimeZone.rfc3339` parsing method
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
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
0 files changed, 0 insertions, 0 deletions