Project

General

Profile

Actions

Feature #18331

open

Kernel.#Time

Added by sawa (Tsuyoshi Sawada) over 2 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:106039]

Description

I remember that, once, Matz suggested a new literal notation for date/time, but he later withdrew it. It seems like introducing new syntax at this point is less realistic. But I believe that many people have wanted a simple way to create a date/time object.

I propose Kernel.Time or Kernel#Time, in much of the same way as Kernel.#Integer, Kernel.#Float, Kernel.#Complex and others. It should take a string as the first required argument and some optional keyword arguments.

Time("2021-11-13T21:21:18.027294 +0900") # => 2021-11-13 21:21:18.027294 +0900
Time("2021-11-13 21:21:18.027294 +0900") # => 2021-11-13 21:21:18.027294 +0900
Time("foo", exception: false) # => nil

I leave out the specifics. There should be room for debate.

I wish the features nobu implemented in https://bugs.ruby-lang.org/issues/18033 for Time.new can be carried over to Kernel.#Time.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #18033: Time.new to parse a stringClosedActions
Actions #1

Updated by sawa (Tsuyoshi Sawada) over 2 years ago

  • Description updated (diff)

Updated by sawa (Tsuyoshi Sawada) over 2 years ago

And I just found a Date counterpart https://bugs.ruby-lang.org/issues/13259, and said to myself, "there are people thinking similar things with me", but it happened to be myself.

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0