Issue #18033 has been updated by Eregon (Benoit Daloze). Like @ioquatix and @byroot I think `Time.new` taking a iso-like String is not a good idea. Also it's technically incompatible (the first argument is always the year for `Time.new` and it even accepts strings): ``` > Time.new "1234-02-03T00:00:00+00:34" => 1234-01-01 00:00:00 +0034 ``` I understand `Time.iso8601 and Time.parse need an extension library, date.` is annoying and not intuitive. How about simply making `Time.iso8601` a core method? > Time.iso8601 can't parse Time#inspect string. One shouldn't parse `inspect` so this should be no problem in practice. We could add `Time#iso8601` though (in core), I think that's much better than `time.to_datetime.iso8601`. ---------------------------------------- Feature #18033: Time.new to parse a string https://bugs.ruby-lang.org/issues/18033#change-94550 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Priority: Normal ---------------------------------------- Make `Time.new` parse `Time#inspect` and ISO-8601 like strings. * `Time.iso8601` and `Time.parse` need an extension library, `date`. * `Time.iso8601` can't parse `Time#inspect` string. * `Time.parse` often results in unintentional/surprising results. * `Time.new` also about 1.9 times faster than `Time.iso8601`. ``` $ ./ruby -rtime -rbenchmark -e ' n = 1000 s = Time.now.iso8601 Benchmark.bm(12) do |x| x.report("Time.iso8601") {n.times{Time.iso8601(s)}} x.report("Time.parse") {n.times{Time.parse(s)}} x.report("Time.new") {n.times{Time.new(s)}} end' user system total real Time.iso8601 0.006919 0.000185 0.007104 ( 0.007091) Time.parse 0.018338 0.000207 0.018545 ( 0.018590) Time.new 0.003671 0.000069 0.003740 ( 0.003741) ``` https://github.com/ruby/ruby/pull/4639 -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>