aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

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

aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

Louis LaBrunda
Hi All,

When milliseconds are involved, it seems DateAndTime>>- is not implemented in a way such that:

aDateAndTime + (aDuration negated) = aDateAndTime - aDuration.

DateAndTime>>- uses Duration>>subtractFromDateAndTime:

that doesn't deal with the milliseconds properly.   Not all the milliseconds get subtracted.

I don't know if I want to go so far as to call this a bug but it is very close.  What does everyone else think?

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

Richard Sargent
Administrator
Bug!

On Tuesday, January 20, 2015 at 10:28:40 AM UTC-8, Louis LaBrunda wrote:
Hi All,

When milliseconds are involved, it seems DateAndTime>>- is not implemented in a way such that:

aDateAndTime + (aDuration negated) = aDateAndTime - aDuration.

DateAndTime>>- uses Duration>>subtractFromDateAndTime:

that doesn't deal with the milliseconds properly.   Not all the milliseconds get subtracted.

I don't know if I want to go so far as to call this a bug but it is very close.  What does everyone else think?

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

dmacq
In reply to this post by Louis LaBrunda
Hi Lou,

Inspecting this code snippet returns true:

| dt dur  |
dt := DateAndTime now.
dur := Duration  hours: 1.
dt + (dur negated) = (dt - dur).


What am I missing?

Donald [|]

On Tuesday, January 20, 2015 at 1:28:40 PM UTC-5, Louis LaBrunda wrote:
Hi All,

When milliseconds are involved, it seems DateAndTime>>- is not implemented in a way such that:

aDateAndTime + (aDuration negated) = aDateAndTime - aDuration.

DateAndTime>>- uses Duration>>subtractFromDateAndTime:

that doesn't deal with the milliseconds properly.   Not all the milliseconds get subtracted.

I don't know if I want to go so far as to call this a bug but it is very close.  What does everyone else think?

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

Wayne Johnston
But change it to this and it fails:
dur := Duration milliseconds: 1.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

Louis LaBrunda
Hi Donald and Wayne,

On Thursday, January 22, 2015 at 7:39:16 AM UTC-5, Wayne Johnston wrote:
But change it to this and it fails:
dur := Duration milliseconds: 1.

Wayne beat me to it. Thanks Wayne.   As I said in my original post, the problems in in the way Duration>>subtractFromDateAndTime: handles/drops the milliseconds.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

dmacq
OK, I have created case 57263.

You guys can take a break anytime you want to. ;-)

Thanks,

Donald [|]

On Thursday, January 22, 2015 at 12:29:29 PM UTC-5, Louis LaBrunda wrote:
Hi Donald and Wayne,

On Thursday, January 22, 2015 at 7:39:16 AM UTC-5, Wayne Johnston wrote:
But change it to this and it fails:
dur := Duration milliseconds: 1.

Wayne beat me to it. Thanks Wayne.   As I said in my original post, the problems in in the way Duration>>subtractFromDateAndTime: handles/drops the milliseconds.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

Louis LaBrunda
Hi Donald,

If I may be so presumptuous as to suggest a solution.  Because DateAndTime>>- can have a DateAndTime as a parameter, the fix needs to be in Duration>>subtractFromDateAndTime:

subtractFromDateAndTime: aDateAndTime
"Answer a <DateAndTime> which represents the UTC time that is
the value of the receiver before @aDateAndTime and whose local
time is the same as @aDateAndTime's."

| dt |

dt := aDateAndTime deepCopy. "do a deepCopy to preserve the timeZone"
dt totalMilliseconds: dt milliseconds - (totalSeconds * MillisecondsPerSecond) - (microseconds // MicrosecondsPerMillisecond).
dt timeZone timeZoneRule: (dt timeZone zoneRuleFor: dt asPointInTime abs).
^dt


Note the changes to the third to last line.

Lou

On Thursday, January 22, 2015 at 6:52:25 PM UTC-5, Donald MacQueen wrote:
OK, I have created case 57263.

You guys can take a break anytime you want to. ;-)

Thanks,

Donald [|]

On Thursday, January 22, 2015 at 12:29:29 PM UTC-5, Louis LaBrunda wrote:
Hi Donald and Wayne,

On Thursday, January 22, 2015 at 7:39:16 AM UTC-5, Wayne Johnston wrote:
But change it to this and it fails:
dur := Duration milliseconds: 1.

Wayne beat me to it. Thanks Wayne.   As I said in my original post, the problems in in the way Duration>>subtractFromDateAndTime: handles/drops the milliseconds.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: aDateAndTime + (aDuration negated) is not equal to aDateAndTime - aDuration

dmacq
Thanks Lou.

Problem reports complete with answers are always welcome!

Donald [|]

On Friday, January 23, 2015 at 10:18:36 AM UTC-5, Louis LaBrunda wrote:
Hi Donald,

If I may be so presumptuous as to suggest a solution.  Because DateAndTime>>- can have a DateAndTime as a parameter, the fix needs to be in Duration>>subtractFromDateAndTime:

subtractFromDateAndTime: aDateAndTime
"Answer a <DateAndTime> which represents the UTC time that is
the value of the receiver before @aDateAndTime and whose local
time is the same as @aDateAndTime's."

| dt |

dt := aDateAndTime deepCopy. "do a deepCopy to preserve the timeZone"
dt totalMilliseconds: dt milliseconds - (totalSeconds * MillisecondsPerSecond) - (microseconds // MicrosecondsPerMillisecond).
dt timeZone timeZoneRule: (dt timeZone zoneRuleFor: dt asPointInTime abs).
^dt


Note the changes to the third to last line.

Lou

On Thursday, January 22, 2015 at 6:52:25 PM UTC-5, Donald MacQueen wrote:
OK, I have created case 57263.

You guys can take a break anytime you want to. ;-)

Thanks,

Donald [|]

On Thursday, January 22, 2015 at 12:29:29 PM UTC-5, Louis LaBrunda wrote:
Hi Donald and Wayne,

On Thursday, January 22, 2015 at 7:39:16 AM UTC-5, Wayne Johnston wrote:
But change it to this and it fails:
dur := Duration milliseconds: 1.

Wayne beat me to it. Thanks Wayne.   As I said in my original post, the problems in in the way Duration>>subtractFromDateAndTime: handles/drops the milliseconds.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.