author | Stefan Vogel <sv@exept.de> |
Thu, 02 Mar 2000 18:21:57 +0100 | |
changeset 5290 | f26854f0f074 |
parent 4930 | edb87412f76d |
child 5291 | 8b1013528fb4 |
permissions | -rw-r--r-- |
30 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 3 |
All Rights Reserved |
30 | 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 |
||
241 | 13 |
AbstractTime subclass:#AbsoluteTime |
795 | 14 |
instanceVariableNames:'osTime' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Magnitude-General' |
|
30 | 18 |
! |
19 |
||
2311 | 20 |
!AbsoluteTime class methodsFor:'documentation'! |
30 | 21 |
|
82 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 25 |
All Rights Reserved |
82 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
30 | 36 |
documentation |
37 |
" |
|
1669 | 38 |
This class represents absolute time values in milliSeconds starting some |
1501 | 39 |
time in the past. |
40 |
(typically, from 1st. Jan 1970, as used in the Unix operating system, |
|
41 |
but other systems may bias the time differently. |
|
42 |
Actually, the implementation does not depend or even know which time/date |
|
43 |
the OperatingSystem bases its time upon - it is simply keeping the value(s) |
|
44 |
as return from the OS. |
|
45 |
For conversion, these values are given back to the OS, which will know |
|
46 |
how to convert these times. |
|
47 |
This has the advantage, that time-stamps on files (such as last-access- |
|
48 |
time or last-modifiaction-time) can be handled transparent to other |
|
49 |
times - especially comparisons). |
|
241 | 50 |
|
1501 | 51 |
You should not interpret the osTime instance variable directly, instead |
52 |
(if at all), as the OS to convert. |
|
30 | 53 |
|
1501 | 54 |
Its implementation is not the same as in ST-80 |
1669 | 55 |
(which represents Time as seconds from 1. Jan 1901.) |
30 | 56 |
|
241 | 57 |
This class should not be confused with Time (which only represents the |
1501 | 58 |
time within one day). |
59 |
Time instances cannot be used to compare times across midnight; |
|
60 |
instances of AbsoluteTime can. |
|
241 | 61 |
|
3479 | 62 |
Notice: this class is aliased as Timestamp for ST-80 compatibility. |
63 |
||
1306 | 64 |
[author:] |
4679 | 65 |
Claus Gittinger |
1306 | 66 |
|
1282 | 67 |
[See also:] |
4679 | 68 |
Time Date |
69 |
Delay ProcessorScheduler |
|
30 | 70 |
" |
71 |
! ! |
|
72 |
||
2311 | 73 |
!AbsoluteTime class methodsFor:'instance creation'! |
30 | 74 |
|
4378 | 75 |
UTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
1501 | 76 |
"return an instance of the receiver, given individual components. |
77 |
See also `AbsoluteTime now' and other protocol inherited |
|
78 |
from my superclass." |
|
79 |
||
423 | 80 |
^ self basicNew |
4679 | 81 |
fromOSTime:(OperatingSystem |
82 |
computeOSTimeFromUTCYear:y month:m day:d |
|
83 |
hour:h minute:min second:s |
|
84 |
millisecond:millis) |
|
30 | 85 |
|
241 | 86 |
" |
4378 | 87 |
AbsoluteTime UTCYear:1970 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
88 |
AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:0 |
|
89 |
AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
90 |
AbsoluteTime UTCYear:1999 month:7 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
91 |
AbsoluteTime UTCYear:2000 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
241 | 92 |
" |
1228 | 93 |
|
4378 | 94 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
95 |
"Created: / 13.7.1999 / 12:34:37 / stefan" |
|
96 |
"Modified: / 13.7.1999 / 12:42:30 / stefan" |
|
97 |
! |
|
98 |
||
99 |
day:d month:m year:y hour:h minutes:min seconds:s |
|
100 |
"This is obsolete. User #year:month:day:hour:minute:second:" |
|
101 |
||
102 |
^ self |
|
4679 | 103 |
year:y month:m day:d hour:h |
104 |
minute:min second:s millisecond:0 |
|
4378 | 105 |
|
106 |
" |
|
107 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
108 |
AbsoluteTime day:8 month:1 year:1995 hour:0 minute:43 second:48 |
|
109 |
" |
|
110 |
||
111 |
"Modified: / 1.7.1996 / 15:22:26 / cg" |
|
112 |
"Modified: / 13.7.1999 / 12:29:56 / stefan" |
|
113 |
! |
|
114 |
||
115 |
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis |
|
116 |
"This is obsolete. User #year:month:day:hour:minute:second:millisecond:" |
|
117 |
||
118 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
119 |
||
120 |
" |
|
121 |
AbsoluteTime day:1 month:1 year:1970 hour:1 minute:0 second:0 |
|
122 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
123 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 millisecond:100 |
|
124 |
" |
|
125 |
||
126 |
"Created: / 1.7.1996 / 14:46:09 / cg" |
|
127 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
128 |
"Modified: / 13.7.1999 / 12:30:26 / stefan" |
|
275 | 129 |
! |
130 |
||
423 | 131 |
fromDate:aDate andTime:aTime |
132 |
"return an instance of the receiver, initialized from a time and a date |
|
1228 | 133 |
object. |
134 |
See also `AbsoluteTime now' and other protocol inherited |
|
135 |
from my superclass." |
|
423 | 136 |
|
137 |
^ self |
|
4679 | 138 |
year:aDate year |
139 |
month:aDate month |
|
140 |
day:aDate day |
|
141 |
hour:aTime hours |
|
142 |
minute:aTime minutes |
|
143 |
second:aTime seconds |
|
423 | 144 |
|
145 |
" |
|
1228 | 146 |
AbsoluteTime fromDate:(Date today) andTime:(Time now) |
147 |
AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) |
|
148 |
AbsoluteTime now |
|
423 | 149 |
" |
150 |
||
4378 | 151 |
"Modified: / 8.9.1995 / 15:07:30 / claus" |
152 |
"Modified: / 19.4.1996 / 15:25:46 / cg" |
|
153 |
"Modified: / 13.7.1999 / 12:30:47 / stefan" |
|
423 | 154 |
! |
155 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
156 |
newDay:dayInYear year:year |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
157 |
"return a new AbsoluteTime, given the year and the day-in-year (starting at 1). |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
158 |
Date protocol compatibility" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
159 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
160 |
^ (Date newDay:dayInYear year:year) asAbsoluteTime |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
161 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
162 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
163 |
AbsoluteTime newDay:183 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
164 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
165 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
166 |
"Modified: 2.7.1996 / 09:39:30 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
167 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
168 |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
169 |
readFrom:aStringOrStream onError:exceptionBlock |
275 | 170 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
171 |
The string is interpreted as 24 hour format, as printed. |
|
172 |
Notice, that this is not the storeString format and |
|
4898 | 173 |
is different from the format expected by readFrom:. |
174 |
The format read here is dd-mm-yyyy hh:mm:ss.iii" |
|
275 | 175 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
176 |
|newTime| |
275 | 177 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
178 |
ErrorSignal handle:[:ex | |
4898 | 179 |
^ exceptionBlock value |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
180 |
] do:[ |
4898 | 181 |
|str day month year hour min sec millis| |
1701
80d13adb2e77
better errorHandling in readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
182 |
|
4898 | 183 |
str := aStringOrStream readStream. |
275 | 184 |
|
4898 | 185 |
day := Integer readFrom:str. |
186 |
(day between:1 and:31) ifFalse:[^ exceptionBlock value]. |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
187 |
|
4898 | 188 |
[str peek isDigit] whileFalse:[str next]. |
189 |
month := Integer readFrom:str. |
|
190 |
(month between:1 and:12) ifFalse:[^ exceptionBlock value]. |
|
275 | 191 |
|
4898 | 192 |
[str peek isDigit] whileFalse:[str next]. |
193 |
year := Integer readFrom:str. |
|
275 | 194 |
|
4898 | 195 |
[str peek isDigit] whileFalse:[str next]. |
196 |
hour := Integer readFrom:str. |
|
197 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
|
275 | 198 |
|
4898 | 199 |
[str peek isDigit] whileFalse:[str next]. |
200 |
min := Integer readFrom:str. |
|
201 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
|
275 | 202 |
|
4906
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
203 |
str atEnd ifTrue:[ |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
204 |
sec := millis := 0. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
205 |
] ifFalse:[ |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
206 |
[str peek isDigit] whileFalse:[str next]. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
207 |
sec := Integer readFrom:str. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
208 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
275 | 209 |
|
4906
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
210 |
str peek = $. ifTrue:[ |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
211 |
str next. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
212 |
millis := Integer readFrom:str. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
213 |
] ifFalse:[ |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
214 |
millis := 0. |
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
215 |
]. |
4898 | 216 |
]. |
1501 | 217 |
|
4898 | 218 |
"special check" |
219 |
hour == 24 ifTrue:[ |
|
220 |
(min ~~ 0 or:[sec ~~ 0]) ifTrue:[^ exceptionBlock value]. |
|
221 |
]. |
|
4899 | 222 |
newTime := self year:year month:month day:day hour:hour minute:min second:sec millisecond:millis. |
275 | 223 |
]. |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
224 |
^ newTime |
275 | 225 |
|
226 |
" |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
227 |
AbsoluteTime readFrom:'20-2-1995 13:11:06' |
4906
80febc79ccff
readFrom:onError: stream without seconds and millisec allowed
ca
parents:
4899
diff
changeset
|
228 |
AbsoluteTime readFrom:'20-2-1995 13:11' |
1501 | 229 |
AbsoluteTime readFrom:'20-2-1995 13:11:06.100' |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
230 |
AbsoluteTime readFrom:'32-2-1995 13:11:06.100' onError:'wrong' |
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
231 |
AbsoluteTime readFrom:'32-foo-1995 13:11:06.100' onError:'wrong' |
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
232 |
AbsoluteTime readFrom:'foo' onError:'wrong' |
275 | 233 |
" |
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
234 |
|
4378 | 235 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
236 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
|
2311 | 237 |
! |
238 |
||
239 |
secondsSince1970:sec |
|
240 |
"set time from elapsed seconds since 1-1-1970, 0:0:0. |
|
241 |
This is the format used in the UNIX world" |
|
242 |
||
4378 | 243 |
^ self year:1970 month:1 day:1 hour:0 minute:0 second:sec. |
244 |
||
245 |
" |
|
4679 | 246 |
AbsoluteTime secondsSince1970:0 |
247 |
AbsoluteTime secondsSince1970:3600 |
|
4378 | 248 |
" |
249 |
||
250 |
"Created: / 21.10.1996 / 17:48:30 / stefan" |
|
251 |
"Modified: / 13.7.1999 / 12:31:22 / stefan" |
|
252 |
! |
|
253 |
||
254 |
year:y month:m day:d hour:h minute:min second:s |
|
255 |
"return an instance of the receiver, given individual components. |
|
256 |
See also `AbsoluteTime now' and other protocol inherited |
|
257 |
from my superclass." |
|
258 |
||
259 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:0 |
|
2311 | 260 |
|
261 |
" |
|
4378 | 262 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 second:0 |
263 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
264 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
265 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minutes:0 second:0 |
|
2311 | 266 |
" |
267 |
||
4378 | 268 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
269 |
"Created: / 13.7.1999 / 12:06:39 / stefan" |
|
270 |
"Modified: / 13.7.1999 / 12:27:47 / stefan" |
|
271 |
! |
|
272 |
||
273 |
year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
274 |
"return an instance of the receiver, given individual components. |
|
275 |
See also `AbsoluteTime now' and other protocol inherited |
|
276 |
from my superclass." |
|
277 |
||
278 |
^ self basicNew |
|
4679 | 279 |
fromOSTime:(OperatingSystem |
280 |
computeOSTimeFromYear:y month:m day:d |
|
281 |
hour:h minute:min seconds:s millis:millis) |
|
4378 | 282 |
|
283 |
" |
|
284 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 seconds:0 |
|
285 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
286 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
287 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minute:0 second:0 |
|
288 |
" |
|
289 |
||
290 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
291 |
"Created: / 13.7.1999 / 12:28:44 / stefan" |
|
292 |
"Modified: / 13.7.1999 / 12:37:57 / stefan" |
|
241 | 293 |
! ! |
30 | 294 |
|
295 |
!AbsoluteTime methodsFor:'accessing'! |
|
296 |
||
297 |
day |
|
92 | 298 |
"return the day-in-month of the receiver (1..31). |
275 | 299 |
For compatibility, use instances of Date for this." |
30 | 300 |
|
241 | 301 |
|d| |
302 |
||
275 | 303 |
OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
3120 | 304 |
d := day |
241 | 305 |
]. |
306 |
^ d |
|
54 | 307 |
|
92 | 308 |
" |
241 | 309 |
AbsoluteTime now day |
92 | 310 |
" |
1501 | 311 |
|
312 |
"Modified: 1.7.1996 / 15:23:02 / cg" |
|
313 |
! |
|
314 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
315 |
dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
316 |
"return the week-day of the receiver - 1 for monday, 7 for sunday" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
317 |
|
3120 | 318 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:11 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
319 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
320 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
321 |
AbsoluteTime now dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
322 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
323 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
324 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
325 |
"Created: 2.7.1996 / 09:35:48 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
326 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
327 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
328 |
dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
329 |
"return the year-day of the receiver - 1 for Jan, 1st." |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
330 |
|
3120 | 331 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:10 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
332 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
333 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
334 |
AbsoluteTime now dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
335 |
AbsoluteTime newDay:184 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
336 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
337 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
338 |
"Modified: 2.7.1996 / 10:21:02 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
339 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
340 |
|
1501 | 341 |
hour |
342 |
"return the hour (0..23). |
|
343 |
ST-80 Timestamp compatibility (I'd prefer the name #hours, for Time compatibility)." |
|
344 |
||
345 |
^ self hours |
|
346 |
||
347 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
348 |
"Modified: 1.7.1996 / 15:15:32 / cg" |
|
30 | 349 |
! |
350 |
||
241 | 351 |
hours |
352 |
"return the hours (0..23)" |
|
353 |
||
354 |
|hr| |
|
355 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
356 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 357 |
hr := hours |
241 | 358 |
]. |
359 |
^ hr |
|
54 | 360 |
|
92 | 361 |
" |
241 | 362 |
AbsoluteTime now hours |
363 |
" |
|
364 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
365 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
1501 | 366 |
! |
367 |
||
368 |
millisecond |
|
369 |
"return the millisecond (0..999). |
|
370 |
ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)." |
|
371 |
||
372 |
^ self milliseconds |
|
373 |
||
374 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
375 |
"Modified: 1.7.1996 / 15:15:24 / cg" |
|
376 |
! |
|
377 |
||
378 |
milliseconds |
|
379 |
"return the milliseconds (0..999)" |
|
380 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
381 |
|m| |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
382 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
383 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 384 |
m := millis |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
385 |
]. |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
386 |
^ m |
1501 | 387 |
|
388 |
" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
389 |
AbsoluteTime now milliseconds |
1501 | 390 |
" |
391 |
||
392 |
"Created: 1.7.1996 / 15:15:02 / cg" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
393 |
"Modified: 2.7.1996 / 09:21:41 / cg" |
1501 | 394 |
! |
395 |
||
396 |
minute |
|
397 |
"return the minute (0..59). |
|
398 |
ST-80 Timestamp compatibility (I'd prefer the name #minutes, for Time compatibility)." |
|
399 |
||
400 |
^ self minutes |
|
401 |
||
402 |
"Created: 1.7.1996 / 15:14:29 / cg" |
|
403 |
"Modified: 1.7.1996 / 15:15:37 / cg" |
|
241 | 404 |
! |
405 |
||
406 |
minutes |
|
407 |
"return the minutes (0..59)" |
|
408 |
||
409 |
|m| |
|
410 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
411 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 412 |
m := minutes |
241 | 413 |
]. |
414 |
^ m |
|
415 |
||
416 |
" |
|
417 |
AbsoluteTime now minutes |
|
92 | 418 |
" |
241 | 419 |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
420 |
"Modified: 2.7.1996 / 09:20:49 / cg" |
241 | 421 |
! |
422 |
||
699 | 423 |
month |
424 |
"return the month of the receiver (1..12). |
|
425 |
For compatibility, use instances of Date for this." |
|
426 |
||
427 |
|m| |
|
428 |
||
429 |
OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day | |
|
3120 | 430 |
m := month |
699 | 431 |
]. |
432 |
^ m |
|
433 |
||
434 |
" |
|
435 |
AbsoluteTime now month |
|
436 |
" |
|
1501 | 437 |
|
438 |
"Modified: 1.7.1996 / 15:23:05 / cg" |
|
439 |
! |
|
440 |
||
4807 | 441 |
osTime:aTime |
442 |
osTime := aTime. |
|
443 |
! |
|
444 |
||
1501 | 445 |
second |
446 |
"return the second (0..59). |
|
447 |
ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)." |
|
448 |
||
449 |
^ self seconds |
|
450 |
||
451 |
"Created: 1.7.1996 / 15:14:19 / cg" |
|
452 |
"Modified: 1.7.1996 / 15:15:49 / cg" |
|
699 | 453 |
! |
454 |
||
241 | 455 |
seconds |
456 |
"return the seconds (0..59)" |
|
457 |
||
458 |
|s| |
|
459 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
460 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 461 |
s := secs |
241 | 462 |
]. |
463 |
^ s |
|
464 |
||
465 |
" |
|
466 |
AbsoluteTime now seconds |
|
467 |
" |
|
468 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
469 |
"Modified: 2.7.1996 / 09:20:54 / cg" |
92 | 470 |
! |
471 |
||
799 | 472 |
utcOffset |
473 |
"return the difference between UTC (Greenwich Mean Time) and the local time |
|
474 |
if daylight saving time applies to ourself, take that into account. |
|
475 |
Add utcOffset bevor converting to get UTC-Time resp. UTC-Date. |
|
476 |
" |
|
477 |
||
478 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7 |
|
479 |
||
480 |
" |
|
481 |
AbsoluteTime now utcOffset |
|
482 |
(AbsoluteTime day:1 month:7 year:1995 hour:12 minutes:0 seconds:0) utcOffset |
|
483 |
" |
|
484 |
||
485 |
"Modified: 20.12.1995 / 17:28:49 / stefan" |
|
1501 | 486 |
"Modified: 1.7.1996 / 15:21:29 / cg" |
799 | 487 |
! |
488 |
||
699 | 489 |
year |
490 |
"return the year of the receiver i.e. 1992. |
|
491 |
For compatibility, use instances of Date for this." |
|
241 | 492 |
|
699 | 493 |
|y| |
241 | 494 |
|
699 | 495 |
OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
3120 | 496 |
y := year |
699 | 497 |
]. |
498 |
^ y |
|
241 | 499 |
|
500 |
" |
|
699 | 501 |
AbsoluteTime now year |
241 | 502 |
" |
1501 | 503 |
|
504 |
"Modified: 1.7.1996 / 15:23:08 / cg" |
|
241 | 505 |
! ! |
506 |
||
30 | 507 |
!AbsoluteTime methodsFor:'arithmetic'! |
508 |
||
509 |
- aTime |
|
242 | 510 |
"return the delta in seconds between 2 times." |
30 | 511 |
|
512 |
^ self getSeconds - (aTime getSeconds) |
|
513 |
! |
|
514 |
||
242 | 515 |
addDays:numberOfDays |
516 |
"return a new instance of myself, numberOfDays afterwards." |
|
517 |
||
518 |
^ self addSeconds:(numberOfDays * (60 * 60 * 24)) |
|
519 |
||
520 |
" |
|
521 |
|t| |
|
522 |
||
523 |
t := AbsoluteTime now. |
|
524 |
t printNL. |
|
525 |
(t addDays:7) printNL |
|
526 |
" |
|
527 |
! |
|
528 |
||
3122 | 529 |
addMilliseconds:nMillis |
530 |
"return a new absoluteTime instance, nMillis milliseconds after myself" |
|
531 |
||
532 |
^ (self class basicNew) setMilliseconds:(self getMilliseconds + nMillis) |
|
533 |
||
534 |
" |
|
535 |
|t1 t2| |
|
536 |
||
537 |
t1 := AbsoluteTime now. |
|
538 |
t2 := t1 addMilliseconds:10. |
|
539 |
Transcript showCR:t1. |
|
540 |
Transcript showCR:t2. |
|
541 |
" |
|
542 |
||
543 |
"Modified: / 2.12.1997 / 17:10:39 / cg" |
|
544 |
! |
|
545 |
||
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
546 |
millisecondDeltaFrom:anAbsoluteTime |
3510 | 547 |
"return the delta in milliseconds between 2 absolute times. |
548 |
The argument is supposed to be AFTER the receiver" |
|
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
549 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
550 |
^ (self getSeconds - (anAbsoluteTime getSeconds)) * 1000 |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
551 |
+ self milliseconds - anAbsoluteTime milliseconds |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
552 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
553 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
554 |
|t1 t2| |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
555 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
556 |
t1 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
557 |
Delay waitForSeconds:0.5. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
558 |
t2 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
559 |
t2 millisecondDeltaFrom:t1 |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
560 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
561 |
|
3510 | 562 |
"Modified: / 5.6.1998 / 04:21:33 / cg" |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
563 |
! |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
564 |
|
242 | 565 |
subtractDays:numberOfDays |
566 |
"return a new instance of myself, numberOfDays before." |
|
567 |
||
568 |
^ self subtractSeconds:(numberOfDays * (60 * 60 * 24)) |
|
569 |
||
570 |
" |
|
571 |
|t| |
|
572 |
||
573 |
t := AbsoluteTime now. |
|
574 |
t printNL. |
|
575 |
(t subtractDays:50) printNL |
|
576 |
" |
|
30 | 577 |
! ! |
578 |
||
699 | 579 |
!AbsoluteTime methodsFor:'comparing'! |
580 |
||
581 |
< aTime |
|
582 |
"return true if the argument, aTime is before the receiver" |
|
583 |
||
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
584 |
^ self getMilliseconds < aTime getMilliseconds |
699 | 585 |
|
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
586 |
"Modified: 3.7.1996 / 13:10:17 / cg" |
699 | 587 |
! |
588 |
||
589 |
= aTime |
|
590 |
"return true if the argument, aTime represents the same time" |
|
591 |
||
592 |
(aTime species == self species) ifFalse:[^ false]. |
|
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
593 |
^ (self getMilliseconds = aTime getMilliseconds) |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
594 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
595 |
"Modified: 3.7.1996 / 13:10:24 / cg" |
699 | 596 |
! |
597 |
||
598 |
> aTime |
|
599 |
"return true if the argument, aTime is after the receiver" |
|
600 |
||
1501 | 601 |
^ self getMilliseconds > aTime getMilliseconds |
699 | 602 |
|
1501 | 603 |
"Modified: 1.7.1996 / 15:24:38 / cg" |
699 | 604 |
! |
605 |
||
606 |
hash |
|
607 |
"return an integer useful for hashing on times" |
|
608 |
||
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
609 |
^ osTime // 1000 |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
610 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
611 |
"Modified: 3.7.1996 / 13:10:52 / cg" |
699 | 612 |
! ! |
613 |
||
614 |
!AbsoluteTime methodsFor:'converting'! |
|
615 |
||
616 |
asAbsoluteTime |
|
617 |
"return an AbsoluteTime object from the receiver - thats the receiver." |
|
618 |
||
619 |
^ self |
|
620 |
! |
|
621 |
||
622 |
asDate |
|
623 |
"return a Date object from the receiver. |
|
624 |
The returned date will only represent the day - not the timeOfDay." |
|
625 |
||
626 |
^ Date fromOSTime:osTime |
|
627 |
||
628 |
" |
|
629 |
AbsoluteTime now |
|
630 |
AbsoluteTime now asDate |
|
631 |
(AbsoluteTime now addTime:3600) asDate |
|
632 |
(AbsoluteTime now addTime:3600) asTime |
|
633 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
634 |
(AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate |
|
635 |
" |
|
636 |
||
637 |
! |
|
638 |
||
639 |
asSeconds |
|
640 |
"return the number of seconds elapsed since whatever time the |
|
641 |
OperatingSystem bases its time upon. Since this is totally |
|
642 |
OS-dependent, do not interpret the value returned by this method. |
|
643 |
You can use it to add/subtract seconds or get time deltas, though." |
|
644 |
||
645 |
^ self getSeconds |
|
646 |
||
647 |
" |
|
648 |
AbsoluteTime now asSeconds |
|
649 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
650 |
Time hour:23 minutes:33 seconds:0 |
|
651 |
Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) |
|
652 |
" |
|
653 |
! |
|
654 |
||
655 |
asTime |
|
656 |
"return a Time object from the receiver. |
|
657 |
The returned time will only represent the timeOfDay - not the day." |
|
658 |
||
659 |
^ Time fromOSTime:osTime |
|
660 |
||
661 |
" |
|
662 |
AbsoluteTime now |
|
663 |
AbsoluteTime now asTime |
|
664 |
(AbsoluteTime now addTime:3600) asTime |
|
665 |
" |
|
666 |
! ! |
|
667 |
||
213 | 668 |
!AbsoluteTime methodsFor:'printing & storing'! |
30 | 669 |
|
4843 | 670 |
addPrintBindingsTo:dict |
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
671 |
|d m y s| |
4843 | 672 |
|
673 |
OperatingSystem computeDatePartsOf:osTime for:[ |
|
674 |
:year :month :day | d := day. m := month. y := year. |
|
675 |
]. |
|
676 |
super addPrintBindingsTo:dict. |
|
677 |
dict at:#day put:(d printString leftPaddedTo:2 with:$0). |
|
678 |
dict at:#dayInWeek put:(self dayInWeek). |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
679 |
dict at:#month put:(s := m printString leftPaddedTo:2 with:$0). |
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
680 |
dict at:#mon put:s. "/ for backward compatibility only |
4843 | 681 |
dict at:#year put:(y printString leftPaddedTo:4 with:$0). |
682 |
||
683 |
dict at:#Day put:d printString. |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
684 |
dict at:#Month put:(s := m printString). |
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
685 |
dict at:#Mon put:s. "/ for backward compatibility only |
4843 | 686 |
|
687 |
" |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
688 |
AbsoluteTime now printOn:Transcript format:'%(day):%(month)'. Transcript cr. |
4843 | 689 |
AbsoluteTime now printOn:Transcript format:'%(dayInWeek)'. Transcript cr. |
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
690 |
AbsoluteTime now printOn:Transcript format:'%(Day)-%(month)-%(year) %h:%m:%s.%i'. Transcript cr. |
4843 | 691 |
AbsoluteTime now printOn:Transcript. Transcript cr |
692 |
" |
|
693 |
||
694 |
||
695 |
||
696 |
! |
|
697 |
||
5290 | 698 |
printGeneralizedOn:aStream |
699 |
"append a representation of the receiver to aStream in a general format, |
|
700 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
|
701 |
This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33, |
|
702 |
so read this before changing the output format." |
|
703 |
||
704 |
|t off| |
|
705 |
||
706 |
t := OperatingSystem computeTimeAndDateFrom:osTime. |
|
707 |
||
708 |
(t at:1) printOn:aStream leftPaddedTo:4 with:$0. |
|
709 |
(t at:2) printOn:aStream leftPaddedTo:2 with:$0. |
|
710 |
(t at:3) printOn:aStream leftPaddedTo:2 with:$0. |
|
711 |
(t at:4) printOn:aStream leftPaddedTo:2 with:$0. |
|
712 |
(t at:5) printOn:aStream leftPaddedTo:2 with:$0. |
|
713 |
(t at:6) printOn:aStream leftPaddedTo:2 with:$0. |
|
714 |
aStream nextPut:$.. |
|
715 |
(t at:9) printOn:aStream leftPaddedTo:3 with:$0. |
|
716 |
||
717 |
off := t at:7. |
|
718 |
off == 0 ifTrue:[ |
|
719 |
aStream nextPut:$Z. |
|
720 |
] ifFalse:[ |min| |
|
721 |
off < 0 ifTrue:[ |
|
722 |
aStream nextPut:$+. |
|
723 |
off := off negated. |
|
724 |
] ifFalse:[ |
|
725 |
aStream nextPut:$-. |
|
726 |
]. |
|
727 |
min := off // 60. |
|
728 |
min // 60 printOn:aStream leftPaddedTo:2 with:$0. |
|
729 |
min \\ 60 printOn:aStream leftPaddedTo:2 with:$0. |
|
730 |
]. |
|
731 |
||
732 |
||
733 |
||
734 |
" |
|
735 |
AbsoluteTime now asn1PrintOn:Transcript. Transcript cr. |
|
736 |
(AbsoluteTime fromSeconds:0) asn1PrintOn:Transcript. Transcript cr. |
|
737 |
Time now printOn:Transcript. Transcript cr. |
|
738 |
Date today printOn:Transcript. Transcript cr. |
|
739 |
||
740 |
Time now asAbsoluteTime asn1PrintOn:Transcript. Transcript cr. |
|
741 |
AbsoluteTime now asn1PrintOn:Transcript. Transcript cr. |
|
742 |
||
743 |
Date today asAbsoluteTime asn1PrintOn:Transcript. Transcript cr. |
|
744 |
Date today printOn:Transcript. Transcript cr. |
|
745 |
" |
|
746 |
||
747 |
"Modified: / 1.7.1996 / 15:20:59 / cg" |
|
748 |
"Modified: / 17.1.2000 / 15:53:02 / stefan" |
|
749 |
! |
|
750 |
||
241 | 751 |
printOn:aStream |
275 | 752 |
"append a user readable representation of the receiver to aStream. |
753 |
The format is compatible with readFromString:, but not with readFrom:." |
|
754 |
||
4843 | 755 |
self printOn:aStream format:'%(Day)-%(mon)-%(year) %h:%m:%s.%i' |
92 | 756 |
|
757 |
" |
|
275 | 758 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
759 |
(AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr. |
|
760 |
Time now printOn:Transcript. Transcript cr. |
|
761 |
Date today printOn:Transcript. Transcript cr. |
|
1501 | 762 |
|
763 |
Time now asAbsoluteTime printOn:Transcript. Transcript cr. |
|
764 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
|
765 |
||
766 |
Date today asAbsoluteTime printOn:Transcript. Transcript cr. |
|
767 |
Date today printOn:Transcript. Transcript cr. |
|
92 | 768 |
" |
1501 | 769 |
|
770 |
"Modified: 1.7.1996 / 15:20:59 / cg" |
|
30 | 771 |
! |
772 |
||
241 | 773 |
storeOn:aStream |
275 | 774 |
"store the receiver in a format suitable for reconstruction of the |
775 |
receiver via readFrom:" |
|
776 |
||
241 | 777 |
aStream nextPut:$(; |
242 | 778 |
nextPutAll:self class name; |
275 | 779 |
nextPutAll:' new setSeconds:'. |
780 |
self getSeconds storeOn:aStream. |
|
241 | 781 |
aStream nextPut:$). |
54 | 782 |
|
241 | 783 |
" |
275 | 784 |
AbsoluteTime now storeString |
30 | 785 |
|
275 | 786 |
AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream |
241 | 787 |
" |
30 | 788 |
! ! |
699 | 789 |
|
790 |
!AbsoluteTime methodsFor:'private'! |
|
791 |
||
1501 | 792 |
fromOSTime:anUninterpretedOSTime |
699 | 793 |
"strictly private: set the seconds from an OS time (since whatever)" |
794 |
||
1501 | 795 |
osTime := anUninterpretedOSTime |
796 |
||
797 |
"Created: 1.7.1996 / 14:33:21 / cg" |
|
798 |
! |
|
799 |
||
800 |
getMilliseconds |
|
801 |
"strictly private: return the milliseconds (since whatever)" |
|
802 |
||
803 |
^ osTime |
|
804 |
||
805 |
"Created: 1.7.1996 / 14:33:56 / cg" |
|
699 | 806 |
! |
807 |
||
808 |
getSeconds |
|
809 |
"strictly private: return the seconds (since whatever)" |
|
810 |
||
1501 | 811 |
^ osTime // 1000 |
812 |
||
813 |
"Modified: 1.7.1996 / 14:33:44 / cg" |
|
699 | 814 |
! |
815 |
||
1501 | 816 |
setMilliseconds:millis |
817 |
"strictly private: set the milliseconds (since whatever)" |
|
818 |
||
819 |
osTime := millis. |
|
820 |
||
821 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
822 |
"Created: 1.7.1996 / 14:34:24 / cg" |
|
823 |
! |
|
824 |
||
699 | 825 |
setSeconds:secs |
826 |
"strictly private: set the seconds (since whatever)" |
|
827 |
||
1501 | 828 |
osTime := secs * 1000. |
795 | 829 |
|
830 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1501 | 831 |
"Modified: 1.7.1996 / 14:34:10 / cg" |
699 | 832 |
! ! |
833 |
||
5290 | 834 |
|
2311 | 835 |
!AbsoluteTime class methodsFor:'documentation'! |
699 | 836 |
|
837 |
version |
|
5290 | 838 |
^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.47 2000-03-02 17:21:57 stefan Exp $' |
699 | 839 |
! ! |