[#8484] strptime fails to properly parse certain inputs — <noreply@...>

Bugs item #5263, was opened at 2006-08-01 23:14

13 messages 2006/08/02
[#8485] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — Yukihiro Matsumoto <matz@...> 2006/08/02

Hi,

[#8538] Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs — nobu@... 2006/08/06

Hi,

[#8561] sandbox timers & block scopes — why the lucky stiff <ruby-core@...>

Two puzzles I am trying to solve:

28 messages 2006/08/08
[#8624] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

raise ThisDecayingInquisition, "anyone? anyone at all?"

[#8627] Re: sandbox timers & block scopes — MenTaLguY <mental@...> 2006/08/15

On Wed, 2006-08-16 at 00:35 +0900, why the lucky stiff wrote:

[#8628] Re: sandbox timers & block scopes — why the lucky stiff <ruby-core@...> 2006/08/15

On Wed, Aug 16, 2006 at 02:46:30AM +0900, MenTaLguY wrote:

[#8629] Re: sandbox timers & block scopes — "Charles O Nutter" <headius@...> 2006/08/15

On 8/15/06, why the lucky stiff <ruby-core@whytheluckystiff.net> wrote:

[#8690] a ruby-core primer — why the lucky stiff <ruby-core@...>

Hello, all. I've been working on the ruby-core page for the new Ruby site.

21 messages 2006/08/22

Re: [ ruby-Bugs-5263 ] strptime fails to properly parse certain inputs

From: "M. Edward (Ed) Borasky" <znmeb@...>
Date: 2006-08-06 15:28:07 UTC
List: ruby-core #8539
nobu@ruby-lang.org wrote:
> Hi,
>
> At Wed, 2 Aug 2006 17:40:13 +0900,
> Yukihiro Matsumoto wrote in [ruby-core:08485]:
>   
>> |Date.strptime and DateTime.strptime do not properly parse
>> |certain forms of input in which there are no non-numeric
>> |separators between the fields.
>> |
>> |For example, the following code fails:
>> |
>> |Date.strptime("20060401", "%Y%m%d")
>>
>> Just because strptime() %Y parsed 20060401 as a year of 20,060,401
>> (year twenty million sixty thousand four hundred and one a.d.), and
>> did not find month and day.
>>     
>
> How about to accept an optional width?
>   
The name "strptime" is used in other programming languages for this 
functionality. For example, in R, it returns an object of class "POSIXlt".


 > t <- strptime("20060401", format="%Y%m%d")
 > t
[1] "2006-04-01"
 > class(t)
[1] "POSIXt"  "POSIXlt"
 >

$ ruby -ve 'Date.strptime("20060401", "%Y%m%d")'
ruby 1.8.5 (2006-06-22) [i686-linux]
-e:1: undefined method `strptime' for Date:Class (NoMethodError)

So:

1. Where is the "strptime" method to be found?
2. IF you're going to change the behavior of "strptime" (string parse 
time) please come up with a new name or an optional parameter. Don't 
change the behavior of "strptime" itself from what it does in other 
languages (parse a date/time string using a standard list of format 
designators.) The same goes for "strftime" (string format time), it's 
inverse.

In This Thread