DateAndTime>>asTime

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

DateAndTime>>asTime

dmacq
In Pharo V2, if I execute this snippet:

| x |
x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
x asTime inspect

I get '12:0-54:0-53 am' which is not what I expect.

DateAndTime>>asTime changed from 1.4 to 2.0.

Any ideas?

Thanks

Donald [|]

Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Camillo Bruni-3

On 2013-06-06, at 00:41, dmacq <[hidden email]> wrote:

> In Pharo V2, if I execute this snippet:
>
> | x |
> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> x asTime inspect
>
> I get '12:0-54:0-53 am' which is not what I expect.

- where did you get this string from? that looks very strange.
If I do what you describe in a fresh 2.0 Image I get '8:05:07 pm' as expected.
- Just to be sure, which exact Pharo version are you using (print SystemVersion current)?

> DateAndTime>>asTime changed from 1.4 to 2.0.

yes, the internals of DateAndTime are now in UTC and no longer local time.

> Any ideas?

Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

dmacq
SystemVersion current ---> Pharo2.0 of 7 March 2013 update 20596

The string is from the inspector window.

I get the same thing in a fresh image.
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Camillo Bruni-3
it keeps on being strange ;), another try, what is your time zone?

TimeZone local inspect
TimeZone local offset inspect


On 2013-06-06, at 01:14, dmacq <[hidden email]> wrote:

> SystemVersion current ---> Pharo2.0 of 7 March 2013 update 20596
>
> The string is from the inspector window.
>
> I get the same thing in a fresh image.
>
>
>
> --
> View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691873.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

dmacq

TimeZone local inspect ----> a TimeZone(LT-4:00)
TimeZone local offset inspect -----> aDuration -0:04:00:00
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Camillo Bruni-3

On 2013-06-06, at 02:53, dmacq <[hidden email]> wrote:
> TimeZone local inspect ----> a TimeZone(LT-4:00)
> TimeZone local offset inspect -----> aDuration -0:04:00:00

that seems normal. can you upload your image somewhere (dropbox) and have an inspector open on the strange DateAndTime instance?

and another try, does the following look normal?

DateAndTime now asTime inspect
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

dmacq
DateAndTime now asTime inspect -----> 8:58:38.218 pm which is correct.

THis is from a virgin image (no package imports) created by unzipping the Windows download.

I will try a different DateAndTime instance creation method tomorrow and let you know.

This is strange. Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Yanni Chiu
On 05/06/13 9:02 PM, dmacq wrote:
> DateAndTime now asTime inspect -----> 8:58:38.218 pm which is correct.
>
> THis is from a virgin image (no package imports) created by unzipping the
> Windows download.
>
> I will try a different DateAndTime instance creation method tomorrow and let
> you know.
>
> This is strange. Thanks.

