Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007197 [Squeak] Kernel minor always 09-21-08 19:20 09-25-08 14:42
Reporter glenpaling View Status public  
Assigned To
Priority normal Resolution open Platform
Status new   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 3.10.2
  Product Build
Summary 0007197: DateAndTime readFrom: Results are About 2 Seconds Early.
Description '2008-08-28' asDateAndTime 2008-08-27T23:59:57.999999995+00:00
'2006-08-28T00:00' asDateAndTime 2006-08-27T23:59:57.999999995+00:00

It should produce 2008-08-28T00:00:00.0000000+00:00. I sampled several dates, all with similar results. I see that the testReadFrom test in the Kernel Tests fail.

I'll have a look at see if I can fix it.
Steps To Reproduce
Additional Information
Attached Files  DateAndTime_readFrom_patch_M7197-nice.1.cs [^] (2,848 bytes) 09-22-08 21:16
 DateAndTime_readFrom_test_M7197-nice.1.cs [^] (1,329 bytes) 09-22-08 22:06
 DateAndTime_readFrom_patch_M7197-nice.2.cs [^] (2,870 bytes) 09-22-08 22:25
 DateAndTime_readFrom_test_M7197-nice.2.cs [^] (1,492 bytes) 09-22-08 22:25

- Relationships

- Notes
(0012682 - 274 - 322 - 322 - 322 - 322 - 322)
nicolas cellier
09-22-08 20:39

I do not confirm this.
In a 3.10.2 basic image, i have a MNU bug because hour isNil.
fixing DataAndTime class>>#readFrom:code with
hour _ (aStream upTo: $:) asInteger ifNil: [0].

I get '2008-08-28' asDateAndTime 2008-08-28T00:00:00+00:00

What image are you using?
 
(0012683 - 286 - 356 - 356 - 473 - 473 - 473)
nicolas cellier
09-22-08 20:47

By the way, this one works:

'2006-08-28T00:00:00.123456789' asDateAndTime.
 2006-08-28T00:00:00.123456789+00:00

But extra picoseconds are just too much:

'2006-08-28T00:00:00.123456789000' asDateAndTime.
 2006-08-28T00:00:01.23456789+00:00

This is somewhat similar to 0006764
 
(0012684 - 297 - 375 - 375 - 375 - 375 - 375)
nicolas cellier
09-22-08 21:09

The picosecond behaviour is tricky:
  nanos _ WriteStream on: buffer.
  blah...
  nanos _ buffer asInteger.

This will fill the 10 characters of buffer, then at 11th, the writeStream will write on a grown buffer copy...

initializing buffer to 9 digits fixes it:
buffer _ '000000000' copy.
 
(0012685 - 247 - 271 - 395 - 395 - 395 - 395)
nicolas cellier
09-22-08 22:18

I added two ifNil: [1] for month and day to be more in line with http://en.wikipedia.org/wiki/ISO_8601 [^]

However, implementation lacks year day, week day, time only and some abbreviations...

And sure we can still fool it with malformed inputs.
 
(0012695 - 701 - 960 - 960 - 960 - 960 - 960)
glenpaling
09-25-08 14:42

I found the problem. I had loaded Didier Besset's Numerical Analysis package from universes. It replaces asInteger with:

asInteger
        "(c) Copyrights Didier BESSET, all rights reserved
         Initial code: 1/6/98 "
    ^self inject: 0
            into: [ :ans :each | (ans * 10) + each digitValue]

It naively assumes that all characters are valid digits. The asDateAndTime also places a plus sign into the conversion buffer. digitValue happily converts $+ to -5.

The original asInteger is coded as ^self asSignedInteger. It works fine when revert it. All Chronology Tests now pass. Hurray for unit tests and Test Runner. A lesson learned for me, I'll run unit test after every package load from now on!
 

- Issue History
Date Modified Username Field Change
09-21-08 19:20 glenpaling New Issue
09-22-08 20:39 nicolas cellier Note Added: 0012682
09-22-08 20:47 nicolas cellier Note Added: 0012683
09-22-08 21:09 nicolas cellier Note Added: 0012684
09-22-08 21:16 nicolas cellier File Added: DateAndTime_readFrom_patch_M7197-nice.1.cs
09-22-08 22:06 nicolas cellier File Added: DateAndTime_readFrom_test_M7197-nice.1.cs
09-22-08 22:18 nicolas cellier Note Added: 0012685
09-22-08 22:25 nicolas cellier File Added: DateAndTime_readFrom_patch_M7197-nice.2.cs
09-22-08 22:25 nicolas cellier File Added: DateAndTime_readFrom_test_M7197-nice.2.cs
09-25-08 14:42 glenpaling Note Added: 0012695


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
57 total queries executed.
36 unique queries executed.
Powered by Mantis Bugtracker