[8.5.2] DateAndTime>>#from: is broken

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

[8.5.2] DateAndTime>>#from: is broken

jtuchel

if you display or inspect:

  DateAndTime from: '2012-11-14T13:59:53.62+01:00'

you get:

   2012-11-14T13:59:53.062+01:00

So there is something wrong with the milliseconds. It should be .62 but is .062
BTW: #from: uses a deprecated method

This must have been wrong since at least 2009.

The problem is in the calculation of the value msec:
   msec := stream upToEnd asScaledDecimal asInteger.

this must be something along the lines of:
    msec := (stream upToEnd  abtPadWith: $0  upToLength: 3 onRight: true) asScaledDecimal asInteger.
    msec := msec min: 999.

   
Please add for next possible fix.


Tried it on Win 7 x64

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/olLwZPUWgzAJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
sorry, it is of course the class method #from: not an instance method.

Am Mittwoch, 14. November 2012 14:43:03 UTC+1 schrieb [hidden email]:

if you display or inspect:

  DateAndTime from: '2012-11-14T13:59:53.62+01:00'

you get:

   2012-11-14T13:59:53.062+01:00

So there is something wrong with the milliseconds. It should be .62 but is .062
BTW: #from: uses a deprecated method

This must have been wrong since at least 2009.

The problem is in the calculation of the value msec:
   msec := stream upToEnd asScaledDecimal asInteger.

this must be something along the lines of:
    msec := (stream upToEnd  abtPadWith: $0  upToLength: 3 onRight: true) asScaledDecimal asInteger.
    msec := msec min: 999.

   
Please add for next possible fix.


Tried it on Win 7 x64

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/zlx7kBBOftMJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

Marten Feldtmann-2
In reply to this post by jtuchel
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/-Jds7hyrn38J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
Really?

DateAndTime from: '2012-11-14T13:59:53.62+01:00'

really means
    2012-11-14T13:59:53.062+01:00???

So it is not the reading from a String that is wrong, but just the printOn: - method???
Strange, but if the standard says so, then DateAndTime>>printOn: needs to be fixed.


Joachim




Am Mittwoch, 14. November 2012 15:17:25 UTC+1 schrieb Marten Feldtmann:
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/ldXqYFZA6KsJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
In reply to this post by Marten Feldtmann-2
Okay, I used Pharo as a reference, because I was in the middle of porting STON.

In Pharo if you inspect

DateAndTime readFrom: '2012-11-14T13:59:53.62+01:00' readStream

You get a DateAndTime with these instVars:
seconds:     50393
offset:     0:01:00:00
jdn:     2456246
nanos:     620000000

So we either need to tell Pharo about their misinterpretation of the standard or change the behaviour in VAST or live with the fact that others do it differently.

Joachim


Am Mittwoch, 14. November 2012 15:17:25 UTC+1 schrieb Marten Feldtmann:
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/V7GINBouKiwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
In reply to this post by Marten Feldtmann-2
Reading your message again, I find we're not contradicting each other at all.

0.62 is 620 ms. So if a time is given as 13:59:53.62 , this means there are 620 milliseconds passed since 13:39:59.

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0,062 milliseconds.

So VAST is wrong and I am right ;-) Right?

Joachim

Am Mittwoch, 14. November 2012 15:17:25 UTC+1 schrieb Marten Feldtmann:
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/1ovnXfood0cJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
Sorry this is a typo:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0,062 milliseconds.

I meant:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0.062 seconds.


Joachim

Am Mittwoch, 14. November 2012 15:48:58 UTC+1 schrieb [hidden email]:
Reading your message again, I find we're not contradicting each other at all.

0.62 is 620 ms. So if a time is given as 13:59:53.62 , this means there are 620 milliseconds passed since 13:39:59.

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0,062 milliseconds.

So VAST is wrong and I am right ;-) Right?

Joachim

Am Mittwoch, 14. November 2012 15:17:25 UTC+1 schrieb Marten Feldtmann:
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/4eec4nWAUu8J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

Marten Feldtmann-2
I would guess so ... but interpretation of standards .... it is also allowed to have more than 3 digits as the fractional parts.

But reading your Pharo tests: it seem, that they did it right:

620.000.000 nanoseconds are 620 milliseconds = 0.62 seconds

Marten

Am Mittwoch, 14. November 2012 15:49:57 UTC+1 schrieb [hidden email]:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0.062 seconds.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/RgKc-BUtiDQJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
Marten

DateAndTime in VAST supports only milliseconds, so any number above .999 would add seconds.

So if we both agree that .62 should be 620 milliseconds and Pharo interprets it this way, I'd suggest that my proposed fix be integrated into VAST. Let's see what Instantiations has to say about that.

