<div dir="ltr">Hi Levente,<div><br></div><div>Here's an alternative which addresses all of your concerns.</div><div><br></div><div> - Chris<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 30, 2020 at 10:35 PM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Chris Muller uploaded a new version of Chronology-Core to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Chronology-Core-cmm.54.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/Chronology-Core-cmm.54.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Chronology-Core-cmm.54<br>
Author: cmm<br>
Time: 30 April 2020, 10:35:37.087886 pm<br>
UUID: aea28e1f-8f45-4621-938d-61349776e465<br>
Ancestors: Chronology-Core-nice.52<br>
<br>
- Let #primUtcMicrosecondClock provide access to primitive 240.<br>
- Let #utcMicrosecondClock be based on the Smalltalk epoch, 1/1/1901 @ 00:00:00.<br>
- Three legacy senders were left alone pending discussion whether they can use the new #utcMicrosecondClock.<br>
- Provide DateAndTime class>>#fromUtcMicrosecondClock:, as a supplement to Time class>>#utcMicrosecondClock.<br>
<br>
=============== Diff against Chronology-Core-nice.52 ===============<br>
<br>
Item was added:<br>
+ ----- Method: DateAndTime class>>fromUtcMicrosecondClock: (in category 'smalltalk-80') -----<br>
+ fromUtcMicrosecondClock: anInteger <br>
+       "Answer a DateAndTime the specified microseconds after the Squeak epoch: 1/1/1901 @ 00:00:00."<br>
+       ^ self<br>
+               utcMicroseconds: anInteger<br>
+               offset: self localOffsetSeconds!<br>
<br>
Item was changed:<br>
  ----- Method: Time class>>estimateHighResClockTicksPerMillisecond (in category 'clock') -----<br>
  estimateHighResClockTicksPerMillisecond<br>
<br>
        | t0 t1 t2 t3 |<br>
<br>
        "Count the ticks ellapsed during a 10ms busy loop"<br>
+       t0 := Time primUtcMicrosecondClock + 200.<br>
+       [Time primUtcMicrosecondClock >= t0] whileFalse.<br>
-       t0 := Time utcMicrosecondClock + 200.<br>
-       [Time utcMicrosecondClock >= t0] whileFalse.<br>
        t1 := self highResClock.<br>
+       [Time primUtcMicrosecondClock >= (t0 + 10000)] whileFalse.<br>
+       t1 := self highResClock - t1 * 1000 // (Time primUtcMicrosecondClock - t0).<br>
-       [Time utcMicrosecondClock >= (t0 + 10000)] whileFalse.<br>
-       t1 := self highResClock - t1 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
        "Count the ticks ellapsed during a 20ms busy loop"<br>
+       t0 := Time primUtcMicrosecondClock + 200.<br>
+       [Time primUtcMicrosecondClock >= t0] whileFalse.<br>
-       t0 := Time utcMicrosecondClock + 200.<br>
-       [Time utcMicrosecondClock >= t0] whileFalse.<br>
        t2 := self highResClock.<br>
+       [Time primUtcMicrosecondClock >= (t0 + 20000)] whileFalse.<br>
+       t2 := self highResClock - t2 * 1000 // (Time primUtcMicrosecondClock - t0).<br>
-       [Time utcMicrosecondClock >= (t0 + 20000)] whileFalse.<br>
-       t2 := self highResClock - t2 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
        "Count the ticks ellapsed during a 30ms busy loop"<br>
+       t0 := Time primUtcMicrosecondClock + 200.<br>
+       [Time primUtcMicrosecondClock >= t0] whileFalse.<br>
-       t0 := Time utcMicrosecondClock + 200.<br>
-       [Time utcMicrosecondClock >= t0] whileFalse.<br>
        t3 := self highResClock.<br>
+       [Time primUtcMicrosecondClock >= (t0 + 30000)] whileFalse.<br>
+       t3 := self highResClock - t3 * 1000 // (Time primUtcMicrosecondClock - t0).<br>
-       [Time utcMicrosecondClock >= (t0 + 30000)] whileFalse.<br>
-       t3 := self highResClock - t3 * 1000 // (Time utcMicrosecondClock - t0).<br>
<br>
        "Take the median of the 3 estimates as the best"<br>
        ^ t1 <= t2<br>
                ifTrue: [t2 <= t3<br>
                                ifTrue: [t2]<br>
                                ifFalse: [t1 <= t3<br>
                                                ifTrue: [t3]<br>
                                                ifFalse: [t1]]]<br>
                ifFalse: [t1 <= t3<br>
                                ifTrue: [t1]<br>
                                ifFalse: [t2 <= t3<br>
                                                ifTrue: [t3]<br>
                                                ifFalse: [t2]]]!<br>
<br>
Item was changed:<br>
  ----- Method: Time class>>localMicrosecondClock (in category 'clock') -----<br>
  localMicrosecondClock<br>
        "Answer the local microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century).<br>
         The value is derived from the current UTC wallclock time and the image's current notion of time zone."<br>
+       ^self primUtcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)!<br>
-       ^self utcMicrosecondClock + (DateAndTime localOffset asSeconds * 1000000)!<br>
<br>
Item was changed:<br>
  ----- Method: Time class>>millisecondClockValue (in category 'general inquiries') -----<br>
  millisecondClockValue<br>
        "Answer the value of the millisecond clock."<br>
<br>
+       ^self primUtcMicrosecondClock // 1000!<br>
-       ^self utcMicrosecondClock // 1000!<br>
<br>
Item was added:<br>
+ ----- Method: Time class>>primUtcMicrosecondClock (in category 'private') -----<br>
+ primUtcMicrosecondClock<br>
+       "Answer the UTC microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century).<br>
+        The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds<br>
+        between the two epochs according to RFC 868."<br>
+       <primitive: 240><br>
+       ^0!<br>
<br>
Item was changed:<br>
  ----- Method: Time class>>utcMicrosecondClock (in category 'clock') -----<br>
  utcMicrosecondClock<br>
        "Answer the UTC microseconds since the Smalltalk epoch (January 1st 1901, the start of the 20th century).<br>
         The value is derived from the Posix epoch with a constant offset corresponding to elapsed microseconds<br>
         between the two epochs according to RFC 868."<br>
+       ^ self primUtcMicrosecondClock - (DateAndTime daysFromSmalltalkEpochToPosixEpoch*MicrosecondsInDay)!<br>
-       <primitive: 240><br>
-       ^0!<br>
<br>
<br>
</blockquote></div>