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-Status: No, score=-1.8 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 F246E1F5AE for ; Wed, 22 Jul 2020 19:15:43 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BAA83120B1B; Thu, 23 Jul 2020 04:15:09 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id CD245120B0D for ; Thu, 23 Jul 2020 04:15:06 +0900 (JST) Received: by filterdrecv-p3iad2-5b55dcd864-m99xc with SMTP id filterdrecv-p3iad2-5b55dcd864-m99xc-18-5F189050-179 2020-07-22 19:15:28.815268657 +0000 UTC m=+2253963.420216879 Received: from herokuapp.com (unknown) by ismtpd0033p1iad2.sendgrid.net (SG) with ESMTP id CsrkjpyiTuSGCqe7EZ2rSw for ; Wed, 22 Jul 2020 19:15:28.771 +0000 (UTC) Date: Wed, 22 Jul 2020 19:15:28 +0000 (UTC) From: gamelinks007@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75067 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17042 X-Redmine-Issue-Author: timcraft X-Redmine-Sender: S_H_ 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-SG-EID: =?us-ascii?Q?hkhH+VYi3CHo0H3puLbdQ20XoWHmZIf5UShlDYZVe94cS=2FafCEzTQEXkno3L1V?= =?us-ascii?Q?foV5AlU3UMQwzGX6VGc88TXNJwClG5IxQTAnlaN?= =?us-ascii?Q?XGhXeB9i=2FJpZfT2=2F9UoYZDdlasWr9opsYuiz3fh?= =?us-ascii?Q?X+HzpDl8p3po1HRY1OhHksmrJeNd21LyoOgf5HY?= =?us-ascii?Q?ZoAVv+aOc9NcY2FBsDqI67udePDIL02+qaZRoV9?= =?us-ascii?Q?uJaw+Gm6=2FEDyAqU8Q=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99278 Subject: [ruby-core:99278] [Ruby master Bug#17042] Times with timezones return incorrect week numbers 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 #17042 has been updated by S_H_ (Shun Hiraoka). This code resolve this behaviour. ```c static VALUE time_strftime(VALUE time, VALUE format) { struct time_object *tobj; const char *fmt; long len; rb_encoding *enc; VALUE tmp; GetTimeval(time, tobj); if (tobj->vtm.yday == 0) { VALUE zone = tobj->vtm.zone; if (!NIL_P(zone)) zone_localtime(zone, time); } MAKE_TM(time, tobj); StringValue(format); if (!rb_enc_str_asciicompat_p(format)) { rb_raise(rb_eArgError, "format should have ASCII compatible encoding"); } tmp = rb_str_tmp_frozen_acquire(format); fmt = RSTRING_PTR(tmp); len = RSTRING_LEN(tmp); enc = rb_enc_get(format); if (len == 0) { rb_warning("strftime called with empty format string"); return rb_enc_str_new(0, 0, enc); } else { VALUE str = rb_strftime_alloc(fmt, len, enc, time, &tobj->vtm, tobj->timew, TZMODE_UTC_P(tobj)); rb_str_tmp_frozen_release(format, tmp); if (!str) rb_raise(rb_eArgError, "invalid format: %"PRIsVALUE, format); return str; } } ``` `tobj->vtm.yday`is seems to be 0. So, these code resolve. ```c if (tobj->vtm.yday == 0) { VALUE zone = tobj->vtm.zone; if (!NIL_P(zone)) zone_localtime(zone, time); } ``` ---------------------------------------- Bug #17042: Times with timezones return incorrect week numbers https://bugs.ruby-lang.org/issues/17042#change-86666 * Author: timcraft (Tim Craft) * Status: Open * Priority: Normal * ruby -v: ruby 2.8.0dev (2020-07-15 master 79d06483a8) * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Times with timezones return incorrect week numbers from strftime. For example: $ irb -r tzinfo irb(main):001:0> Time.utc(2020, 7, 22, 12, 0, 0).strftime('%U %V %W') => "29 30 29" irb(main):002:0> Time.new(2020, 7, 22, 12, 0, 0, TZInfo::Timezone.get('America/New_York')).strftime('%U %V %W') => "00 00 00" Follow up to #17024 -- https://bugs.ruby-lang.org/