--- a/AbstrTime.st Thu Dec 07 22:24:46 1995 +0100
+++ b/AbstrTime.st Thu Dec 07 22:32:39 1995 +0100
@@ -10,8 +10,6 @@
hereby transferred.
"
-'From Smalltalk/X, Version:2.10.4 on 7-feb-1995 at 11:53:03 pm'!
-
Magnitude subclass:#AbstractTime
instanceVariableNames:''
classVariableNames:''
@@ -40,37 +38,17 @@
This is an abstract class; there are no instances in the system.
It is meant as a home for methods common to time handling classes.
"
-!
-
-version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/AbstrTime.st,v 1.7 1995-11-11 14:26:24 cg Exp $'
! !
!AbstractTime class methodsFor:'instance creation'!
-now
- "return an instance of myself representing this moment"
+dateAndTimeNow
+ "return an array filled with date and time"
- ^ self basicNew fromOSTime:(OperatingSystem getTimeParts)
+ ^ Array with:(Date today) with:(Time now)
"
- AbsoluteTime now
- Time now
- "
-!
-
-fromSeconds:seconds
- "return an instance that is constructed from seconds.
- This method is only allowed for second values as returned by
- getSeconds, possibly adding/subtracting to that. Never
- depend on any specific interpretation of the seconds."
-
- ^ self basicNew setSeconds:seconds
-
- "
- Time fromSeconds:0 should return midnight
- AbsoluteTime fromSeconds:0 on UNIX: returns 1st. Jan 1970
- on others: dont know
+ Time dateAndTimeNow
"
!
@@ -100,14 +78,40 @@
^ self basicNew fromOSTimeLow:osTimeLow and:osTimeHigh
!
-dateAndTimeNow
- "return an array filled with date and time"
+fromSeconds:seconds
+ "return an instance that is constructed from seconds.
+ This method is only allowed for second values as returned by
+ getSeconds, possibly adding/subtracting to that. Never
+ depend on any specific interpretation of the seconds."
- ^ Array with:(Date today) with:(Time now)
+ ^ self basicNew setSeconds:seconds
"
- Time dateAndTimeNow
+ Time fromSeconds:0 should return midnight
+ AbsoluteTime fromSeconds:0 on UNIX: returns 1st. Jan 1970
+ on others: dont know
+ "
+!
+
+now
+ "return an instance of myself representing this moment"
+
+ ^ self basicNew fromOSTime:(OperatingSystem getTimeParts)
+
"
+ AbsoluteTime now
+ Time now
+ "
+! !
+
+!AbstractTime class methodsFor:'ST-80 compatibility'!
+
+totalSeconds
+ "returns an internal second clock. Dont interpret the returned
+ value - if at all, use it to compute time deltas, by subtracting
+ returned values."
+
+ ^ self secondClock
! !
!AbstractTime class methodsFor:'obsolete'!
@@ -119,36 +123,60 @@
^ self fromOSTimeLow:low and:hi
! !
-!AbstractTime methodsFor:'private'!
+!AbstractTime class methodsFor:'queries'!
-fromOSTime:timeParts
- "set my time, from operatingSystems time parts"
+millisecondClockValue
+ "return the millisecond clock - since this one overruns
+ regularly, use the value only for short timing deltas.
+ Also remember that it wraps when compares these values."
- ^ self fromOSTimeLow:(timeParts at:1) and:(timeParts at:2)
+ ^ OperatingSystem getMillisecondTime.
+
+ "
+ Time millisecondClockValue
+ "
!
-fromOSTimeTimeLow:lowTime and:hiTime
- "set my time, from operatingSystems time parts.
- Since I am abstract (not knowing how the time is actually
- represented), this must be done by a concrete class."
+secondClock
+ "return seconds of now - for GNU-ST compatibility"
+
+ ^ OperatingSystem getTime
+
+ "
+ AbstractTime secondClock
+ "
+! !
+
+!AbstractTime class methodsFor:'timing evaluations'!
- ^ self subclassResponsibility
+millisecondsToRun:aBlock
+ "evaluate the argument, aBlock; return the number of milliseconds it took"
+
+ |startTime endTime|
+
+ startTime := self millisecondClockValue.
+ aBlock value.
+ endTime := self millisecondClockValue.
+ ^ endTime - startTime
+
+ "
+ Time millisecondsToRun:[100 factorial]
+ "
!
-setSeconds:secs
- "set the seconds.
- Since I am abstract (not knowing how the time is actually
- represented), this must be done by a concrete class."
+secondsToRun:aBlock
+ "evaluate the argument, aBlock; return the number of seconds it took"
+
+ |startTime endTime|
- ^ self subclassResponsibility
-!
+ startTime := self secondClock.
+ aBlock value.
+ endTime := self secondClock.
+ ^ endTime - startTime
-getSeconds
- "get the seconds.
- Since I am abstract (not knowing how the time is actually
- represented), this must be done by a concrete class."
-
- ^ self subclassResponsibility
+ "
+ Time secondsToRun:[1000 factorial]
+ "
! !
!AbstractTime methodsFor:'accessing'!
@@ -203,17 +231,17 @@
"
!
-addSeconds:numberOfSeconds
- "return a new instance of myself, numberOfSeconds afterwards."
+addHours:numberOfHours
+ "return a new instance of myself, numberOfHours afterwards."
- ^ self species basicNew setSeconds:(self getSeconds + numberOfSeconds)
+ ^ self addSeconds:(numberOfHours * (60 * 60))
"
|t|
- t := AbsoluteTime now. t printNL. (t addSeconds:50) printNL.
-
- t := Time now. t printNL. (t addSeconds:50) printNL
+ t := AbsoluteTime now.
+ t printNL.
+ (t addHours:50) printNL
"
!
@@ -231,31 +259,39 @@
"
!
-addHours:numberOfHours
- "return a new instance of myself, numberOfHours afterwards."
+addSeconds:numberOfSeconds
+ "return a new instance of myself, numberOfSeconds afterwards."
+
+ ^ self species basicNew setSeconds:(self getSeconds + numberOfSeconds)
+
+ "
+ |t|
+
+ t := AbsoluteTime now. t printNL. (t addSeconds:50) printNL.
- ^ self addSeconds:(numberOfHours * (60 * 60))
+ t := Time now. t printNL. (t addSeconds:50) printNL
+ "
+!
+
+addTime:timeAmount
+ "return a new instance of myself, timeAmount seconds afterwards.
+ AddTime is a bad name - it does not add a time, but expects
+ a number. Use any of addSeconds/addHours etc."
+
+ ^ self species basicNew setSeconds:(self getSeconds + timeAmount)
+!
+
+subtractHours:numberOfHours
+ "return a new instance of myself, numberOfHours before."
+
+ ^ self subtractSeconds:(numberOfHours * (60 * 60))
"
|t|
t := AbsoluteTime now.
t printNL.
- (t addHours:50) printNL
- "
-!
-
-subtractSeconds:numberOfSeconds
- "return a new instance of myself, numberOfSeconds before."
-
- ^ self species basicNew setSeconds:(self getSeconds - numberOfSeconds)
-
- "
- |t|
-
- t := AbsoluteTime now.
- t printNL.
- (t subtractSeconds:50) printNL
+ (t subtractHours:50) printNL
"
!
@@ -273,28 +309,20 @@
"
!
-subtractHours:numberOfHours
- "return a new instance of myself, numberOfHours before."
+subtractSeconds:numberOfSeconds
+ "return a new instance of myself, numberOfSeconds before."
- ^ self subtractSeconds:(numberOfHours * (60 * 60))
+ ^ self species basicNew setSeconds:(self getSeconds - numberOfSeconds)
"
|t|
t := AbsoluteTime now.
t printNL.
- (t subtractHours:50) printNL
+ (t subtractSeconds:50) printNL
"
!
-addTime:timeAmount
- "return a new instance of myself, timeAmount seconds afterwards.
- AddTime is a bad name - it does not add a time, but expects
- a number. Use any of addSeconds/addHours etc."
-
- ^ self species basicNew setSeconds:(self getSeconds + timeAmount)
-!
-
subtractTime:timeAmount
"return a new instance opf myself, timeAmount seconds before myself.
SubtractTime is a bad name - it does not subtract a time, but expects
@@ -303,69 +331,40 @@
^ self species basicNew setSeconds:(self getSeconds - timeAmount)
! !
-!AbstractTime class methodsFor:'queries'!
-
-secondClock
- "return seconds of now - for GNU-ST compatibility"
+!AbstractTime methodsFor:'private'!
- ^ OperatingSystem getTime
+fromOSTime:timeParts
+ "set my time, from operatingSystems time parts"
- "
- AbstractTime secondClock
- "
+ ^ self fromOSTimeLow:(timeParts at:1) and:(timeParts at:2)
!
-millisecondClockValue
- "return the millisecond clock - since this one overruns
- regularly, use the value only for short timing deltas.
- Also remember that it wraps when compares these values."
+fromOSTimeTimeLow:lowTime and:hiTime
+ "set my time, from operatingSystems time parts.
+ Since I am abstract (not knowing how the time is actually
+ represented), this must be done by a concrete class."
+
+ ^ self subclassResponsibility
+!
- ^ OperatingSystem getMillisecondTime.
+getSeconds
+ "get the seconds.
+ Since I am abstract (not knowing how the time is actually
+ represented), this must be done by a concrete class."
- "
- Time millisecondClockValue
- "
+ ^ self subclassResponsibility
+!
+
+setSeconds:secs
+ "set the seconds.
+ Since I am abstract (not knowing how the time is actually
+ represented), this must be done by a concrete class."
+
+ ^ self subclassResponsibility
! !
-!AbstractTime class methodsFor:'timing evaluations'!
-
-secondsToRun:aBlock
- "evaluate the argument, aBlock; return the number of seconds it took"
-
- |startTime endTime|
-
- startTime := self secondClock.
- aBlock value.
- endTime := self secondClock.
- ^ endTime - startTime
-
- "
- Time secondsToRun:[1000 factorial]
- "
-!
-
-millisecondsToRun:aBlock
- "evaluate the argument, aBlock; return the number of milliseconds it took"
+!AbstractTime class methodsFor:'documentation'!
- |startTime endTime|
-
- startTime := self millisecondClockValue.
- aBlock value.
- endTime := self millisecondClockValue.
- ^ endTime - startTime
-
- "
- Time millisecondsToRun:[100 factorial]
- "
+version
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/AbstrTime.st,v 1.8 1995-12-07 21:31:40 cg Exp $'
! !
-
-!AbstractTime class methodsFor:'ST-80 compatibility'!
-
-totalSeconds
- "returns an internal second clock. Dont interpret the returned
- value - if at all, use it to compute time deltas, by subtracting
- returned values."
-
- ^ self secondClock
-! !
-