[squeak-dev] The Trunk: Kernel-tfel.236.mcz

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

[squeak-dev] The Trunk: Kernel-tfel.236.mcz

commits-2
Andreas Raab uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-tfel.236.mcz

==================== Summary ====================

Name: Kernel-tfel.236
Author: tfel
Time: 2 September 2009, 11:07 am
UUID: c52f7e22-0347-48b2-b827-77855c248e2d
Ancestors: Kernel-tfel.235

This fixes Bug #0006764 where Duration couldn't deal with trailing spaces properly.

=============== Diff against Kernel-tfel.235 ===============

Item was changed:
  ----- Method: Duration class>>readFrom: (in category 'squeak protocol') -----
  readFrom: aStream
+ "Formatted as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]"
- "Formatted as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]
- To assiste DateAndTime>>#readFrom: SS may be unpadded or absent."
-
- | sign days hours minutes seconds nanos ws ch |
- sign := (aStream peekFor: $-) ifTrue: [-1] ifFalse: [1].
-
- days := (aStream upTo: $:) asInteger sign: sign.
- hours := (aStream upTo: $:) asInteger sign: sign.
- minutes := (aStream upTo: $:) asInteger sign: sign.
 
+ | sign days hours minutes seconds nanos nanosBuffer |
+ sign := (aStream peekFor: $-) ifTrue: [-1] ifFalse: [1].
+ days := (aStream upTo: $:) asInteger sign: sign.
+ hours := (aStream upTo: $:) asInteger sign: sign.
+ minutes := (aStream upTo: $:) asInteger sign: sign.
+ seconds := (aStream upTo: $.) asInteger sign: sign.
+ nanosBuffer := '000000000' copy.
+ nanos := WriteStream on: nanosBuffer.
+ [aStream atEnd not and: [aStream peek isDigit]]
+ whileTrue: [nanos nextPut: aStream next].
+
+ ^ self
+ days: days
+ hours: hours
+ minutes: minutes
+ seconds: seconds
+ nanoSeconds: (nanosBuffer asInteger sign: sign)
- aStream atEnd
- ifTrue: [seconds := 0. nanos := 0]
- ifFalse:
- [ ws := String new writeStream.
- [ch := aStream next. (ch isNil) | (ch = $.)]
- whileFalse: [ ws nextPut: ch ].
- seconds := ws contents asInteger sign: sign.
- ws reset.
- 9 timesRepeat:
- [ ch := aStream next.
- ws nextPut: (ch ifNil: [$0] ifNotNil: [ch]) ].
- nanos := ws contents asInteger sign: sign].
-
- ^ self days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos.
 
  " '0:00:00:00' asDuration
  '0:00:00:00.000000001' asDuration
  '0:00:00:00.999999999' asDuration
  '0:00:00:00.100000000' asDuration
+ '0:00:00:00.001 ' asDuration
- '0:00:00:00.10' asDuration
  '0:00:00:00.1' asDuration
+ '0:00:00:01 ' asDuration
- '0:00:00:01' asDuration
  '0:12:45:45' asDuration
  '1:00:00:00' asDuration
  '365:00:00:00' asDuration
  '-7:09:12:06.10' asDuration
- '+0:01:02' asDuration
  '+0:01:02:3' asDuration
    "!

Item was changed:
  ----- Method: DateAndTime class>>readFrom: (in category 'squeak protocol') -----
  readFrom: aStream
 
  | offset date time ch |
 
  date := Date readFrom: aStream.
  [aStream peek isDigit]
  whileFalse: [aStream next].
  time := Time readFrom: aStream.
  aStream atEnd
  ifTrue: [ offset := self localOffset ]
  ifFalse: [
  ch := aStream next.
  ch = $+ ifTrue: [ch := Character space].
+ offset := Duration fromString: ch asString, '0:', aStream upToEnd, ':0'].
- offset := Duration fromString: ch asString, '0:', aStream upToEnd].
 
  ^ self
  year: date year
  month: date monthIndex
  day: date dayOfMonth
  hour: time hour
  minute: time minute
  second: time second
  nanoSecond: time nanoSecond
  offset: offset
 
 
  " '-1199-01-05T20:33:14.321-05:00' asDateAndTime
  ' 2002-05-16T17:20:45.1+01:01' asDateAndTime
 
  ' 2002-05-16T17:20:45.02+01:01' asDateAndTime
 
  ' 2002-05-16T17:20:45.003+01:01' asDateAndTime
 
  ' 2002-05-16T17:20:45.0004+01:01' asDateAndTime
    ' 2002-05-16T17:20:45.00005' asDateAndTime
  ' 2002-05-16T17:20:45.000006+01:01' asDateAndTime
 
  ' 2002-05-16T17:20:45.0000007+01:01' asDateAndTime
  ' 2002-05-16T17:20:45.00000008-01:01' asDateAndTime  
  ' 2002-05-16T17:20:45.000000009+01:01' asDateAndTime  
  ' 2002-05-16T17:20:45.0000000001+01:01' asDateAndTime  
 
    ' 2002-05-16T17:20' asDateAndTime
  ' 2002-05-16T17:20:45' asDateAndTime
  ' 2002-05-16T17:20:45+01:57' asDateAndTime
    ' 2002-05-16T17:20:45-02:34' asDateAndTime
    ' 2002-05-16T17:20:45+00:00' asDateAndTime
  ' 1997-04-26T01:02:03+01:02:3' asDateAndTime
    "!

Item was changed:
  ----- Method: Time class>>readFrom: (in category 'smalltalk-80') -----
  readFrom: aStream
  "Read a Time from the stream in the form:
  <hour>:<minute>:<second> <am/pm>
 
  <minute>, <second> or <am/pm> may be omitted.  e.g. 1:59:30 pm; 8AM; 15:30"
 
  | hour minute second ampm nanos nanosBuffer |
  hour := Integer readFrom: aStream.
  minute := 0.
  second := 0.
  nanosBuffer := '000000000' copy.
+ nanos := WriteStream on: nanosBuffer.
- nanos := ReadWriteStream on: nanosBuffer.
  (aStream peekFor: $:)
  ifTrue: [
  minute := Integer readFrom: aStream.
  (aStream peekFor: $:)
  ifTrue: [
  second := Integer readFrom: aStream].
  (aStream peekFor: $.)
  ifTrue: [
  [aStream atEnd not and: [aStream peek isDigit]]
  whileTrue: [nanos nextPut: aStream next]]].
  aStream skipSeparators.
  (aStream atEnd not and: [aStream peek isLetter]) ifTrue:
  [ampm := aStream next asLowercase.
 
  (ampm = $p and: [hour < 12]) ifTrue: [hour := hour + 12].
  (ampm = $a and: [hour = 12]) ifTrue: [hour := 0].
 
  (aStream peekFor: $m) ifFalse: [aStream peekFor: $M ]].
  ^ self
  hour: hour
  minute: minute
  second: second
  nanoSecond: nanosBuffer asInteger
 
  "Time readFrom: (ReadStream on: '2:23:09 pm')"!