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: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 186FB1F66E for ; Thu, 16 Jun 2022 16:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1655396038; bh=nPIOTaWjanpzAIhC7wLOwwgpFfC/FXT7EHyWPnkikMk=; h=From:To:Subject:Date:From; b=v20ElFQFP+wX85i8joVwIUHVpUSRlqXczGlfRvkfncm5538zUYJYVZ2LhY+6QoCBq DfTHTyVNk7ZiRnxzE7/zv/LXoDZC3MaTxsQJm3s2+RzGfo/ue7Mk8TPe6qUSip0HXJ ENznXQ9v0vrxFkSEP0gXhuJQ6TczxysoV4wE8Hm8= From: Eric Wong To: clogger-public@yhbt.net Subject: [PATCH] pure: fix time.rb incompatibility in Ruby 3.1+ Date: Thu, 16 Jun 2022 16:13:58 +0000 Message-Id: <20220616161358.29618-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The time.rb distributed with Ruby 3.1+ no longer has the RFC2822_MONTH_NAME constant, as Time#strftime in Ruby is locale-independent (unlike strftime(3) in C). This doesn't affect the default C extension, it only affects the pure Ruby code used for Ruby implementations without C extension support. cf. ruby.git commit 5307fab6619e26e05d791d68c35ceef2e923e8d5 --- lib/clogger/pure.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb index 7f82992..4b38e90 100644 --- a/lib/clogger/pure.rb +++ b/lib/clogger/pure.rb @@ -133,17 +133,10 @@ private when :time_iso8601 Time.now.iso8601 when :time_local - t = Time.now - off = t.utc_offset - sign = off < 0 ? '-' : '+' - sprintf("%02d/%s/%d:%02d:%02d:%02d #{sign}%02d%02d", - t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1], - t.year, t.hour, t.min, t.sec, *(off.abs / 60).divmod(60)) + # %b in Ruby is locale-independent, unlike strftime(3) in C + Time.now.strftime('%d/%b/%Y:%H:%M:%S %z') when :time_utc - t = Time.now.utc - sprintf("%02d/%s/%d:%02d:%02d:%02d +0000", - t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1], - t.year, t.hour, t.min, t.sec) + Time.now.utc.strftime('%d/%b/%Y:%H:%M:%S %z') else raise "EDOOFUS #{special_nr}" end