mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 03:48:21 +01:00
44 lines
767 B
Smalltalk
44 lines
767 B
Smalltalk
Class {
|
|
#name : #DiyaClock,
|
|
#superclass : #DiyaSingleton,
|
|
#instVars : [
|
|
'monotonic',
|
|
'lastTick',
|
|
'lapTime'
|
|
],
|
|
#category : #'Diya-Runtime'
|
|
}
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> delta [
|
|
^ self lapDelta + self lapTime
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> elapsedTime [
|
|
^(DateAndTime now) - monotonic
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> initialize [
|
|
monotonic := DateAndTime now.
|
|
lastTick := monotonic.
|
|
lapTime := 0 asDuration.
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> lapDelta [
|
|
^ ((DateAndTime now) - lastTick)
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> lapTime [
|
|
^ lapTime
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
DiyaClock >> tick [
|
|
lapTime := (DateAndTime now) - lastTick.
|
|
lastTick := DateAndTime now.
|
|
]
|