Try it again in the morning! I think it's related to time zones. If, in
your local time, it is not yet midnight, but it's already the next day
at GMT, then you get a negative "something" (can't remember what).

I've seen the '-' (negative integer) show up in the time printString
result. I think I fixed it by printing the hours/minutes/seconds with a
custom print method.

Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

dmacq
I tried it again this morning and still had the problem.

This is interesting.

| x y |
x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
x = y  <------------------ True

But
| x y |
x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
x asTime = y asTime <------------- False
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Camillo Bruni-3
can you save an image with the inspector opened on both x and y, x asTime and y asTime
and provide a link to it? like that I can inspect it in all detail...

On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:

> I tried it again this morning and still had the problem.
>
> This is interesting.
>
> | x y |
> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> x = y  <------------------ True
>
> But
> | x y |
> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> x asTime = y asTime <------------- False
>
>
>
> --
> View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

José Comesaña
Hello everybody. 

I would like to add a new improvement to this thread.

I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.". 

But this seems to be incorrect: if you evaluate 

Date readFrom: '07/06/13' readStream pattern: 'd/m/y'

you get:

 7 June 0013     instead of  7 June 2013.

I am working with version #20605

Thank you all for your great work.

Regards.


2013/6/6 Camillo Bruni <[hidden email]>
can you save an image with the inspector opened on both x and y, x asTime and y asTime
and provide a link to it? like that I can inspect it in all detail...

On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:

> I tried it again this morning and still had the problem.
>
> This is interesting.
>
> | x y |
> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> x = y  <------------------ True
>
> But
> | x y |
> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> x asTime = y asTime <------------- False
>
>
>
> --
> View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>



Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Sven Van Caekenberghe-2
Hi José,

On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:

> Hello everybody.
>
> I would like to add a new improvement to this thread.
>
> I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
>
> But this seems to be incorrect: if you evaluate
>
> Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
>
> you get:
>
>  7 June 0013     instead of  7 June 2013.
>
> I am working with version #20605

The fix would be quite easy:

  year := (inputStream next: 2) asInteger

should be

  year := 2000 + (inputStream next: 2) asInteger

A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.

Sven

> Thank you all for your great work.
>
> Regards.
>
>
> 2013/6/6 Camillo Bruni <[hidden email]>
> can you save an image with the inspector opened on both x and y, x asTime and y asTime
> and provide a link to it? like that I can inspect it in all detail...
>
> On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
>
> > I tried it again this morning and still had the problem.
> >
> > This is interesting.
> >
> > | x y |
> > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > x = y  <------------------ True
> >
> > But
> > | x y |
> > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > x asTime = y asTime <------------- False
> >
> >
> >
> > --
> > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

José Comesaña
Thank you Sven.

I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.

Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.

I could write the tests you suggest, if you think they are interesting. 

Regards

2013/6/7 Sven Van Caekenberghe <[hidden email]>
Hi José,

On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:

> Hello everybody.
>
> I would like to add a new improvement to this thread.
>
> I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
>
> But this seems to be incorrect: if you evaluate
>
> Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
>
> you get:
>
>  7 June 0013     instead of  7 June 2013.
>
> I am working with version #20605

The fix would be quite easy:

  year := (inputStream next: 2) asInteger

should be

  year := 2000 + (inputStream next: 2) asInteger

A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.

Sven

> Thank you all for your great work.
>
> Regards.
>
>
> 2013/6/6 Camillo Bruni <[hidden email]>
> can you save an image with the inspector opened on both x and y, x asTime and y asTime
> and provide a link to it? like that I can inspect it in all detail...
>
> On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
>
> > I tried it again this morning and still had the problem.
> >
> > This is interesting.
> >
> > | x y |
> > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > x = y  <------------------ True
> >
> > But
> > | x y |
> > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > x asTime = y asTime <------------- False
> >
> >
> >
> > --
> > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

dmacq
In reply to this post by Camillo Bruni-3
On 6/6/2013 2:14 PM, Camillo Bruni wrote:
> can you save an image with the inspector opened on both x and y, x asTime and y asTime
> and provide a link to it? like that I can inspect it in all detail...

yes. probably tomorrow.

please ping me if I forget.

thanks

>
> On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
>
>> I tried it again this morning and still had the problem.
>>
>> This is interesting.
>>
>> | x y |
>> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
>> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
>> x = y  <------------------ True
>>
>> But
>> | x y |
>> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
>> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
>> x asTime = y asTime <------------- False
>>
>>
>>
>> --
>> View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>


--
Donald [|]

A bad day in [] is better than a good day in {}


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Sven Van Caekenberghe-2
In reply to this post by José Comesaña

On 07 Jun 2013, at 13:26, José Comesaña <[hidden email]> wrote:

> Thank you Sven.
>
> I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.
>
> Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.

Depends on what a single y means, right ?

> I could write the tests you suggest, if you think they are interesting.

Yes, please do: with a good set of tests, we can discuss using concrete examples.

> Regards
>
> 2013/6/7 Sven Van Caekenberghe <[hidden email]>
> Hi José,
>
> On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:
>
> > Hello everybody.
> >
> > I would like to add a new improvement to this thread.
> >
> > I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
> >
> > But this seems to be incorrect: if you evaluate
> >
> > Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
> >
> > you get:
> >
> >  7 June 0013     instead of  7 June 2013.
> >
> > I am working with version #20605
>
> The fix would be quite easy:
>
>   year := (inputStream next: 2) asInteger
>
> should be
>
>   year := 2000 + (inputStream next: 2) asInteger
>
> A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.
>
> Sven
>
> > Thank you all for your great work.
> >
> > Regards.
> >
> >
> > 2013/6/6 Camillo Bruni <[hidden email]>
> > can you save an image with the inspector opened on both x and y, x asTime and y asTime
> > and provide a link to it? like that I can inspect it in all detail...
> >
> > On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
> >
> > > I tried it again this morning and still had the problem.
> > >
> > > This is interesting.
> > >
> > > | x y |
> > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > x = y  <------------------ True
> > >
> > > But
> > > | x y |
> > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > x asTime = y asTime <------------- False
> > >
> > >
> > >
> > > --
> > > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> > >
> >
> >
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

José Comesaña
Answers in red.

Regards

2013/6/7 Sven Van Caekenberghe <[hidden email]>

On 07 Jun 2013, at 13:26, José Comesaña <[hidden email]> wrote:

> Thank you Sven.
>
> I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.
>
> Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.

Depends on what a single y means, right ?

According  to documentation, one y means ...year, no matter how many digits supplied... (my own words, not litteral).  It means it will either accept ../../13 or ../../2013

> I could write the tests you suggest, if you think they are interesting.

Yes, please do: with a good set of tests, we can discuss using concrete examples.


Sure I will. Will keep you informed!
 
> Regards
>
> 2013/6/7 Sven Van Caekenberghe <[hidden email]>
> Hi José,
>
> On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:
>
> > Hello everybody.
> >
> > I would like to add a new improvement to this thread.
> >
> > I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
> >
> > But this seems to be incorrect: if you evaluate
> >
> > Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
> >
> > you get:
> >
> >  7 June 0013     instead of  7 June 2013.
> >
> > I am working with version #20605
>
> The fix would be quite easy:
>
>   year := (inputStream next: 2) asInteger
>
> should be
>
>   year := 2000 + (inputStream next: 2) asInteger
>
> A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.
>
> Sven
>
> > Thank you all for your great work.
> >
> > Regards.
> >
> >
> > 2013/6/6 Camillo Bruni <[hidden email]>
> > can you save an image with the inspector opened on both x and y, x asTime and y asTime
> > and provide a link to it? like that I can inspect it in all detail...
> >
> > On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
> >
> > > I tried it again this morning and still had the problem.
> > >
> > > This is interesting.
> > >
> > > | x y |
> > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > x = y  <------------------ True
> > >
> > > But
> > > | x y |
> > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > x asTime = y asTime <------------- False
> > >
> > >
> > >
> > > --
> > > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> > >
> >
> >
> >
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Sven Van Caekenberghe-2

On 07 Jun 2013, at 14:28, José Comesaña <[hidden email]> wrote:

> Answers in red.
>
> Regards
>
> 2013/6/7 Sven Van Caekenberghe <[hidden email]>
>
> On 07 Jun 2013, at 13:26, José Comesaña <[hidden email]> wrote:
>
> > Thank you Sven.
> >
> > I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.
> >
> > Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.
>
> Depends on what a single y means, right ?
>
> According  to documentation, one y means ...year, no matter how many digits supplied... (my own words, not litteral).  It means it will either accept ../../13 or ../../2013

Yes, that is how I understood it as well. My change adds 2000 only in the case of 2 y's unless I am mistaken. But I must admin I didn't test it.

> > I could write the tests you suggest, if you think they are interesting.
>
> Yes, please do: with a good set of tests, we can discuss using concrete examples.
>
>
> Sure I will. Will keep you informed!

Super.

> > Regards
> >
> > 2013/6/7 Sven Van Caekenberghe <[hidden email]>
> > Hi José,
> >
> > On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:
> >
> > > Hello everybody.
> > >
> > > I would like to add a new improvement to this thread.
> > >
> > > I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
> > >
> > > But this seems to be incorrect: if you evaluate
> > >
> > > Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
> > >
> > > you get:
> > >
> > >  7 June 0013     instead of  7 June 2013.
> > >
> > > I am working with version #20605
> >
> > The fix would be quite easy:
> >
> >   year := (inputStream next: 2) asInteger
> >
> > should be
> >
> >   year := 2000 + (inputStream next: 2) asInteger
> >
> > A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.
> >
> > Sven
> >
> > > Thank you all for your great work.
> > >
> > > Regards.
> > >
> > >
> > > 2013/6/6 Camillo Bruni <[hidden email]>
> > > can you save an image with the inspector opened on both x and y, x asTime and y asTime
> > > and provide a link to it? like that I can inspect it in all detail...
> > >
> > > On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
> > >
> > > > I tried it again this morning and still had the problem.
> > > >
> > > > This is interesting.
> > > >
> > > > | x y |
> > > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > > x = y  <------------------ True
> > > >
> > > > But
> > > > | x y |
> > > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > > x asTime = y asTime <------------- False
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > > > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Stéphane Ducasse
In reply to this post by Sven Van Caekenberghe-2
can you open a bug entry and publish a slice so that we do not fix it.

Stef

On Jun 7, 2013, at 12:36 PM, Sven Van Caekenberghe <[hidden email]> wrote:

> Hi José,
>
> On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:
>
>> Hello everybody.
>>
>> I would like to add a new improvement to this thread.
>>
>> I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
>>
>> But this seems to be incorrect: if you evaluate
>>
>> Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
>>
>> you get:
>>
>> 7 June 0013     instead of  7 June 2013.
>>
>> I am working with version #20605
>
> The fix would be quite easy:
>
>  year := (inputStream next: 2) asInteger
>
> should be
>
>  year := 2000 + (inputStream next: 2) asInteger
>
> A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.
>
> Sven
>
>> Thank you all for your great work.
>>
>> Regards.
>>
>>
>> 2013/6/6 Camillo Bruni <[hidden email]>
>> can you save an image with the inspector opened on both x and y, x asTime and y asTime
>> and provide a link to it? like that I can inspect it in all detail...
>>
>> On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
>>
>>> I tried it again this morning and still had the problem.
>>>
>>> This is interesting.
>>>
>>> | x y |
>>> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
>>> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
>>> x = y  <------------------ True
>>>
>>> But
>>> | x y |
>>> x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
>>> y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
>>> x asTime = y asTime <------------- False
>>>
>>>
>>>
>>> --
>>> View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
>>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

Stéphane Ducasse
In reply to this post by Sven Van Caekenberghe-2
>>
>>
>> I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.
>>
>> Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.
>
> Depends on what a single y means, right ?
>
>> I could write the tests you suggest, if you think they are interesting.
>
> Yes, please do: with a good set of tests, we can discuss using concrete examples.

Please :)
We love tests!
Reply | Threaded
Open this post in threaded view
|

