[DOC] State timezone info in the string wins `in:` keyword

This commit is contained in:
Nobuyoshi Nakada 2023-11-24 19:16:18 +09:00
Родитель 045e74d8e4
Коммит 2ecc372a5d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
2 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -77,6 +77,7 @@ class TestTime < Test::Unit::TestCase
assert_equal(Time.new(2021), Time.new("2021"))
assert_equal(Time.new(2021, 12, 25, in: "+09:00"), Time.new("2021-12-25+09:00"))
assert_equal(Time.new(2021, 12, 25, in: "+09:00"), Time.new("2021-12-25+09:00", in: "-01:00"))
assert_equal(0.123456r, Time.new("2021-12-25 00:00:00.123456 +09:00").subsec)
assert_equal(0.123456789r, Time.new("2021-12-25 00:00:00.123456789876 +09:00").subsec)

Просмотреть файл

@ -380,6 +380,12 @@ class Time
# Time.new(in: '-12:00')
# # => 2022-08-23 08:49:26.1941467 -1200
#
# Since +in:+ keyword argument just provides the default, so if the
# first argument in single string form contains time zone information,
# this keyword argument will be silently ignored.
#
# Time.new('2000-01-01 00:00:00 +0100', in: '-0500').utc_offset # => 3600
#
# - +precision+: maximum effective digits in sub-second part, default is 9.
# More digits will be truncated, as other operations of \Time.
# Ignored unless the first argument is a string.