The Trunk: Kernel-ar.386.mcz

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

The Trunk: Kernel-ar.386.mcz

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

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

Name: Kernel-ar.386
Author: ar
Time: 2 February 2010, 10:52:47.731 am
UUID: 72d71775-3ee2-bb41-b1db-2a527b7cc25c
Ancestors: Kernel-ar.385, Kernel-ar.381

Merging Date class>>#readFrom:pattern: one more time (got accidentally replaced by a newer version without being merged).

=============== Diff against Kernel-ar.385 ===============

Item was added:
+ ----- Method: Date class>>readFrom:pattern: (in category 'squeak protocol') -----
+ readFrom: inputStream pattern: pattern
+ "Read a Date from the stream based on the pattern which can include the tokens:
+
+ y = A year with 1-n digits
+ yy = A year with 2 digits
+ yyyy = A year with 4 digits
+ m = A month with 1-n digits
+ mm = A month with 2 digits
+ d = A day with 1-n digits
+ dd = A day with 2 digits
+
+ ...and any other Strings inbetween. Representing $y, $m and $d is done using
+ \y, \m and \d and slash itself with \\. Simple example patterns:
+
+ 'yyyy-mm-dd'
+ 'yyyymmdd'
+ 'yy.mm.dd'
+ 'y-m-d'
+
+ A year given using only two decimals is considered to be >2000."
+
+ | day month year patternStream char |
+ patternStream := pattern readStream.
+ [patternStream atEnd] whileFalse: [
+ inputStream atEnd ifTrue: [^nil].
+ char := patternStream next.
+ char = $\
+ ifTrue: [inputStream next = patternStream next ifFalse: [^nil]]
+ ifFalse: [
+ char = $y
+ ifTrue: [
+ (patternStream nextMatchAll: 'yyy')
+ ifTrue: [year := (inputStream next: 4) asInteger]
+ ifFalse: [
+ (patternStream peekFor: $y)
+ ifTrue: [
+ year := (inputStream next: 2) asInteger]
+ ifFalse: [
+ year := Integer readFrom: inputStream]]]
+ ifFalse: [
+ char = $m
+ ifTrue: [
+ (patternStream peekFor: $m)
+ ifTrue: [
+ month := (inputStream next: 2) asInteger]
+ ifFalse: [
+ month := Integer readFrom: inputStream]]
+ ifFalse: [
+ char = $d
+ ifTrue: [
+ (patternStream peekFor: $d)
+ ifTrue: [
+ day := (inputStream next: 2) asInteger]
+ ifFalse: [
+ day := Integer readFrom: inputStream]]
+ ifFalse: [
+ inputStream next = char ifFalse: [^nil]]]]]].
+ (year isNil | month isNil | day isNil) ifTrue: [^nil].
+ ^self year: year month: month day: day!