mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
strftime.c: support unknown offset UTC in RFC 3339 [Feature #17544]
In RFC 3339, -00:00 is used for the time in UTC is known, but the offset to local time is unknown. Support that representation by `-` flag for `z`.
This commit is contained in:
parent
4fc6fb2d12
commit
9ef66ce3fc
Notes:
git
2021-02-16 20:34:47 +09:00
2 changed files with 6 additions and 1 deletions
|
@ -547,7 +547,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
|
|||
else {
|
||||
off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0));
|
||||
}
|
||||
if (off < 0) {
|
||||
if (off < 0 || (off == 0 && (flags & BIT_OF(LEFT)))) {
|
||||
off = -off;
|
||||
sign = -1;
|
||||
}
|
||||
|
|
|
@ -920,6 +920,11 @@ class TestTime < Test::Unit::TestCase
|
|||
assert_equal("+09:00", t.strftime("%:z"))
|
||||
assert_equal("+09:00:01", t.strftime("%::z"))
|
||||
assert_equal("+09:00:01", t.strftime("%:::z"))
|
||||
|
||||
assert_equal("+0000", t2000.strftime("%z"))
|
||||
assert_equal("-0000", t2000.strftime("%-z"))
|
||||
assert_equal("-00:00", t2000.strftime("%-:z"))
|
||||
assert_equal("-00:00:00", t2000.strftime("%-::z"))
|
||||
end
|
||||
|
||||
def test_strftime_padding
|
||||
|
|
Loading…
Add table
Reference in a new issue