[squeak-dev] Re: The Trunk: Chronology-Tests-pre.4.mcz
marcel.taeumel
Marcel.Taeumel at hpi.de
Thu Aug 18 19:57:29 UTC 2016
Chris Muller-3 wrote
> makeUTC should be deprecated (next release). I added it years ago as
> an external "solution" to the equivalence check, but mutating a value
> object is a hack, and now we need it anymore.
>
>
> On Wed, Aug 17, 2016 at 3:40 AM, <
> commits at .squeak
> > wrote:
>> Patrick Rein uploaded a new version of Chronology-Tests to project The
>> Trunk:
>> http://source.squeak.org/trunk/Chronology-Tests-pre.4.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Chronology-Tests-pre.4
>> Author: pre
>> Time: 17 August 2016, 10:40:34.494232 am
>> UUID: bb438ab5-6837-d74f-9036-cfb85ef62bf7
>> Ancestors: Chronology-Tests-bf.3
>>
>> Updates makeUTC test for Dates to cater for the timezone independent
>> behavior of Date objects. (together with Marcel)
>>
>> =============== Diff against Chronology-Tests-bf.3 ===============
>>
>> Item was changed:
>> ----- Method: DateTest>>testMakeUTC (in category 'testing') -----
>> testMakeUTC
>> + "Equal dates should compare equal regardless of which TimeZone
>> they are created in."
>> +
>> + | priorTz march31stLocal march31stOcean |
>> - "Equal dates should compare equal regardless of which TimeZone
>> - they are created in."
>> - | priorTz march31stLocal march31stOcean |
>> - "This test won't work in GMT-9, but nobody lives there."
>> - self deny: DateAndTime localTimeZone offset hours = -9.
>> priorTz := DateAndTime localTimeZone.
>> +
>> + [DateAndTime
>> + localTimeZone: (TimeZone
>> + offset: 9 hours
>> + name: 'Early Test Countries'
>> + abbreviation: 'Test Ocean Early').
>> +
>> + march31stLocal := Date year: 2016 month: 3 day: 31.
>> + march31stLocal start: (march31stLocal start offset: DateAndTime
>> localTimeZone offset).
>> +
>> - march31stLocal := Date today.
>> DateAndTime
>> localTimeZone: (TimeZone
>> + offset: -9 hours
>> + name: 'Late Test Countries'
>> + abbreviation: 'Test Ocean Late').
>> +
>> + march31stOcean := Date year: 2016 month: 3 day: 31.
>> + march31stOcean start: (march31stOcean start offset: DateAndTime
>> localTimeZone offset).]
>> + ensure: [DateAndTime localTimeZone: priorTz].
>> +
>> + self
>> + deny: march31stLocal = march31stOcean;
>> + assert: march31stOcean > march31stLocal.
>> +
>> + self
>> + assert: march31stLocal makeUTC = march31stOcean makeUTC;
>> + deny: march31stOcean makeUTC > march31stLocal makeUTC;
>> + deny: march31stOcean makeUTC < march31stLocal makeUTC.!
>> - offset: -9 hours
>> - name: 'No Countries'
>> - abbreviation: 'Ocean').
>> - march31stOcean := Date today.
>> - DateAndTime localTimeZone: priorTz.
>> - self assert: march31stLocal makeUTC = march31stOcean makeUTC ;
>> - deny: march31stOcean makeUTC > march31stLocal makeUTC ;
>> - deny: march31stOcean makeUTC < march31stLocal makeUTC!
>>
>>
Hmm... instead of deprecating #makeUTC, we should make adding a time zone
offset to a date instance much easier than:
march31stLocal := Date year: 2016 month: 3 day: 31.
march31stLocal start: (march31stLocal start offset: DateAndTime
localTimeZone offset).
Then, #makeUTC could be the inverse operation for that. Then, if you ever
need to work with "time-zoned dates", you can do it easily.
Best,
Marcel
--
View this message in context: http://forum.world.st/The-Trunk-Chronology-Tests-pre-4-mcz-tp4911472p4911795.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.
More information about the Squeak-dev
mailing list
|