[squeak-dev] The Trunk: Chronology-Core-dtl.67.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Jul 5 10:08:37 UTC 2021


Thank you for fixing the update stream once again, Marcel! :-)


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 5. Juli 2021 09:22:41
An: squeak-dev
Betreff: Re: [squeak-dev] The Trunk: Chronology-Core-dtl.67.mcz

Hi Dave, hi all!

There was an update issue because a class definition will always be loaded before the updated methods, which meant that "DateAndTime now" stopped working after the classVar InitializeFromPrimitive was removed, which was a problem because it apparently required during code loading.

Using the update map (i.e. Monticello Configuration), I could solve this issue by first changing "DateAndTime class >> now" to not use InitializeFromPrimitive any longer.

So, there is no bigger issue here. Just an unexpected side effect with the MC code loading mechanism.

Best,
Marcel

Am 03.07.2021 23:38:46 schrieb commits at source.squeak.org <commits at source.squeak.org>:

David T. Lewis uploaded a new version of Chronology-Core to project The Trunk:
http://source.squeak.org/trunk/Chronology-Core-dtl.67.mcz

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

Name: Chronology-Core-dtl.67
Author: dtl
Time: 3 July 2021, 5:38:37.488688 pm
UUID: 142336d9-cfb5-476e-ba15-a8daf9aad710
Ancestors: Chronology-Core-dtl.66

Cruft removal. DateAndTime no longer needs to be in the startUp list. The canInitializeFromPrimitive workaround is no longer needed. Do not use the no-argument call to primitiveUtcWithOffset, which works fine but is easier to understand in the image if we always use a single primitive interface.

=============== Diff against Chronology-Core-dtl.66 ===============

Item was changed:
Magnitude subclass: #DateAndTime
instanceVariableNames: 'utcMicroseconds localOffsetSeconds'
+ classVariableNames: 'AutomaticTimezone ClockProvider LocalTimeZone PosixEpochJulianDays'
- classVariableNames: 'AutomaticTimezone ClockProvider InitializeFromPrimitive LocalTimeZone PosixEpochJulianDays'
poolDictionaries: 'ChronologyConstants'
category: 'Chronology-Core'!

!DateAndTime commentStamp: 'dtl 3/12/2016 10:32' prior: 0!
I represent a point in UTC time as defined by ISO 8601. I have zero duration.

My implementation uses variables utcMicroseconds and localOffsetSeconds. This represents time magnitude as elapsed microseconds since the Posix epoch, with localOffsetSeconds representing local offset from UTC. The magnitude is used for comparison and duration calculations, and the local offset is used for displaying this magnitude in the context of a local time zone.

The implementation ignores leap seconds, which are adjustments made to maintain earth rotational clock time in synchronization with elapsed seconds.

DateAndTime class>>now will use #primitiveUtcWithOffset to obtain current time in UTC microseconds with current local offset in seconds. The primitive provides an atomic query for UTC time and local offset as measured by the OS platform. If primitiveUtcWithOffset is not available, the traditional implementation is used, which relies on a primitive for microseconds in the local time zone and derives UTC based on the TimeZone setting.
!

Item was removed:
- ----- Method: DateAndTime class>>canInitializeFromPrimitive (in category 'system startup') -----
- canInitializeFromPrimitive
- "Some implementations of primitiveUtcWithOffset do not support passing the
- DateAndTime instance as a parameter to the primitive."
-
- ^self basicNew initializeFromPrimitive utcMicroseconds notNil!

Item was changed:
----- Method: DateAndTime class>>initialize (in category 'initialize-release') -----
initialize

ClockProvider := Time.
+ PosixEpochJulianDays := 2440588.!
- PosixEpochJulianDays := 2440588.
- InitializeFromPrimitive := self canInitializeFromPrimitive.
- Smalltalk addToStartUpList: self.
- self startUp: true
- !

Item was changed:
----- Method: DateAndTime class>>now (in category 'ansi protocol') -----
now
"Answer time now as reported by #primitiveUtcWithOffset. If the primitive is not
available, answer the Posix epoch GMT."

self automaticTimezone
+ ifTrue: [ ^ self basicNew initializeFromPrimitive ]
- ifTrue: [ InitializeFromPrimitive
- ifTrue: [ ^ self basicNew initializeFromPrimitive ]
- ifFalse: [ | timeArray |
- timeArray := Time posixMicrosecondClockWithOffset.
- ^ self utcMicroseconds: timeArray first offset: timeArray second ] ]
ifFalse: [ | timeArray |
timeArray := Time posixMicrosecondClockWithOffset.
^ self utcMicroseconds: timeArray first offset: self localOffsetSeconds ]
!

