From: "andrykonchin (Andrew Konchin)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110769] [Ruby master Misc#19098] Time#strftime: %z and width
Date: Tue, 15 Nov 2022 15:43:23 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-100112.20221115154322.13553@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19098.20221101174920.13553@ruby-lang.org
Issue #19098 has been updated by andrykonchin (Andrew Konchin).
I have checked on MacOS Monterey and Debian 11 (bullseye) (in Docker, if it matters) and received the same results like mentioned in the description.
----------------------------------------
Misc #19098: Time#strftime: %z and width
https://bugs.ruby-lang.org/issues/19098#change-100112
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
----------------------------------------
It seems `%z` behaves in some surprising way when it is combined with a width - sign `+` is placed at the beginning of the result string:
```ruby
Time.now.strftime("%10z")
=> "+000000200"
Time.now.strftime("%_10z")
=> " +200"
```
It seems a time zone offset is treated as a number. It probably makes sense with default format but it looks strange with `:` separators:
```ruby
Time.now.strftime("%10::z")
# => "+002:00:00"
```
So I would expect that `%z` directive output to be treated as a non-numerical and padded by default with spaces.
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2022-11-15 15:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 17:49 [ruby-core:110574] [Ruby master Bug#19098] Time#strftime: %z and width andrykonchin (Andrew Konchin)
2022-11-02 6:03 ` [ruby-core:110579] [Ruby master Misc#19098] " nobu (Nobuyoshi Nakada)
2022-11-15 15:43 ` andrykonchin (Andrew Konchin) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-100112.20221115154322.13553@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=ruby-core@neon.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).