Re: DateAndTime>>asTime

José Comesaña
In reply to this post by Sven Van Caekenberghe-2
Hi again.

I have one first test for #readFrom:pattern:. What can I do now to send it, where, to whom?.

Regards

2013/6/7 Sven Van Caekenberghe <[hidden email]>

On 07 Jun 2013, at 14:28, José Comesaña <[hidden email]> wrote:

> Answers in red.
>
> Regards
>
> 2013/6/7 Sven Van Caekenberghe <[hidden email]>
>
> On 07 Jun 2013, at 13:26, José Comesaña <[hidden email]> wrote:
>
> > Thank you Sven.
> >
> > I had made the fixes myself, creating a new class for dates (I don't need the complexity of Date just for determining if a date is past, I don't need date arithmetic either). I just wanted to inform, mainly because the bug seems to be still present in Pharo 3.0.
> >
> > Anyway, your solution does not work for the 'd/m/y' pattern, although it does for 'd/m/yy'.
>
> Depends on what a single y means, right ?
>
> According  to documentation, one y means ...year, no matter how many digits supplied... (my own words, not litteral).  It means it will either accept ../../13 or ../../2013

Yes, that is how I understood it as well. My change adds 2000 only in the case of 2 y's unless I am mistaken. But I must admin I didn't test it.

