1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
32
|
13 |
AbsoluteTime subclass:#Time
|
|
14 |
instanceVariableNames:''
|
1
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Magnitude-General'
|
|
18 |
!
|
|
19 |
|
|
20 |
Time comment:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
1
|
23 |
All Rights Reserved
|
|
24 |
|
32
|
25 |
$Header: /cvs/stx/stx/libbasic/Time.st,v 1.6 1994-01-08 16:24:16 claus Exp $
|
1
|
26 |
'!
|
|
27 |
|
|
28 |
!Time class methodsFor:'instance creation'!
|
|
29 |
|
|
30 |
now
|
|
31 |
"return an instance of Time representing this moment"
|
|
32 |
|
|
33 |
^ self basicNew setSecondsLow:(OperatingSystem getTimeLow)
|
|
34 |
and:(OperatingSystem getTimeHi)
|
|
35 |
! !
|
|
36 |
|
|
37 |
!Time class methodsFor:'ST-80 compatibility'!
|
|
38 |
|
|
39 |
totalSeconds
|
|
40 |
^ self secondClock
|
|
41 |
! !
|
|
42 |
|
|
43 |
!Time methodsFor:'comparing'!
|
|
44 |
|
|
45 |
> aTime
|
|
46 |
(aTime isMemberOf:Time) ifTrue:[
|
|
47 |
(secondsHi > aTime secondsHi) ifTrue:[^ true].
|
|
48 |
(secondsHi < aTime secondsHi) ifTrue:[^ false].
|
|
49 |
(secondsLow > aTime secondsLow) ifTrue:[^ true].
|
|
50 |
^ false
|
|
51 |
].
|
|
52 |
^ self getSeconds > aTime getSeconds
|
|
53 |
!
|
|
54 |
|
|
55 |
< aTime
|
|
56 |
(aTime isMemberOf:Time) ifTrue:[
|
|
57 |
(secondsHi < aTime secondsHi) ifTrue:[^ true].
|
|
58 |
(secondsHi > aTime secondsHi) ifTrue:[^ false].
|
|
59 |
(secondsLow < aTime secondsLow) ifTrue:[^ true].
|
|
60 |
^ false
|
|
61 |
].
|
|
62 |
^ self getSeconds < aTime getSeconds
|
|
63 |
!
|
|
64 |
|
|
65 |
= aTime
|
|
66 |
(aTime isMemberOf:Time) ifTrue:[
|
|
67 |
^ ((secondsLow == aTime secondsLow) and:[secondsHi == aTime secondsHi])
|
|
68 |
].
|
|
69 |
^ self getSeconds = aTime getSeconds
|
|
70 |
! !
|
|
71 |
|
|
72 |
!Time methodsFor:'printing'!
|
|
73 |
|
|
74 |
printString
|
|
75 |
|aString|
|
|
76 |
|
|
77 |
OperatingSystem computeTimePartsOf:secondsLow and:secondsHi for:[
|
|
78 |
:hours :minutes :secs |
|
|
79 |
|
|
80 |
aString := hours printString , ':' .
|
|
81 |
(minutes < 10) ifTrue:[aString := aString , '0'].
|
|
82 |
aString := aString , minutes printString.
|
|
83 |
aString := aString , ':'.
|
|
84 |
(secs < 10) ifTrue:[aString := aString , '0'].
|
|
85 |
aString := aString , secs printString
|
|
86 |
].
|
|
87 |
^ aString
|
|
88 |
! !
|