Christoph Thiede uploaded a new version of Chronology-Core to project The Inbox:
http://source.squeak.org/inbox/Chronology-Core-ct.52.mcz ==================== Summary ==================== Name: Chronology-Core-ct.52 Author: ct Time: 31 January 2020, 11:23:39.214625 am UUID: 34a31242-e22f-ca42-b8d9-e9f2b37fa169 Ancestors: Chronology-Core-mt.51 Extends DateAndTime readFrom: to accept offset strings without colon. For example, java's zzzz format gives you such a string. Test will be added on request. =============== Diff against Chronology-Core-mt.51 =============== Item was changed: ----- Method: DateAndTime class>>readFrom: (in category 'squeak protocol') ----- readFrom: aStream + | yearMonthDay hourMinuteSecondNano offsetSeconds | - | offsetSeconds ch yearMonthDay hourMinuteSecondNano offset | yearMonthDay := Date readYearMonthDayFrom: aStream. [aStream peek isDigit] whileFalse: [aStream next]. hourMinuteSecondNano := Time readHourMinuteSecondNanoFrom: aStream. (aStream atEnd or: [('+-Z' includes: aStream peek) not]) ifTrue: [ self flag: #FIXME. "Different unit tests have conflicting opinions as to whether the current local offset should be used as a default. However, the current local offset cannot be correct due to DST (offset is itself a function of the point in time). Nevertheless, this is a reasonable default considering that the offset would have been explicitly part of the date string if it was a matter of concern. Unit tests will require updates to match this assumption." "offsetSeconds := 0" offsetSeconds := self localOffsetSeconds] ifFalse: [(aStream peekFor: $Z) ifTrue: [offsetSeconds := 0] + ifFalse: [ | ch offsetString offset | - ifFalse: [ ch := aStream next. ch = $+ ifTrue: [ch := Character space]. + offsetString := aStream upToEnd. + (offsetString atLast: 3 ifAbsent: ['']) = $: + ifFalse: [offsetString := (offsetString allButLast: 2) , ':' , (offsetString last: 2)]. + offset := Duration fromString: ch asString, '0:', offsetString, ':0'. - offset := Duration fromString: ch asString, '0:', aStream upToEnd, ':0'. offsetSeconds := offset asSeconds]]. ^ self year: yearMonthDay first month: yearMonthDay second day: yearMonthDay third hour: hourMinuteSecondNano first minute: hourMinuteSecondNano second second: hourMinuteSecondNano third nanoSecond: hourMinuteSecondNano fourth offsetSeconds: offsetSeconds " '-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 + + ' 1970-01-01T00:00:00.000+0000' asDateAndTime "! |
Free forum by Nabble | Edit this page |