Item was removed:
- ----- Method: DateAndTime class>>startUp: (in category 'system startup') -----
- startUp: startingAfresh
- "Set local timezone"
- startingAfresh
- ifTrue: [InitializeFromPrimitive := self canInitializeFromPrimitive.
- Time initialize. "set LastClockTick to 0".
- self now]!

Item was changed:
----- Method: Time class>>posixMicrosecondClockWithOffset (in category 'clock') -----
posixMicrosecondClockWithOffset
"Answer an array with local microseconds since the Posix epoch and the
current seconds offset from GMT in the local time zone."

| array posixUtcValue |
+ array := self primPosixMicrosecondClockWithOffset: (Array new: 2).
- array := self primPosixMicrosecondClockWithOffset.
posixUtcValue := array at: 1.
(self updateTimeZoneCacheAt: posixUtcValue) ifTrue: [ "Time zone may have changed: fetch again."
self primPosixMicrosecondClockWithOffset: array.
posixUtcValue := array at: 1 ].
ClockPolicy caseOf: {
[#acceptPlatformTime] -> [^ array] .
[#monotonicAllowDuplicates] -> [
posixUtcValue > LastClockTick
ifTrue: [LastClockTick := posixUtcValue]
ifFalse: [array at: 1 put: LastClockTick]] .
[#monotonicForceMicrosecondIncrement] -> [
posixUtcValue > LastClockTick
ifTrue: [LastClockTick := posixUtcValue]
ifFalse: [LastClockTick := LastClockTick + 1. "add one microsecond"
array at: 1 put: LastClockTick]] .
[#monotonicForceNanosecondIncrement] -> [
posixUtcValue > LastClockTick
ifTrue: [LastClockTick := posixUtcValue]
ifFalse: [LastClockTick := LastClockTick + (1 / 1000). "add one nanosecond"
array at: 1 put: LastClockTick]]
} otherwise: [].
^array!

Item was removed:
- ----- Method: Time class>>primPosixMicrosecondClockWithOffset (in category 'private') -----
- primPosixMicrosecondClockWithOffset
- "Answer an array with UTC microseconds since the Posix epoch and the
- current seconds offset from GMT in the local time zone. If the primitive is
- not available, then answer the time and offset of Posix epoch GMT. This enables
- the image to continue running in the absence of #primitiveUtcWithOffset, thus
- avoiding the need to fallback code based on the earlier local microsecond clock
- mechanism."
-
-
- ^{0. 0}!

Item was changed:
+ ----- Method: Time class>>primPosixMicrosecondClockWithOffset: (in category 'clock') -----
- ----- Method: Time class>>primPosixMicrosecondClockWithOffset: (in category 'private') -----
primPosixMicrosecondClockWithOffset: arrayOrObjectWithTwoSlots
"Answer an array with UTC microseconds since the Posix epoch and the
current seconds offset from GMT in the local time zone. If the primitive is
not available, then answer the time and offset of Posix epoch GMT. This enables
the image to continue running in the absence of #primitiveUtcWithOffset, thus
avoiding the need to fallback code based on the earlier local microsecond clock
mechanism.

The parameter may be a two element array, or an object whose first two instance
variables are expected to be UTC microseconds and seconds offset from GMT."



(arrayOrObjectWithTwoSlots instVarAt: 1)
ifNil: [arrayOrObjectWithTwoSlots instVarAt: 1 put: 0].
(arrayOrObjectWithTwoSlots instVarAt: 2)
ifNil: [arrayOrObjectWithTwoSlots instVarAt: 2 put: 0]!

Item was changed:
+ (PackageInfo named: 'Chronology-Core') postscript: 'Smalltalk removeFromStartUpList: DateAndTime'!
- (PackageInfo named: 'Chronology-Core') postscript: '"Make sure UpdateVMTimeZoneCacheAt of Time is initialized."
- Time classPool at: #UpdateVMTimeZoneCacheAt put: 0.
- "Separated Time''s startup duties from DateAndTime."
- Smalltalk addToStartUpList: Time before: DateAndTime'!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210705/67d8bf29/attachment.html>


More information about the Squeak-dev mailing list