Project

General

Profile

Actions

Feature #17485

closed

Keyword argument for timezone in Time.new

Added by nobu (Nobuyoshi Nakada) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:101780]

Description

Currently, Time.at and Time.now accept a timezone as a keyword argument, but not Time.new.
This means minor arguments cannot be omitted for Time.new.

Time.new(2021, 1, 1, 0, 0, 0, "+09:00") #=> ok: 2021-01-01 00:00:00 +0900
Time.new(2021, 1, 1, "+09:00")          #=> bad: 2021-01-01 09:00:00 +0900
Time.new(2021, 1, "+09:00")             #=> bad: 2021-01-09 00:00:00 +0900
Time.new(2021, "+09:00")                #=> ArgumentError (mon out of range)

Suggest that Time.new should also accept the in: timezone option.

Time.new(2021, 1, 1, in: "+09:00") #=> ok: 2021-01-01 00:00:00 +0900
Time.new(2021, in: "+09:00")       #=> ok: 2021-01-01 00:00:00 +0900

https://github.com/ruby/ruby/pull/4010


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #17504: Allow UTC offset without colons per ISO-8601ClosedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Description updated (diff)
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Related to Bug #17504: Allow UTC offset without colons per ISO-8601 added

Updated by akr (Akira Tanaka) about 3 years ago

I think Time.new(2021, 1, 1, "+09:99") should raise an error instead of 2021-01-01 09:00:00 +0900.

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|4b15caee8fe7a5aaa52ed5a3ab2a3517c9206fd7.


Added in: timezone option to Time.new [Feature #17485]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0