2022-02-15 18:04:54 +01:00
|
|
|
Class {
|
|
|
|
#name : #DiyaClock,
|
|
|
|
#superclass : #DiyaSingleton,
|
|
|
|
#instVars : [
|
2022-03-06 18:33:10 +01:00
|
|
|
'monotonic',
|
2022-08-12 16:37:53 +02:00
|
|
|
'lastTick',
|
|
|
|
'lapTime'
|
2022-02-15 18:04:54 +01:00
|
|
|
],
|
|
|
|
#category : #'Diya-Runtime'
|
|
|
|
}
|
|
|
|
|
2022-03-06 18:33:10 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> delta [
|
2022-08-12 16:37:53 +02:00
|
|
|
^ self lapDelta + self lapTime
|
2022-03-06 18:33:10 +01:00
|
|
|
]
|
|
|
|
|
2022-02-15 18:04:54 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> elapsedTime [
|
|
|
|
^(DateAndTime now) - monotonic
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> initialize [
|
|
|
|
monotonic := DateAndTime now.
|
2022-03-06 18:33:10 +01:00
|
|
|
lastTick := monotonic.
|
2022-08-14 22:49:36 +02:00
|
|
|
lapTime := 0.
|
2022-08-12 16:37:53 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> lapDelta [
|
2022-08-14 22:49:36 +02:00
|
|
|
^ ((DateAndTime now) - lastTick) asMilliSeconds
|
2022-08-12 16:37:53 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> lapTime [
|
|
|
|
^ lapTime
|
2022-03-06 18:33:10 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaClock >> tick [
|
2022-08-14 22:49:36 +02:00
|
|
|
lapTime := self lapDelta.
|
2022-03-06 18:33:10 +01:00
|
|
|
lastTick := DateAndTime now.
|
2022-02-15 18:04:54 +01:00
|
|
|
]
|