For now, this little discrepancy means that moving a DateAndTime instance from one Smalltalk to another using STON (or very likely every other mechanism like XML that uses #from: to instantiate a DateAndTime from a String representation) will cause trouble becuase the interpretation of .62 (or any other number that has less than 3 digits after the decimal point) is different (and I think it is wrong).


Joachim


Am Mittwoch, 14. November 2012 16:31:02 UTC+1 schrieb Marten Feldtmann:
I would guess so ... but interpretation of standards .... it is also allowed to have more than 3 digits as the fractional parts.

But reading your Pharo tests: it seem, that they did it right:

620.000.000 nanoseconds are 620 milliseconds = 0.62 seconds

Marten

Am Mittwoch, 14. November 2012 15:49:57 UTC+1 schrieb [hidden email]:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0.062 seconds.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/kJEV2h8fyaUJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

jtuchel
Regarding this:

>DateAndTime in VAST supports only milliseconds, so any number above .999 would add seconds.

VAST is also not able to manage less that 0.001 second in a DateAndTime instance, so if ISO8601 allows any number of digits, my fix doesn't handle values below .001 correctly, that has to be added as well: the msec string may not be longer than 3 digits in VAST or it will lead to an msec value of 0. That's a design decision that somebody from Instantiations needs to make based on the ISO standard.

Joachim

Am Mittwoch, 14. November 2012 17:14:38 UTC+1 schrieb [hidden email]:
Marten

DateAndTime in VAST supports only milliseconds, so any number above .999 would add seconds.

So if we both agree that .62 should be 620 milliseconds and Pharo interprets it this way, I'd suggest that my proposed fix be integrated into VAST. Let's see what Instantiations has to say about that.

For now, this little discrepancy means that moving a DateAndTime instance from one Smalltalk to another using STON (or very likely every other mechanism like XML that uses #from: to instantiate a DateAndTime from a String representation) will cause trouble becuase the interpretation of .62 (or any other number that has less than 3 digits after the decimal point) is different (and I think it is wrong).


Joachim


Am Mittwoch, 14. November 2012 16:31:02 UTC+1 schrieb Marten Feldtmann:
I would guess so ... but interpretation of standards .... it is also allowed to have more than 3 digits as the fractional parts.

But reading your Pharo tests: it seem, that they did it right:

620.000.000 nanoseconds are 620 milliseconds = 0.62 seconds

Marten

Am Mittwoch, 14. November 2012 15:49:57 UTC+1 schrieb [hidden email]:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0.062 seconds.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/9yYhUeI5t84J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

Marten Feldtmann-2
In reply to this post by jtuchel

More Digits - higher precision. Va can throw away the additional digits

Am 14.11.2012 17:14 schrieb "[hidden email]" <[hidden email]>:
Marten

DateAndTime in VAST supports only milliseconds, so any number above .999 would add seconds.

So if we both agree that .62 should be 620 milliseconds and Pharo interprets it this way, I'd suggest that my proposed fix be integrated into VAST. Let's see what Instantiations has to say about that.

For now, this little discrepancy means that moving a DateAndTime instance from one Smalltalk to another using STON (or very likely every other mechanism like XML that uses #from: to instantiate a DateAndTime from a String representation) will cause trouble becuase the interpretation of .62 (or any other number that has less than 3 digits after the decimal point) is different (and I think it is wrong).


Joachim


Am Mittwoch, 14. November 2012 16:31:02 UTC+1 schrieb Marten Feldtmann:
I would guess so ... but interpretation of standards .... it is also allowed to have more than 3 digits as the fractional parts.

But reading your Pharo tests: it seem, that they did it right:

620.000.000 nanoseconds are 620 milliseconds = 0.62 seconds

Marten

Am Mittwoch, 14. November 2012 15:49:57 UTC+1 schrieb [hidden email]:

Which in the end means the calculation in VAST is wrong, because it treats .62 as 0.062 seconds.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/kJEV2h8fyaUJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] DateAndTime>>#from: is broken

John O'Keefe-3
In reply to this post by jtuchel
DateAndTime class from: is broken. DateAndTime printOn: (actually DateAndTime printMilliseconds:on:) is OK.

On Wednesday, November 14, 2012 9:36:30 AM UTC-5, [hidden email] wrote:
Really?

DateAndTime from: '2012-11-14T13:59:53.62+01:00'

really means
    2012-11-14T13:59:53.062+01:00???

So it is not the reading from a String that is wrong, but just the printOn: - method???
Strange, but if the standard says so, then DateAndTime>>printOn: needs to be fixed.


Joachim




Am Mittwoch, 14. November 2012 15:17:25 UTC+1 schrieb Marten Feldtmann:
Joachim, this is an interesting question.

In the ISO 8601 it seems to be said, that ".62" is the decimal fraction of a second:

-> "0.62" -> 620ms (if the next unit is ms)

?????

Marten

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/0J7XKeRWoJIJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.