> > I could write the tests you suggest, if you think they are interesting.
>
> Yes, please do: with a good set of tests, we can discuss using concrete examples.
>
>
> Sure I will. Will keep you informed!

Super.

> > Regards
> >
> > 2013/6/7 Sven Van Caekenberghe <[hidden email]>
> > Hi José,
> >
> > On 07 Jun 2013, at 12:02, José Comesaña <[hidden email]> wrote:
> >
> > > Hello everybody.
> > >
> > > I would like to add a new improvement to this thread.
> > >
> > > I have noticed that Date class has a bug, or at least something to improve in readFrom:pattern: method. The initial comment states that "A year given using only two decimals is considered to be >2000.".
> > >
> > > But this seems to be incorrect: if you evaluate
> > >
> > > Date readFrom: '07/06/13' readStream pattern: 'd/m/y'
> > >
> > > you get:
> > >
> > >  7 June 0013     instead of  7 June 2013.
> > >
> > > I am working with version #20605
> >
> > The fix would be quite easy:
> >
> >   year := (inputStream next: 2) asInteger
> >
> > should be
> >
> >   year := 2000 + (inputStream next: 2) asInteger
> >
> > A more important problem is that there are no users of #readFrom:pattern: in the system, not even unit tests. If we want to keep the methods, someone should start by writing a couple of unit tests.
> >
> > Sven
> >
> > > Thank you all for your great work.
> > >
> > > Regards.
> > >
> > >
> > > 2013/6/6 Camillo Bruni <[hidden email]>
> > > can you save an image with the inspector opened on both x and y, x asTime and y asTime
> > > and provide a link to it? like that I can inspect it in all detail...
> > >
> > > On 2013-06-06, at 17:51, dmacq <[hidden email]> wrote:
> > >
> > > > I tried it again this morning and still had the problem.
> > > >
> > > > This is interesting.
> > > >
> > > > | x y |
> > > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > > x = y  <------------------ True
> > > >
> > > > But
> > > > | x y |
> > > > x := DateAndTime year: 1991 day: 196 hour: 20 minute: 5 second: 7.
> > > > y := DateAndTime year: 1991 month: 7 day: 15 hour: 20 minute: 5 second: 7.
> > > > x asTime = y asTime <------------- False
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context: http://forum.world.st/DateAndTime-asTime-tp4691870p4691988.html
> > > > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>



12