From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 6B4481F8C6 for ; Fri, 9 Jul 2021 08:29:39 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 085FF1209C2; Fri, 9 Jul 2021 17:28:24 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1C15A1209C2 for ; Fri, 9 Jul 2021 17:28:21 +0900 (JST) Received: by filterdrecv-754c6cd859-lp729 with SMTP id filterdrecv-754c6cd859-lp729-1-60E808E8-15 2021-07-09 08:29:28.490172878 +0000 UTC m=+135417.079780571 Received: from herokuapp.com (unknown) by geopod-ismtpd-6-2 (SG) with ESMTP id UOtXBvmvQVGrgkNEzRPWjw for ; Fri, 09 Jul 2021 08:29:28.434 +0000 (UTC) Date: Fri, 09 Jul 2021 08:29:28 +0000 (UTC) From: samuel@oriontransfer.net Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 18033 X-Redmine-Issue-Author: nobu X-Redmine-Sender: ioquatix X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 80688 X-SG-EID: =?us-ascii?Q?cjxb6GWHefMLoR50bkJBcGo6DRiDl=2FNYcMZdY+Wj30QqJcDXPtX88brWC23D5a?= =?us-ascii?Q?VHTD5X8D+Xh2hfeGBOjJELfqL05H5mrnAE7z3fG?= =?us-ascii?Q?B815Z0SYDcWdZeCQFf6+Z4pAPZ16SGRo8VAfzhb?= =?us-ascii?Q?VEhkq2cLNXZxQDeeS+iO6N7wBHtexTCJBrghcSy?= =?us-ascii?Q?8LZVkzCEQTMq5ZbMJ9=2F8pFY5Oc6SewFdzJPEeta?= =?us-ascii?Q?cdEIKTkeH7O86wKCo=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 104562 Subject: [ruby-core:104562] [Ruby master Feature#18033] Time.new to parse a string X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #18033 has been updated by ioquatix (Samuel Williams). > Time.parse often results in unintentional/surprising results. Can we change it so that it doesn't return unintentional/surprising results? I agree clean room implementation is nice. But it `Time.parse` can do unexpected things, a new interface does not fix existing usage so the problem still exists. ---------------------------------------- Feature #18033: Time.new to parse a string https://bugs.ruby-lang.org/issues/18033#change-92842 * 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/