1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-26 11:28:22 +01:00
Diya-API/Diya/DiyaClock.class.st

44 lines
756 B
Smalltalk
Raw Permalink Normal View History

2022-02-15 18:04:54 +01:00
Class {
#name : #DiyaClock,
#superclass : #DiyaSingleton,
#instVars : [
2022-03-06 18:33:10 +01:00
'monotonic',
'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 [
^ 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.
]
{ #category : #initialization }
DiyaClock >> lapDelta [
2022-08-14 22:49:36 +02:00
^ ((DateAndTime now) - lastTick) asMilliSeconds
]
{ #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
]