Bug. Incredible date parsing by String>>asDate

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug. Incredible date parsing by String>>asDate

Denis Kudriashov
Hello.

I found very crappy behaviour:

'01.03.2012' asDate => 3 January 2012
'30.03.2012' asDate => 30 March 2012

As you can see for first line #asDate use first number as month. But for last line It use second number as month.

We should fix or remove such inconsistent behaviour.

We all like to test something inside debugger or browser. Such way I was learn how I can parse date from String. And I saved it immediatelly at my code. But when current date become greater then day 12 my code become broken.
And when I see this there was many nice russian words :))

I open ticket http://code.google.com/p/pharo/issues/detail?id=6884


cbc
Reply | Threaded
Open this post in threaded view
|

Re: Bug. Incredible date parsing by String>>asDate

cbc
you are aware that both of those dates are correct, just in different
parts of the world?  Of course, the first could be 1 March, 2012 just
a easily as 3 January, 2012.

If you make it consistent, which way are you leaning towards?  Maybe
more specific asXXXDate keywords to indicate which one you want?

-Chris

On Sun, Oct 28, 2012 at 10:22 AM, Denis Kudriashov <[hidden email]> wrote:

> Hello.
>
> I found very crappy behaviour:
>
> '01.03.2012' asDate => 3 January 2012
> '30.03.2012' asDate => 30 March 2012
>
> As you can see for first line #asDate use first number as month. But for
> last line It use second number as month.
>
> We should fix or remove such inconsistent behaviour.
>
> We all like to test something inside debugger or browser. Such way I was
> learn how I can parse date from String. And I saved it immediatelly at my
> code. But when current date become greater then day 12 my code become
> broken.
> And when I see this there was many nice russian words :))
>
> I open ticket http://code.google.com/p/pharo/issues/detail?id=6884
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bug. Incredible date parsing by String>>asDate

Denis Kudriashov
Hello

2012/10/29 Chris Cunningham <[hidden email]>
you are aware that both of those dates are correct, just in different
parts of the world?  Of course, the first could be 1 March, 2012 just
a easily as 3 January, 2012.

To me system should not try to be too much clever. It should use concrete strong format to parse date in String>>asDate.
Really who needs such magic behaviour?

How I can learn what format #asDate wants? Simplest way is execute on some example (which I do). And I was try format dd.MM.yyyy for current date 28.10.2012. And then I was use my understanding in my code for parsing date. But for begin of next month my code will broken because "'01.11.2012' asDate" returns 11 january 2012 instead of november which should be consistent to parsing '28.10.2012'.
So to me it is totally crappy behaviour which leads to many trouble
 

If you make it consistent, which way are you leaning towards?  Maybe
more specific asXXXDate keywords to indicate which one you want?

-Chris

I want #asDate uses only strong (default) format for parsing date and throws error when given string not satisfied it.

For explicit parsing date from concrete format I think Camillo Bruni work at stamp port. Very nice library https://github.com/jeremyw/stamp#readme

Best regards,
Denis