'From Squeak4.2 of 3 May 2011 [latest update: #11376] on 3 May 2011 at 8:25:17 pm'! Object subclass: #CheckTimeDrift instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Junk'! !CheckTimeDrift commentStamp: 'dtl 5/3/2011 20:13' prior: 0! A CheckTimeDrift is a test for Squeak DateAndTime now versus the underlying platform time. Prerequisites: - Install TimeZoneDatabase from SqueakSource and set local time zone - Run under an interpreter VM that provides #primitiveUtcWithOffset Open a transcript, then doIt: [CheckTimeDrift run] fork inspect ! ]style[(221 22 34 25 10),c000000126,,c000126126,! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! CheckTimeDrift class instanceVariableNames: ''! !CheckTimeDrift class methodsFor: 'running' stamp: 'dtl 5/3/2011 20:24'! run "Load package TimeZoneDatabase. Set time zone. Run under an interpreter VM. Open transcript, then run." "[CheckTimeDrift run] fork" | start diff osTime squeakTime initialDifference drift | start := DateAndTime now. osTime := CheckTimeDrift now. squeakTime := DateAndTime now. initialDifference := squeakTime - osTime. [osTime := CheckTimeDrift now. squeakTime := DateAndTime now. diff := squeakTime - osTime. drift := diff - initialDifference. Transcript cr; nextPutAll: '=== Started at ', start printString, ' ==='. Transcript cr; nextPutAll: 'Test duration ', (squeakTime - start) printString. Transcript cr; nextPutAll: 'OS time now: ', osTime printString. Transcript cr; nextPutAll: 'Squeak time now: ', squeakTime printString. Transcript cr; nextPutAll: 'Difference: ', diff printString. Transcript cr; show: 'Drift: ', drift printString. (Delay forSeconds: 3) wait. ] repeat! ! !CheckTimeDrift class methodsFor: 'time' stamp: 'dtl 5/3/2011 19:59'! now "self now" | uSec pt | uSec := self primUtcWithOffset first. pt := PointInTime fromPosixSeconds: uSec / 1000000. ^ pt asDateAndTime! ! !CheckTimeDrift class methodsFor: 'primitive access' stamp: 'dtl 5/3/2011 19:54'! primUtcWithOffset "Answer an array with UTC microseconds since the Posix epoch and the current seconds offset from GMT in the local time zone. This is a named (not numbered) primitive in the null module (ie the VM)" "self primUtcWithOffset" self error: 'use an interpreter VM, not Cog'! !