8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 'From Smalltalk/X, Version:2.10.4 on 8-feb-1995 at 12:46:41 pm'! |
|
14 |
|
15 AbstractTime subclass:#Time |
13 AbstractTime subclass:#Time |
16 instanceVariableNames:'timeEncoding' |
14 instanceVariableNames:'timeEncoding' |
17 classVariableNames:'' |
15 classVariableNames:'' |
18 poolDictionaries:'' |
16 poolDictionaries:'' |
19 category:'Magnitude-General' |
17 category:'Magnitude-General' |
118 "Modified: 16.11.1995 / 22:51:20 / cg" |
112 "Modified: 16.11.1995 / 22:51:20 / cg" |
119 ! ! |
113 ! ! |
120 |
114 |
121 !Time methodsFor:'accessing'! |
115 !Time methodsFor:'accessing'! |
122 |
116 |
|
117 day |
|
118 "catch day access - Time does not know about it" |
|
119 |
|
120 ^ self shouldNotImplement |
|
121 ! |
|
122 |
|
123 hours |
|
124 "return the number of hours since midnight (i.e. 0..23)" |
|
125 |
|
126 ^ timeEncoding // 3600 |
|
127 |
|
128 " |
|
129 Time now hours |
|
130 " |
|
131 ! |
|
132 |
123 minutes |
133 minutes |
124 "return the number of minutes within the hour (i.e. 0..59)" |
134 "return the number of minutes within the hour (i.e. 0..59)" |
125 |
135 |
126 ^ (timeEncoding \\ 3600) // 60 |
136 ^ (timeEncoding \\ 3600) // 60 |
127 |
137 |
128 " |
138 " |
129 Time now minutes |
139 Time now minutes |
130 " |
140 " |
131 ! |
141 ! |
132 |
142 |
|
143 month |
|
144 "catch month access - Time does not know about it" |
|
145 |
|
146 ^ self shouldNotImplement |
|
147 ! |
|
148 |
133 seconds |
149 seconds |
134 "return the number of seconds within the minute (i.e. 0..59)" |
150 "return the number of seconds within the minute (i.e. 0..59)" |
135 |
151 |
136 ^ (timeEncoding \\ 3600) \\ 60 |
152 ^ (timeEncoding \\ 3600) \\ 60 |
137 |
153 |
138 " |
154 " |
139 Time now seconds |
155 Time now seconds |
140 " |
156 " |
141 ! |
157 ! |
142 |
158 |
143 hours |
|
144 "return the number of hours since midnight (i.e. 0..23)" |
|
145 |
|
146 ^ timeEncoding // 3600 |
|
147 |
|
148 " |
|
149 Time now hours |
|
150 " |
|
151 ! |
|
152 |
|
153 day |
|
154 "catch day access - Time does not know about it" |
|
155 |
|
156 ^ self shouldNotImplement |
|
157 ! |
|
158 |
|
159 month |
|
160 "catch month access - Time does not know about it" |
|
161 |
|
162 ^ self shouldNotImplement |
|
163 ! |
|
164 |
|
165 year |
159 year |
166 "catch year access - Time does not know about it" |
160 "catch year access - Time does not know about it" |
167 |
161 |
168 ^ self shouldNotImplement |
162 ^ self shouldNotImplement |
169 ! ! |
163 ! ! |
170 |
164 |
|
165 !Time methodsFor:'comparing'! |
|
166 |
|
167 < aTime |
|
168 "return true if the argument, aTime is before the receiver" |
|
169 |
|
170 ^ timeEncoding < aTime timeEncoding |
|
171 ! |
|
172 |
|
173 = aTime |
|
174 "return true if the argument, aTime represents the same timeOfDay" |
|
175 |
|
176 aTime class == self class ifTrue:[ |
|
177 ^ timeEncoding == aTime timeEncoding |
|
178 ]. |
|
179 (aTime species == self species) ifFalse:[^ false]. |
|
180 ^ self asSeconds == aTime asSeconds |
|
181 ! |
|
182 |
|
183 > aTime |
|
184 "return true if the argument, aTime is after the receiver" |
|
185 |
|
186 ^ timeEncoding > aTime timeEncoding |
|
187 ! |
|
188 |
|
189 hash |
|
190 "return an integer useful for hashing on times" |
|
191 |
|
192 ^ timeEncoding |
|
193 ! ! |
|
194 |
|
195 !Time methodsFor:'converting'! |
|
196 |
|
197 asAbsoluteTime |
|
198 "return an AbsoluteTime object from the receiver. |
|
199 The date components are taken from today." |
|
200 |
|
201 |today| |
|
202 |
|
203 today := Date today. |
|
204 ^ AbsoluteTime day:today day month:today month year:today year |
|
205 hour:self hours minutes:self minutes seconds:self seconds |
|
206 " |
|
207 Time now asAbsoluteTime |
|
208 " |
|
209 ! |
|
210 |
|
211 asSeconds |
|
212 "return the number of seconds elapsed since midnight" |
|
213 |
|
214 ^ timeEncoding |
|
215 |
|
216 " |
|
217 Time now asSeconds |
|
218 " |
|
219 ! |
|
220 |
|
221 asTime |
|
222 "return a Time object from the receiver - thats the receiver." |
|
223 |
|
224 ^ self |
|
225 ! ! |
|
226 |
171 !Time methodsFor:'printing & storing'! |
227 !Time methodsFor:'printing & storing'! |
172 |
|
173 printOn:aStream |
|
174 "append a printed representation of the receiver to aStream. |
|
175 Format is hh:mm:ss either in 12-hour or 24-hour format. |
|
176 depending on the setting of LanguageTerritory. |
|
177 I dont know what ST-80 does here (12-hour format ?)" |
|
178 |
|
179 LanguageTerritory = 'usa' ifTrue:[ |
|
180 self print12HourFormatOn:aStream |
|
181 ] ifFalse:[ |
|
182 self print24HourFormatOn:aStream |
|
183 ] |
|
184 |
|
185 " |
|
186 Time now printOn:Transcript. Transcript cr |
|
187 " |
|
188 ! |
|
189 |
|
190 print24HourFormatOn:aStream |
|
191 "append a printed representation of the receiver to aStream. |
|
192 Format is hh:mm:ss (i.e. 24-hour european format)." |
|
193 |
|
194 |h m s| |
|
195 |
|
196 h := self hours. |
|
197 (h < 10) ifTrue:[aStream nextPut:$0]. |
|
198 h printOn:aStream. |
|
199 aStream nextPut:$:. |
|
200 m := self minutes. |
|
201 (m < 10) ifTrue:[aStream nextPut:$0]. |
|
202 m printOn:aStream. |
|
203 aStream nextPut:$:. |
|
204 s := self seconds. |
|
205 (s < 10) ifTrue:[aStream nextPut:$0]. |
|
206 s printOn:aStream |
|
207 |
|
208 " |
|
209 Time now print24HourFormatOn:Transcript. Transcript cr |
|
210 " |
|
211 ! |
|
212 |
228 |
213 print12HourFormatOn:aStream |
229 print12HourFormatOn:aStream |
214 "append a printed representation of the receiver to aStream. |
230 "append a printed representation of the receiver to aStream. |
215 Format is hh:mm:ss am/pm (i.e. 12-hour american format)." |
231 Format is hh:mm:ss am/pm (i.e. 12-hour american format)." |
216 |
232 |
241 aStream nextPutAll:ampm |
257 aStream nextPutAll:ampm |
242 |
258 |
243 " |
259 " |
244 Time now print12HourFormatOn:Transcript. Transcript cr |
260 Time now print12HourFormatOn:Transcript. Transcript cr |
245 " |
261 " |
246 ! ! |
262 ! |
247 |
263 |
248 !Time methodsFor:'converting'! |
264 print24HourFormatOn:aStream |
249 |
265 "append a printed representation of the receiver to aStream. |
250 asSeconds |
266 Format is hh:mm:ss (i.e. 24-hour european format)." |
251 "return the number of seconds elapsed since midnight" |
267 |
252 |
268 |h m s| |
253 ^ timeEncoding |
269 |
254 |
270 h := self hours. |
255 " |
271 (h < 10) ifTrue:[aStream nextPut:$0]. |
256 Time now asSeconds |
272 h printOn:aStream. |
257 " |
273 aStream nextPut:$:. |
258 ! |
274 m := self minutes. |
259 |
275 (m < 10) ifTrue:[aStream nextPut:$0]. |
260 asTime |
276 m printOn:aStream. |
261 "return a Time object from the receiver - thats the receiver." |
277 aStream nextPut:$:. |
262 |
278 s := self seconds. |
263 ^ self |
279 (s < 10) ifTrue:[aStream nextPut:$0]. |
264 ! |
280 s printOn:aStream |
265 |
281 |
266 asAbsoluteTime |
282 " |
267 "return an AbsoluteTime object from the receiver. |
283 Time now print24HourFormatOn:Transcript. Transcript cr |
268 The date components are taken from today." |
284 " |
269 |
285 ! |
270 |today| |
286 |
271 |
287 printOn:aStream |
272 today := Date today. |
288 "append a printed representation of the receiver to aStream. |
273 ^ AbsoluteTime day:today day month:today month year:today year |
289 Format is hh:mm:ss either in 12-hour or 24-hour format. |
274 hour:self hours minutes:self minutes seconds:self seconds |
290 depending on the setting of LanguageTerritory. |
275 " |
291 I dont know what ST-80 does here (12-hour format ?)" |
276 Time now asAbsoluteTime |
292 |
277 " |
293 LanguageTerritory = 'usa' ifTrue:[ |
278 ! ! |
294 self print12HourFormatOn:aStream |
279 |
295 ] ifFalse:[ |
280 !Time methodsFor:'comparing'! |
296 self print24HourFormatOn:aStream |
281 |
297 ] |
282 > aTime |
298 |
283 "return true if the argument, aTime is after the receiver" |
299 " |
284 |
300 Time now printOn:Transcript. Transcript cr |
285 ^ timeEncoding > aTime timeEncoding |
301 " |
286 ! |
|
287 |
|
288 < aTime |
|
289 "return true if the argument, aTime is before the receiver" |
|
290 |
|
291 ^ timeEncoding < aTime timeEncoding |
|
292 ! |
|
293 |
|
294 = aTime |
|
295 "return true if the argument, aTime represents the same timeOfDay" |
|
296 |
|
297 aTime class == self class ifTrue:[ |
|
298 ^ timeEncoding == aTime timeEncoding |
|
299 ]. |
|
300 (aTime species == self species) ifFalse:[^ false]. |
|
301 ^ self asSeconds == aTime asSeconds |
|
302 ! |
|
303 |
|
304 hash |
|
305 "return an integer useful for hashing on times" |
|
306 |
|
307 ^ timeEncoding |
|
308 ! ! |
302 ! ! |
309 |
303 |
310 !Time methodsFor:'private'! |
304 !Time methodsFor:'private'! |
311 |
305 |
312 fromOSTimeLow:lowOSTime and:hiOSTime |
306 fromOSTimeLow:lowOSTime and:hiOSTime |
326 |
320 |
327 getSeconds |
321 getSeconds |
328 ^ timeEncoding |
322 ^ timeEncoding |
329 ! |
323 ! |
330 |
324 |
|
325 setHour:h minutes:m seconds:s |
|
326 "set my time given individual values" |
|
327 |
|
328 timeEncoding := ((h\\24) * 60 * 60 ) + (m * 60) + s. |
|
329 ! |
|
330 |
331 setSeconds:secs |
331 setSeconds:secs |
332 "set my time given seconds since midnight" |
332 "set my time given seconds since midnight" |
333 |
333 |
334 timeEncoding := secs |
334 timeEncoding := secs |
335 ! |
335 ! |
336 |
336 |
337 setHour:h minutes:m seconds:s |
337 timeEncoding |
338 "set my time given individual values" |
338 "the internal encoding is stricktly private, |
339 |
339 and should not be used outside." |
340 timeEncoding := ((h\\24) * 60 * 60 ) + (m * 60) + s. |
340 |
|
341 ^ timeEncoding |
341 ! |
342 ! |
342 |
343 |
343 timeEncoding:encoding |
344 timeEncoding:encoding |
344 "the internal encoding is stricktly private, |
345 "the internal encoding is stricktly private, |
345 and should not be used outside." |
346 and should not be used outside." |
346 |
347 |
347 timeEncoding := encoding |
348 timeEncoding := encoding |
348 ! |
349 ! ! |
349 |
350 |
350 timeEncoding |
351 !Time class methodsFor:'documentation'! |
351 "the internal encoding is stricktly private, |
352 |
352 and should not be used outside." |
353 version |
353 |
354 ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.23 1995-12-07 21:32:28 cg Exp $' |
354 ^ timeEncoding |
355 ! ! |
355 ! ! |
|