From: sawadatsuyoshi@... Date: 2017-02-28T02:17:56+00:00 Subject: [ruby-core:79808] [Ruby trunk Feature#13259] Kernel#Date Issue #13259 has been reported by Tsuyoshi Sawada. ---------------------------------------- Feature #13259: Kernel#Date https://bugs.ruby-lang.org/issues/13259 * Author: Tsuyoshi Sawada * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I often see a piece of code like this: ```ruby require "date" begin Date.strptime(some_string, some_format) rescue nil end ``` Since we now have (https://bugs.ruby-lang.org/issues/12732) `Kernel#Integer` with a parameter to avoid raising an error in case of an invalid string, I think that having a counterpart of it in `Date` would be convenient. I propose `Kernel#Date`, which works like `Date.strptime` except that it takes an optional keyword argument, and works as follows: ```ruby Date("2017/02/02", "%Y/%m/%d", exception: nil) # => # Date("foo", exception: nil) # => nil ``` -- https://bugs.ruby-lang.org/ Unsubscribe: