author | Claus Gittinger <cg@exept.de> |
Fri, 28 Jun 2019 08:49:56 +0200 | |
changeset 24385 | dd84e4dfb5cc |
parent 24118 | 02d39aaca894 |
child 25221 | 4fcb818b33a1 |
permissions | -rw-r--r-- |
22809 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
6165 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
6165 | 14 |
"{ Package: 'stx:libbasic' }" |
5390 | 15 |
|
17641 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
6165 | 18 |
AbstractTime subclass:#Time |
19 |
instanceVariableNames:'timeEncoding' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
7672 | 22 |
category:'Magnitude-Time' |
1 | 23 |
! |
24 |
||
6165 | 25 |
!Time class methodsFor:'documentation'! |
88 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
6165 | 30 |
All Rights Reserved |
88 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
Instances of time represent a particular time-of-day. |
|
409 | 44 |
Since they only store hours, minutes and seconds within a day, |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
45 |
they cannot be used to compare times across midnight |
409 | 46 |
(i.e. they should not be used as timeStamps). |
1228 | 47 |
|
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
48 |
Use instances of Timestamp (and read the comment there) to do this. |
241 | 49 |
|
13235 | 50 |
Time now returns the time in the local timezone. |
22839 | 51 |
Use Time utcNow to get the time in the UTC zone; |
52 |
bare in mind that, Time instances are not prepared and made for time zone aware |
|
53 |
time handling: always use Timestamp instances. |
|
54 |
||
55 |
Note: |
|
56 |
Time was changed recently to keep the number of milliseconds since midnight. |
|
57 |
However, all existing instance creators so far only create time instances with 0-millis. |
|
58 |
I.e. 'Time now' still returns a time with second precision. |
|
16940 | 59 |
|
22839 | 60 |
It is not done currently, to remain backward compatible, as users may get confused |
61 |
to see t1 > t2 although they print the same |
|
62 |
(as long as the printed representation does not include the milliseconds). |
|
16937 | 63 |
|
22839 | 64 |
On the other hand: |
65 |
a change of the default printformat is not done, |
|
66 |
as it may affect many existing applications. |
|
67 |
||
68 |
Any application which needs the millisecond precision time should call the new |
|
69 |
Time nowWithMilliseconds. |
|
16940 | 70 |
|
241 | 71 |
Examples: |
17641 | 72 |
|t| |
241 | 73 |
|
17641 | 74 |
t := Time now. |
75 |
Transcript showCR:t. |
|
241 | 76 |
|
77 |
||
17641 | 78 |
|t1 t2| |
241 | 79 |
|
17641 | 80 |
t1 := Time now. |
81 |
(Delay forSeconds:10) wait. |
|
82 |
t2 := Time now. |
|
83 |
t2 - t1 |
|
1295 | 84 |
|
85 |
[author:] |
|
17641 | 86 |
Claus Gittinger |
1295 | 87 |
|
88 |
[see also:] |
|
17641 | 89 |
Date Timestamp AbstractTime OperatingSystem |
90 |
Filename |
|
88 | 91 |
" |
92 |
! ! |
|
1 | 93 |
|
6165 | 94 |
!Time class methodsFor:'instance creation'! |
95 |
||
13603
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
96 |
fromString: aString |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
97 |
^ self readFrom: (ReadStream on: aString). |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
98 |
|
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
99 |
"Modified (format): / 20-08-2011 / 16:46:39 / cg" |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
100 |
! |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
101 |
|
8749 | 102 |
hour:h minute:m |
103 |
"compatibility" |
|
104 |
||
22038 | 105 |
<resource:#obsolete> |
106 |
||
107 |
self obsoleteMethodWarning:'use #hours:minutes:seconds:'. |
|
108 |
||
8749 | 109 |
^ self hours:h minutes:m seconds:0 |
110 |
||
111 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
112 |
Time hour:2 minute:33 |
8749 | 113 |
" |
22038 | 114 |
|
115 |
"Modified: / 17-07-2017 / 14:04:39 / cg" |
|
8749 | 116 |
! |
117 |
||
7818 | 118 |
hour:h minute:m second:s |
119 |
"compatibility" |
|
120 |
||
22038 | 121 |
<resource:#obsolete> |
122 |
||
123 |
self obsoleteMethodWarning:'use #hours:minutes:seconds:'. |
|
124 |
||
7818 | 125 |
^ self hours:h minutes:m seconds:s |
126 |
||
127 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
128 |
Time hour:2 minute:33 second:0 |
7818 | 129 |
" |
22038 | 130 |
|
131 |
"Modified: / 17-07-2017 / 14:04:34 / cg" |
|
7818 | 132 |
! |
133 |
||
6165 | 134 |
hour:h minutes:m seconds:s |
135 |
"return an instance of Time representing the given time. |
|
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
136 |
See also Time now / Date today / Timestamp now. |
6165 | 137 |
Obsolete: please use #hours:minutes:seconds:" |
138 |
||
139 |
<resource:#obsolete> |
|
140 |
||
9061 | 141 |
self obsoleteMethodWarning:'use #hours:minutes:seconds:'. |
6165 | 142 |
|
143 |
^ self hours:h minutes:m seconds:s |
|
144 |
||
145 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
146 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
147 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
148 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
149 |
Time hours23 minutes:59 seconds:59 |
6165 | 150 |
" |
151 |
||
152 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
153 |
! |
|
154 |
||
22038 | 155 |
hours:h minutes:m |
156 |
"return a new TimeDuration representing a duration of h hours and m minutes. |
|
157 |
See also Time now / Date today / Timestamp now." |
|
158 |
||
159 |
^ self basicNew setHours:h minutes:m seconds:0 milliseconds:0 |
|
160 |
||
161 |
" |
|
162 |
TimeDuration hours:2 minutes:33 |
|
163 |
TimeDuration hours:100 minutes:33 |
|
164 |
" |
|
165 |
! |
|
166 |
||
6165 | 167 |
hours:h minutes:m seconds:s |
4031 | 168 |
"return an instance of Time representing the given time. |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
169 |
See also Time now / Date today / Timestamp now." |
4031 | 170 |
|
6165 | 171 |
^ self basicNew setHours:h minutes:m seconds:s |
4031 | 172 |
|
173 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
174 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
175 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
176 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
177 |
Time hours:23 minutes:59 seconds:59 |
95 | 178 |
" |
6165 | 179 |
|
180 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
181 |
! |
|
182 |
||
16937 | 183 |
hours:h minutes:m seconds:s milliseconds:ms |
184 |
"return an instance of Time representing the given time. |
|
185 |
See also Time now / Date today / Timestamp now." |
|
186 |
||
187 |
^ self basicNew setHours:h minutes:m seconds:s milliseconds:ms |
|
188 |
||
189 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
190 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
191 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
192 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
193 |
Time hours:23 minutes:59 seconds:59 |
16937 | 194 |
" |
195 |
||
196 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
197 |
! |
|
198 |
||
7293 | 199 |
midnight |
200 |
"Answer a new instance at midnight." |
|
201 |
||
13235 | 202 |
^ self fromSeconds: 0 |
7293 | 203 |
|
204 |
" |
|
205 |
Time midnight |
|
206 |
" |
|
207 |
! |
|
208 |
||
209 |
noon |
|
210 |
"Answer a new instance at noon." |
|
211 |
||
13235 | 212 |
^ self fromSeconds: 43200 "12*60*60" |
7293 | 213 |
|
214 |
" |
|
215 |
Time noon |
|
216 |
" |
|
217 |
! |
|
218 |
||
18456 | 219 |
readFrom:aStringOrStream format:formatString language:languageOrNil onError:exceptionalValue |
220 |
"return a new Time, reading a printed representation from aStream using a formatString. |
|
221 |
The formatString is similar to the one used when printing. |
|
222 |
On error, exceptionalValue is returned. |
|
223 |
If exceptionalValue is a one-arg block, an error message is passed as argument. |
|
224 |
Format: |
|
225 |
%h hours, 00..23 (i.e. european) 0-padded to length 2 |
|
226 |
%u hours, 00..12 (i.e. us) 0-padded to length 2 |
|
227 |
%m minutes, 00..59 0-padded to length 2 |
|
228 |
%s seconds, 00..59 0-padded to length 2 |
|
229 |
%i milliseconds, 000..999 0-padded to length 3 |
|
19922 | 230 |
%f fractional seconds any length, but only milliseconds are read |
18456 | 231 |
%a am/pm |
232 |
||
233 |
an optional length after the % gives a field length; |
|
234 |
i.e. %2h%2m%2s parses '123557' as 12:35:37 |
|
235 |
||
236 |
Please consider using a standard format, such as iso8601. |
|
237 |
" |
|
238 |
||
239 |
|hour minute second millisecond |
|
240 |
utcOffset inStream formatStream error fChar format itemHandler |
|
19922 | 241 |
len s fraction fractionString| |
18456 | 242 |
|
243 |
error := [:msg | |
|
244 |
exceptionalValue isBlock ifTrue:[ |
|
245 |
^ exceptionalValue valueWithOptionalArgument:'format error' |
|
246 |
] ifFalse:[ |
|
247 |
^ exceptionalValue value |
|
248 |
]. |
|
249 |
]. |
|
250 |
||
251 |
itemHandler := [:format | |
|
252 |
|input| |
|
253 |
||
254 |
input := len isNil ifTrue:[ inStream ] ifFalse:[ inStream next: len ]. |
|
255 |
||
256 |
( format = 'h' or:[ format = 'H' ]) ifTrue:[ |
|
257 |
hour := Integer readFrom:input onError:[ error value:'invalid hour' ]. |
|
258 |
||
259 |
] ifFalse:[ ( format = 'u' or:[ format = 'U']) ifTrue:[ |
|
260 |
hour := Integer readFrom:input onError:[ error value:'invalid hour' ]. |
|
261 |
||
262 |
] ifFalse:[ ( format = 'm' or:[ format = 'M' ]) ifTrue:[ |
|
263 |
minute := Integer readFrom:input onError:[ error value:'invalid minute' ]. |
|
264 |
||
265 |
] ifFalse:[ ( format = 's' or:[ format = 'S' ]) ifTrue:[ |
|
266 |
second := Integer readFrom:input onError:[ error value:'invalid second' ]. |
|
267 |
||
268 |
] ifFalse:[ ( format = 'i' or:[ format = 'I' ]) ifTrue:[ |
|
269 |
millisecond := Integer readFrom:input onError:[ error value:'invalid millsecond' ]. |
|
270 |
||
19922 | 271 |
] ifFalse:[ ( format = 'f' or:[ format = 'F' ]) ifTrue:[ |
272 |
fractionString := input upToMatching:[:ch | ch isDigit not]. |
|
273 |
fraction := FixedPoint readFrom:'0.',fractionString. |
|
274 |
millisecond := (fraction * 1000) truncated. |
|
18456 | 275 |
] ifFalse:[ ( format = 'tz' ) ifTrue:[ |
276 |
utcOffset := Timestamp utcOffsetFrom:input. |
|
277 |
utcOffset isNil ifTrue:[ error value:'invalid timezone' ] |
|
278 |
] ifFalse:[ ( format = 'a' ) ifTrue:[ |
|
279 |
s := (input next:2) asLowercase. |
|
280 |
s = 'am' ifTrue:[ |
|
281 |
(hour between:0 and:12) ifFalse:[ error value:'invalid hour' ] |
|
282 |
] ifFalse:[ |
|
283 |
s = 'pm' ifTrue:[ |
|
284 |
(hour between:1 and:12) ifFalse:[ error value:'invalid hour' ]. |
|
285 |
hour := hour + 12. |
|
286 |
] ifFalse:[ |
|
287 |
error value:'invalid am/pm' |
|
288 |
] |
|
289 |
] |
|
290 |
||
291 |
] ifFalse:[ |
|
292 |
error value:'unhandled format:',format |
|
19922 | 293 |
]]]]]]]] |
18456 | 294 |
]. |
295 |
||
296 |
hour := 0. |
|
297 |
minute := 0. |
|
298 |
second := 0. |
|
299 |
millisecond := 0. |
|
300 |
utcOffset := 0. |
|
301 |
||
302 |
inStream := aStringOrStream readStream. |
|
303 |
formatStream := formatString readStream. |
|
304 |
||
305 |
[formatStream atEnd] whileFalse:[ |
|
306 |
fChar := formatStream next. |
|
307 |
fChar = Character space ifTrue:[ |
|
308 |
inStream peek isSeparator ifFalse:[ error value: 'format error; space expcected' ]. |
|
309 |
inStream skipSeparators. |
|
310 |
] ifFalse:[ |
|
311 |
fChar == $% ifTrue:[ |
|
312 |
len := nil. |
|
313 |
(formatStream peek isDigit) ifTrue:[ |
|
314 |
len := Integer readFrom:formatStream onError:[ error value: 'format error; invalid length' ] |
|
315 |
]. |
|
316 |
(formatStream peek == $() ifTrue:[ |
|
317 |
formatStream next. |
|
318 |
format := formatStream upTo:$). |
|
319 |
] ifFalse:[ |
|
320 |
(formatStream peek == ${) ifTrue:[ |
|
321 |
formatStream next. |
|
322 |
format := formatStream upTo:$}. |
|
323 |
] ifFalse:[ |
|
324 |
(formatStream peek isLetter) ifTrue:[ |
|
325 |
format := formatStream nextAlphaNumericWord. |
|
326 |
] ifFalse:[ |
|
327 |
error value:'unhandled format:',formatStream peek |
|
328 |
] |
|
329 |
] |
|
330 |
]. |
|
331 |
itemHandler value:format. |
|
332 |
] ifFalse:[ |
|
333 |
inStream peek = fChar ifFalse:[^ error value: 'format error; ',fChar,' expcected']. |
|
334 |
inStream next. |
|
335 |
] |
|
336 |
]. |
|
337 |
]. |
|
338 |
||
339 |
^ (self |
|
340 |
hours:(hour ? 0) minutes:(minute ? 0) seconds:(second ? 0) milliseconds:millisecond) |
|
341 |
+ utcOffset |
|
342 |
||
343 |
" |
|
344 |
Time readFrom:'13:11:06' format:'%h:%m:%s' language:nil onError:[self halt] |
|
345 |
Time readFrom:'131106' format:'%2h%2m%2s' language:nil onError:[self halt] |
|
346 |
Time readFrom:'7:30pm EST' format:'%u:%m%a %tz' language:#en onError:[self halt] |
|
347 |
Time readFrom:'7:30pm UTC' format:'%u:%m%a %tz' language:#en onError:[self halt] |
|
19922 | 348 |
|
349 |
Time readFrom:'13:11:06.111' format:'%h:%m:%s.%i' language:nil onError:[self halt] |
|
350 |
Time readFrom:'13:11:06.1' format:'%h:%m:%s.%f' language:nil onError:[self halt] |
|
351 |
Time readFrom:'13:11:06.01' format:'%h:%m:%s.%f' language:nil onError:[self halt] |
|
352 |
Time readFrom:'13:11:06.001' format:'%h:%m:%s.%f' language:nil onError:[self halt] |
|
353 |
Time readFrom:'13:11:06.1234567' format:'%h:%m:%s.%f' language:nil onError:[self halt] |
|
18456 | 354 |
" |
355 |
! |
|
356 |
||
6165 | 357 |
readFrom:aStringOrStream onError:exceptionBlock |
358 |
"return a new Time, reading a printed representation from aStream. |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
359 |
If no am/pm follows the time, the string is interpreted as |
6165 | 360 |
either 24 hour format or being am." |
361 |
||
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6467
diff
changeset
|
362 |
^ [ |
20818 | 363 |
|str hour min sec peekC millis| |
6165 | 364 |
|
20818 | 365 |
str := aStringOrStream readStream. |
6165 | 366 |
|
20818 | 367 |
hour := Integer readFrom:str. |
368 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
|
6165 | 369 |
|
20818 | 370 |
min := 0. |
371 |
sec := 0. |
|
372 |
millis := 0. |
|
16940 | 373 |
|
20818 | 374 |
str atEnd ifFalse:[ |
375 |
peekC := str peek. |
|
376 |
(peekC == $:) ifTrue:[ |
|
377 |
str next. |
|
378 |
min := Integer readFrom:str. |
|
379 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
|
6165 | 380 |
|
20818 | 381 |
(str peek == $:) ifTrue:[ |
382 |
str next. |
|
383 |
sec := Integer readFrom:str. |
|
384 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
|
385 |
(str peek == $.) ifTrue:[ |
|
386 |
str next. |
|
387 |
millis := ((Fraction readDecimalFractionFrom:str onError:[^ exceptionBlock value]) * 1000) asInteger. |
|
388 |
]. |
|
389 |
]. |
|
390 |
peekC := str peek. |
|
391 |
]. |
|
392 |
[peekC == Character space] whileTrue:[str next. peekC := str peek]. |
|
393 |
(peekC == $p or:[peekC == $P]) ifTrue:[ |
|
394 |
str next. |
|
395 |
(str peek == $m or:[str peek == $M]) ifTrue:[ |
|
396 |
str next |
|
397 |
]. |
|
398 |
(hour <= 0 or:[hour > 12]) ifTrue:[^ exceptionBlock value]. |
|
6165 | 399 |
|
20818 | 400 |
"pm" |
401 |
hour ~~ 12 ifTrue:[ |
|
402 |
hour := hour + 12 |
|
403 |
]. |
|
404 |
peekC := str peek |
|
405 |
] ifFalse:[ |
|
406 |
(peekC == $a or:[peekC == $A]) ifTrue:[ |
|
407 |
str next. |
|
408 |
(str peek == $m or:[str peek == $M]) ifTrue:[ |
|
409 |
str next |
|
410 |
]. |
|
411 |
hour == 12 ifTrue:[ |
|
412 |
hour := 0. |
|
413 |
]. |
|
414 |
hour > 12 ifTrue:[^ exceptionBlock value]. |
|
415 |
peekC := str peek |
|
416 |
] ifFalse:[ |
|
417 |
"/ cg: don't be too picky here - we do not care, what comes after the |
|
418 |
"/ time string. (Needed to be able to read rfc822 strings where a timezone |
|
419 |
"/ follows (-/+0700 GMT, for example) |
|
11809
efca8cccc66b
time reading: do not insist on peek-char to be a separator after the
Claus Gittinger <cg@exept.de>
parents:
11308
diff
changeset
|
420 |
"/ peekC notNil ifTrue:[ |
efca8cccc66b
time reading: do not insist on peek-char to be a separator after the
Claus Gittinger <cg@exept.de>
parents:
11308
diff
changeset
|
421 |
"/ peekC isSeparator ifFalse:[^ exceptionBlock value]. |
efca8cccc66b
time reading: do not insist on peek-char to be a separator after the
Claus Gittinger <cg@exept.de>
parents:
11308
diff
changeset
|
422 |
"/ ] |
20818 | 423 |
]. |
424 |
] |
|
425 |
]. |
|
426 |
self basicNew setHours:hour minutes:min seconds:sec milliseconds:millis |
|
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6467
diff
changeset
|
427 |
] on:Error do:exceptionBlock. |
6165 | 428 |
|
429 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
430 |
Time readFrom:'0:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
431 |
Time readFrom:'2:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
432 |
Time readFrom:'12:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
433 |
Time readFrom:'14:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
434 |
Time readFrom:'23:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
435 |
Time readFrom:'24:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
436 |
Time readFrom:'2:30 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
437 |
Time readFrom:'2:30 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
438 |
Time readFrom:'14' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
439 |
Time readFrom:'2 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
440 |
Time readFrom:'2 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
441 |
Time readFrom:'12:05 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
442 |
Time readFrom:'12:06 am' |
6165 | 443 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
444 |
Time readFrom:'18:22:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
445 |
Time readFrom:'14:00:11' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
446 |
Time readFrom:'7:00:11' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
447 |
Time readFrom:'24:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
448 |
Time readFrom:'0:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
449 |
Time readFrom:'12:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
450 |
Time readFrom:'0:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
451 |
Time readFrom:'6:22:00 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
452 |
Time readFrom:'2:00:11 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
453 |
Time readFrom:'7:00:11 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
454 |
Time readFrom:'12:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
455 |
Time readFrom:'0:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
456 |
Time readFrom:'24:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
457 |
Time readFrom:'12:00:00 pm' |
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6467
diff
changeset
|
458 |
Time readFrom:'0:00:00 pm' onError:'invalid' |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
459 |
Time readFrom:'24:00:00 pm' |
16940 | 460 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
461 |
Time readFrom:'13:00:00.5' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
462 |
Time readFrom:'13:00:00.123' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
463 |
Time readFrom:'1:00:00.123 pm' |
6165 | 464 |
" |
465 |
||
466 |
"Modified: 8.10.1996 / 19:32:11 / cg" |
|
13235 | 467 |
! |
468 |
||
469 |
utcNow |
|
17136 | 470 |
"return an instance of myself representing this moment in UTC. |
471 |
That is, the current time in London without any daylight saving adjustments." |
|
13235 | 472 |
|
473 |
^ self basicNew fromUtcOSTime:(OperatingSystem getOSTime) |
|
474 |
||
475 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
476 |
Timestamp now |
13235 | 477 |
Timestamp utcNow |
478 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
479 |
Time now |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
480 |
Time utcNow |
13235 | 481 |
" |
482 |
||
483 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
22839 | 484 |
! |
485 |
||
486 |
utcNowWithMilliseconds |
|
487 |
"return an instance of myself representing this moment with at least millisecond precision." |
|
488 |
||
489 |
^ self basicNew fromUtcOSTimeWithMilliseconds:(OperatingSystem getOSTime) |
|
490 |
||
491 |
" |
|
492 |
Time now -> 01:05:10 PM |
|
493 |
Time nowWithMilliseconds -> 01:05:14.359 PM |
|
494 |
||
495 |
Time utcNow -> 11:05:16 AM |
|
496 |
Time utcNowWithMilliseconds -> 11:05:18.753 AM |
|
497 |
" |
|
498 |
||
499 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
1 | 500 |
! ! |
501 |
||
6165 | 502 |
!Time class methodsFor:'format strings'! |
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
503 |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
504 |
defaultFormatString |
16985 | 505 |
"a language specific format string to present times in user interfaces. |
506 |
Do not use this to store/retrieve times (use ISO8601 for that)" |
|
507 |
||
20614 | 508 |
Smalltalk languageTerritory == #us ifTrue:[ |
509 |
^ self formatString12us |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
510 |
] ifFalse:[ |
20614 | 511 |
^ self formatString24 |
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
512 |
] |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
513 |
|
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
514 |
"Created: / 16-01-2011 / 11:23:36 / cg" |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
515 |
! |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
516 |
|
16940 | 517 |
defaultFormatStringWithMilliseconds |
20614 | 518 |
Smalltalk languageTerritory == #us ifTrue:[ |
519 |
^ self formatStringWithMilliseconds12us |
|
16940 | 520 |
] ifFalse:[ |
20614 | 521 |
^ self formatStringWithMilliseconds24 |
16940 | 522 |
] |
523 |
! |
|
524 |
||
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
525 |
formatString12us |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
526 |
"return the format string used to format US times (and other areas)" |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
527 |
|
8231 | 528 |
^ '%u:%m:%s %A' |
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
529 |
! |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
530 |
|
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
531 |
formatString24 |
8231 | 532 |
"return the format string used to format non US times" |
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
533 |
|
6164 | 534 |
^ '%h:%m:%s' |
16940 | 535 |
! |
536 |
||
537 |
formatStringWithMilliseconds12us |
|
538 |
"return the format string used to format US times (and other areas)" |
|
539 |
||
16949 | 540 |
^ '%u:%m:%s.%i %A' |
16940 | 541 |
! |
542 |
||
543 |
formatStringWithMilliseconds24 |
|
544 |
"return the format string used to format non US times" |
|
545 |
||
546 |
^ '%h:%m:%s.%i' |
|
6164 | 547 |
! ! |
548 |
||
16981 | 549 |
!Time methodsFor:'Compatibility-Backward'! |
550 |
||
551 |
asMilliSeconds |
|
552 |
<resource: #obsolete> |
|
553 |
"return the number of milliseconds elapsed since midnight" |
|
554 |
||
555 |
^ self asMilliseconds |
|
6164 | 556 |
|
16981 | 557 |
" |
558 |
Time now asMilliSeconds |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
559 |
(TimeDuration days:1) asMilliSeconds |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
560 |
(TimeDuration hours:1) asMilliSeconds |
16981 | 561 |
" |
13632 | 562 |
|
16981 | 563 |
"Created: / 05-09-2011 / 10:40:15 / cg" |
564 |
! ! |
|
565 |
||
566 |
!Time methodsFor:'Compatibility-Squeak'! |
|
13632 | 567 |
|
6164 | 568 |
intervalString |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
569 |
"Treat the time as a difference. |
6164 | 570 |
Give it in hours and minutes with two digits of accuracy." |
571 |
||
6467 | 572 |
|hours minutes seconds hh mm ss s| |
6164 | 573 |
|
574 |
hours := self hours. |
|
575 |
minutes := self minutes. |
|
576 |
seconds := self seconds. |
|
6467 | 577 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
578 |
hours = 0 |
23790 | 579 |
ifTrue: [hh := ''] |
580 |
ifFalse: [ |
|
581 |
hh := hours printString, ' hour'. |
|
582 |
hours > 1 ifTrue:[ |
|
583 |
hh := hh , 's' |
|
584 |
] |
|
585 |
]. |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
586 |
minutes = 0 |
23790 | 587 |
ifTrue: [mm := ''] |
588 |
ifFalse: [ |
|
589 |
mm := minutes printString, ' minute'. |
|
590 |
minutes > 1 ifTrue:[ |
|
591 |
mm := mm , 's' |
|
592 |
] |
|
593 |
]. |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
594 |
seconds = 0 |
23790 | 595 |
ifTrue: [ss := ''] |
596 |
ifFalse: [ |
|
597 |
ss := seconds printString, ' second'. |
|
598 |
seconds > 1 ifTrue:[ |
|
599 |
ss := ss , 's' |
|
600 |
] |
|
601 |
]. |
|
6467 | 602 |
|
603 |
"/ do not show seconds, if hours are there |
|
23790 | 604 |
hh size ~~ 0 ifTrue: [ss := '']. |
6467 | 605 |
|
606 |
s := hh. |
|
6873 | 607 |
mm notEmpty ifTrue:[ |
23790 | 608 |
s notEmpty ifTrue:[ |
609 |
s := s , ' ' |
|
610 |
]. |
|
611 |
s := s , mm. |
|
6467 | 612 |
]. |
6873 | 613 |
ss notEmpty ifTrue:[ |
23790 | 614 |
s notEmpty ifTrue:[ |
615 |
s := s , ' ' |
|
616 |
]. |
|
617 |
s := s , ss |
|
6467 | 618 |
]. |
6873 | 619 |
^ s |
6164 | 620 |
|
621 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
622 |
(Time fromSeconds:3600) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
623 |
(Time fromSeconds:3605) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
624 |
(Time fromSeconds:3700) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
625 |
(Time fromSeconds:5) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
626 |
(Time fromSeconds:65) intervalString |
6164 | 627 |
" |
23790 | 628 |
|
629 |
"Modified: / 01-03-2019 / 16:14:41 / Claus Gittinger" |
|
6164 | 630 |
! |
631 |
||
7024 | 632 |
print24:prnt24FormatBoolean on:aStream |
633 |
"print me either US or 24hr format on a stream" |
|
634 |
||
635 |
^ self print24:prnt24FormatBoolean showSeconds:true on:aStream |
|
636 |
||
637 |
" |
|
638 |
Time now print24:true on:Transcript. Transcript cr. |
|
639 |
Time now print24:false on:Transcript. Transcript cr. |
|
640 |
" |
|
641 |
! |
|
642 |
||
6164 | 643 |
print24:prnt24Format showSeconds:doSeconds on:aStream |
644 |
"print me either US or 24hr format, optionally with |
|
645 |
seconds on a stream" |
|
646 |
||
647 |
|format| |
|
648 |
||
649 |
prnt24Format ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
650 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
651 |
format := '%h:%m:%s' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
652 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
653 |
format := '%h:%m' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
654 |
]. |
6164 | 655 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
656 |
"/ US format |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
657 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
658 |
format := '%u:%m:%s %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
659 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
660 |
format := '%u:%m %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
661 |
]. |
6164 | 662 |
]. |
663 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
664 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
665 |
format:format. |
6164 | 666 |
|
667 |
" |
|
668 |
Time now print24:true showSeconds:true on:Transcript. Transcript cr. |
|
669 |
Time now print24:false showSeconds:true on:Transcript. Transcript cr. |
|
670 |
Time now print24:true showSeconds:false on:Transcript. Transcript cr. |
|
671 |
Time now print24:false showSeconds:false on:Transcript. Transcript cr. |
|
672 |
" |
|
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
673 |
! ! |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
674 |
|
6164 | 675 |
!Time methodsFor:'accessing'! |
676 |
||
677 |
hours |
|
678 |
"return the number of hours since midnight (i.e. 0..23)" |
|
679 |
||
680 |
^ self getSeconds // 3600 |
|
681 |
||
682 |
" |
|
683 |
Time now hours |
|
684 |
" |
|
685 |
! |
|
275 | 686 |
|
4845 | 687 |
milliseconds |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
688 |
"get the milliseconds part |
16981 | 689 |
(notice: that is NOT the total number of millis (since midnight), |
19848 | 690 |
but the fractional part only. Use this only for printing. |
691 |
asMilliseconds or getMilliseconds is probably what you want" |
|
6164 | 692 |
|
16940 | 693 |
^ timeEncoding \\ 1000 |
6164 | 694 |
! |
695 |
||
696 |
minutes |
|
19848 | 697 |
"return the number of minutes within the hour (i.e. 0..59). |
698 |
(notice: that is NOT the total number of minutes (since midnight), |
|
699 |
but the fractional part only. Use this only for printing." |
|
6164 | 700 |
|
701 |
^ (self getSeconds \\ 3600) // 60 |
|
702 |
||
703 |
" |
|
704 |
Time now minutes |
|
705 |
" |
|
706 |
! |
|
707 |
||
708 |
seconds |
|
19848 | 709 |
"return the number of seconds within the minute (i.e. 0..59). |
710 |
(notice: that is NOT the total number of seconds (since midnight), |
|
711 |
but the fractional part only. Use this only for printing. |
|
712 |
asSeconds or getSeconds give you the nr of seconds since midnight" |
|
6164 | 713 |
|
7733 | 714 |
^ self getSeconds \\ 60 |
6164 | 715 |
|
716 |
" |
|
717 |
Time now seconds |
|
718 |
" |
|
719 |
! |
|
720 |
||
9441 | 721 |
timeZoneDeltaInMinutes |
722 |
"answer the number of minutes between local time and utc time. |
|
723 |
Delta is positive if local time is ahead of utc, negative if behind utc. |
|
724 |
||
16985 | 725 |
Time is local time, so ask a local timestamp" |
9441 | 726 |
|
727 |
^ Timestamp now timeZoneDeltaInMinutes |
|
728 |
||
729 |
||
730 |
" |
|
731 |
Time now timeZoneDeltaInMinutes |
|
732 |
" |
|
1 | 733 |
! ! |
734 |
||
6164 | 735 |
!Time methodsFor:'comparing'! |
736 |
||
737 |
hash |
|
738 |
"return an integer useful for hashing on times" |
|
739 |
||
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
740 |
^ timeEncoding |
6164 | 741 |
! ! |
742 |
||
743 |
!Time methodsFor:'converting'! |
|
744 |
||
13235 | 745 |
asLocalTimestamp |
746 |
"return an Timestamp object from the receiver. |
|
747 |
So I am interpreted as a Time in the local timezone. |
|
748 |
The date components are taken from today." |
|
749 |
||
750 |
|todayTimestamp| |
|
751 |
||
752 |
todayTimestamp := Timestamp now. |
|
22038 | 753 |
todayTimestamp |
754 |
year:todayTimestamp year |
|
755 |
month:todayTimestamp month |
|
756 |
day:todayTimestamp day |
|
757 |
hour:(self hours) |
|
758 |
minute:(self minutes) |
|
759 |
second:(self seconds) |
|
760 |
millisecond:(self milliseconds). |
|
13235 | 761 |
|
762 |
^ todayTimestamp. |
|
763 |
||
764 |
" |
|
765 |
Time now asLocalTimestamp |
|
766 |
" |
|
22038 | 767 |
|
768 |
"Modified (format): / 17-07-2017 / 14:07:27 / cg" |
|
769 |
! |
|
770 |
||
771 |
asTZTimestamp |
|
772 |
"return a TZTimestamp object from the receiver. |
|
773 |
This includes the local timezone information." |
|
774 |
||
775 |
^ self asLocalTimestamp asTZTimestamp. |
|
776 |
||
777 |
" |
|
778 |
Time now asTZTimestamp -> 2017-07-17 14:11:16+02 |
|
779 |
Time now asUtcTimestamp -> 2017-07-17 12:11:16Z |
|
780 |
Time now asLocalTimestamp -> 2017-07-17 14:11:16 |
|
781 |
" |
|
782 |
||
783 |
"Created: / 17-07-2017 / 14:11:14 / cg" |
|
13235 | 784 |
! |
785 |
||
699 | 786 |
asTime |
16981 | 787 |
"return a Time object from the receiver - that's the receiver." |
699 | 788 |
|
22038 | 789 |
self class == Time ifTrue:[ |
790 |
^ self |
|
791 |
]. |
|
792 |
^ super asTime |
|
793 |
||
794 |
"Modified: / 17-07-2017 / 14:06:53 / cg" |
|
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
795 |
! |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
796 |
|
8796 | 797 |
asTimeDuration |
798 |
"return an TimeDuration object from the receiver, taking the time since midnight." |
|
799 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
800 |
^ TimeDuration |
23618 | 801 |
hours:(self hours) minutes:(self minutes) seconds:(self seconds) |
802 |
milliseconds:(self milliseconds) |
|
8796 | 803 |
" |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
804 |
Time now asTimeDuration |
23618 | 805 |
10 asTimeDuration |
806 |
10 seconds asTimeDuration |
|
807 |
'10m 20s' asTimeDuration |
|
8796 | 808 |
" |
23618 | 809 |
|
810 |
"Modified (comment): / 21-01-2019 / 10:29:05 / Claus Gittinger" |
|
8796 | 811 |
! |
812 |
||
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
813 |
asTimestamp |
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
814 |
"return an Timestamp object from the receiver. |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
815 |
The date components are taken from today." |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
816 |
|
13235 | 817 |
^ self asLocalTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
818 |
|
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
819 |
" |
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
820 |
Time now asTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
821 |
" |
13235 | 822 |
! |
823 |
||
824 |
asUtcTimestamp |
|
825 |
"return an UtcTimestamp object from the receiver. |
|
826 |
So I am interpreted as a Time in the UTC zone. |
|
827 |
The date components are taken from today." |
|
828 |
||
22038 | 829 |
^ self asLocalTimestamp asUtcTimestamp. |
13235 | 830 |
|
831 |
" |
|
22038 | 832 |
Time now asTimestamp -> 2017-07-17 14:08:22 |
833 |
Time now asLocalTimestamp -> 2017-07-17 14:08:24 |
|
834 |
Time now asUtcTimestamp -> 2017-07-17 12:08:27Z |
|
13235 | 835 |
" |
22038 | 836 |
|
837 |
"Modified (comment): / 17-07-2017 / 14:09:45 / cg" |
|
699 | 838 |
! ! |
839 |
||
24118 | 840 |
!Time methodsFor:'double dispatching'! |
841 |
||
842 |
differenceFromTimestamp:aTimestamp |
|
843 |
"return the time difference as a timeDuration instance. |
|
844 |
Use only the time part of aTimestamp (so interpret it as a time today)." |
|
845 |
||
846 |
^ TimeDuration basicNew setMilliseconds:aTimestamp asTime getMilliseconds - self getMilliseconds. |
|
847 |
||
848 |
" |
|
849 |
Time nowWithMilliseconds differenceFromTimestamp:Timestamp now. |
|
850 |
Time now differenceFromTimestamp:Time now + 1 seconds |
|
851 |
" |
|
852 |
||
853 |
"Created: / 27-07-2018 / 11:23:37 / Stefan Vogel" |
|
854 |
"Modified (comment): / 08-05-2019 / 13:06:35 / Claus Gittinger" |
|
855 |
! ! |
|
856 |
||
6164 | 857 |
!Time methodsFor:'printing & storing'! |
858 |
||
859 |
print12HourFormatOn:aStream |
|
11151 | 860 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 861 |
Format is hh:mm:ss am/pm (i.e. 12-hour american format)." |
862 |
||
863 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
864 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
865 |
format:(self class formatString12us) |
6164 | 866 |
|
867 |
"/ |h m s ampm| |
|
868 |
"/ |
|
869 |
"/ h := self hours. |
|
870 |
"/ |
|
871 |
"/ "/ 0 -> 12 am |
|
872 |
"/ "/ 12 -> 12 pm |
|
873 |
"/ |
|
874 |
"/ h // 12 == 0 ifTrue:[ |
|
875 |
"/ ampm := ' am'. |
|
876 |
"/ ] ifFalse:[ |
|
877 |
"/ ampm := ' pm'. |
|
878 |
"/ ]. |
|
879 |
"/ |
|
880 |
"/ h == 0 ifFalse:[ |
|
881 |
"/ h := h - 1 \\ 12 + 1. |
|
882 |
"/ ]. |
|
883 |
"/ |
|
884 |
"/ h printOn:aStream. |
|
885 |
"/ aStream nextPut:$:. |
|
886 |
"/ m := self minutes. |
|
887 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
888 |
"/ m printOn:aStream. |
|
889 |
"/ aStream nextPut:$:. |
|
890 |
"/ s := self seconds. |
|
891 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
892 |
"/ s printOn:aStream. |
|
893 |
"/ aStream nextPutAll:ampm |
|
894 |
||
895 |
" |
|
896 |
Time now print12HourFormatOn:Transcript. Transcript cr |
|
897 |
(Time now subtractHours:12) print12HourFormatOn:Transcript. Transcript cr |
|
898 |
(Time hour:24 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
899 |
(Time hour:12 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
900 |
(Time hour:0 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
901 |
0 to:24 do:[:h | |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
902 |
(Time hour:h minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
6164 | 903 |
] |
904 |
" |
|
905 |
! |
|
906 |
||
907 |
print24HourFormatOn:aStream |
|
11151 | 908 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 909 |
Format is hh:mm:ss (i.e. 24-hour european format)." |
910 |
||
911 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
912 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
913 |
format:(self class formatString24). |
6164 | 914 |
|
915 |
"/ |h m s| |
|
916 |
"/ |
|
917 |
"/ h := self hours. |
|
918 |
"/ (h < 10) ifTrue:[aStream nextPut:$0]. |
|
919 |
"/ h printOn:aStream. |
|
920 |
"/ aStream nextPut:$:. |
|
921 |
"/ m := self minutes. |
|
922 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
923 |
"/ m printOn:aStream. |
|
924 |
"/ aStream nextPut:$:. |
|
925 |
"/ s := self seconds. |
|
926 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
927 |
"/ s printOn:aStream |
|
928 |
||
929 |
" |
|
930 |
Time now print24HourFormatOn:Transcript. Transcript cr |
|
931 |
" |
|
932 |
! |
|
933 |
||
22839 | 934 |
printAsUTCIso8601FormatOn:aStream |
935 |
"prints the receiver as UTC time" |
|
936 |
||
937 |
Timestamp timestampISO8601Builder |
|
938 |
print:self compact:false |
|
939 |
asLocal:false asUTC:true withMilliseconds:true |
|
940 |
timeSeparator:$T timeOnly:true |
|
941 |
on:aStream |
|
942 |
||
943 |
" |
|
944 |
Time now printString -> '04:23:33 PM' |
|
945 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
946 |
||
947 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
948 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
949 |
||
950 |
" |
|
951 |
! |
|
952 |
||
23021 | 953 |
printIso8601CompressedOn:aStream |
954 |
"prints the receiver as local time" |
|
955 |
||
956 |
Timestamp timestampISO8601Builder |
|
957 |
print:self compact:true |
|
958 |
asLocal:true asUTC:false withMilliseconds:true |
|
959 |
timeSeparator:$T timeOnly:true |
|
960 |
on:aStream |
|
961 |
||
962 |
" |
|
963 |
Time now printString -> '04:23:33 PM' |
|
964 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
965 |
||
966 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
967 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
968 |
" |
|
969 |
||
970 |
"Created: / 25-05-2018 / 12:06:35 / Claus Gittinger" |
|
971 |
! |
|
972 |
||
22839 | 973 |
printIso8601FormatOn:aStream |
974 |
"prints the receiver as local time" |
|
975 |
||
976 |
Timestamp timestampISO8601Builder |
|
977 |
print:self compact:false |
|
978 |
asLocal:true asUTC:false withMilliseconds:true |
|
979 |
timeSeparator:$T timeOnly:true |
|
980 |
on:aStream |
|
981 |
||
982 |
" |
|
983 |
Time now printString -> '04:23:33 PM' |
|
984 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
985 |
||
986 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
987 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
988 |
" |
|
989 |
! |
|
990 |
||
6164 | 991 |
printOn:aStream |
11151 | 992 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 993 |
The format is suitable for a human - not meant to be read back. |
994 |
||
995 |
Format is hh:mm:ss either in 12-hour or 24-hour format. |
|
996 |
depending on the setting of LanguageTerritory. |
|
17162 | 997 |
I don't know what ST-80 does here (12-hour format ?)" |
6164 | 998 |
|
16940 | 999 |
|format| |
1000 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1001 |
format := (self milliseconds = 0) |
17162 | 1002 |
ifTrue:[self class defaultFormatString] |
1003 |
ifFalse:[self class defaultFormatStringWithMilliseconds]. |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
1004 |
^ self |
17162 | 1005 |
printOn:aStream |
1006 |
format:format |
|
6164 | 1007 |
|
1008 |
" |
|
1009 |
Time now printOn:Transcript. Transcript cr |
|
22839 | 1010 |
Time now printString |
1011 |
Time now printStringIso8601 |
|
6164 | 1012 |
" |
1013 |
||
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
1014 |
"Modified: / 16-01-2011 / 11:27:24 / cg" |
6164 | 1015 |
! |
1016 |
||
1017 |
printString12HourFormat |
|
1018 |
"return a printed representation in 12 hour format" |
|
1019 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1020 |
^ self printStringFormat:(self class formatString12us) |
6164 | 1021 |
|
1022 |
" |
|
1023 |
Time now printString12HourFormat |
|
1024 |
" |
|
1025 |
! |
|
1026 |
||
1027 |
printString24HourFormat |
|
1028 |
"return a printed representation in 24 hour format" |
|
1029 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1030 |
^ self printStringFormat:(self class formatString24) |
6164 | 1031 |
|
1032 |
" |
|
1033 |
Time now printString24HourFormat |
|
1034 |
" |
|
1035 |
||
1036 |
! |
|
1037 |
||
1038 |
shortPrintString |
|
1039 |
"dummy - for now" |
|
1040 |
||
1041 |
^ self printString |
|
1042 |
||
1043 |
"Created: 20.6.1997 / 17:17:01 / cg" |
|
1044 |
! ! |
|
1045 |
||
1046 |
!Time methodsFor:'private'! |
|
1047 |
||
1048 |
fromOSTime:osTime |
|
13235 | 1049 |
"set my time in the local timezone, given an osTime" |
6164 | 1050 |
|
7513 | 1051 |
|i| |
6164 | 1052 |
|
7513 | 1053 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
7740 | 1054 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
6164 | 1055 |
|
1056 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1057 |
! |
|
275 | 1058 |
|
16940 | 1059 |
fromOSTimeWithMilliseconds:osTime |
1060 |
"set my time in the local timezone, given an osTime" |
|
1061 |
||
1062 |
|i| |
|
1063 |
||
1064 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
|
1065 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) milliseconds:(i milliseconds) |
|
1066 |
! |
|
1067 |
||
13235 | 1068 |
fromUtcOSTime:osTime |
1069 |
"set my time in the local timezone, given an osTime" |
|
1070 |
||
1071 |
|i| |
|
1072 |
||
1073 |
i := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
1074 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
|
1075 |
||
1076 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1077 |
! |
|
1078 |
||
22839 | 1079 |
fromUtcOSTimeWithMilliseconds:osTime |
1080 |
"set my time in the local timezone, given an osTime" |
|
1081 |
||
1082 |
|i| |
|
1083 |
||
1084 |
i := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
1085 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) milliseconds:(i milliseconds) |
|
1086 |
||
1087 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1088 |
! |
|
1089 |
||
3477 | 1090 |
getMilliseconds |
22839 | 1091 |
"return the number of milliseconds since midnight. |
1092 |
Notice that the receiver may or may not have millisecond resolution, |
|
1093 |
depending on whether it was created by Time now or by Time nowWithMilliseconds. |
|
1094 |
Notice: |
|
1095 |
does not include any timezone info (in contrast to Timestamp), |
|
1096 |
so this always represent a time depending on the context (usually: local) |
|
1097 |
Notice: |
|
1098 |
beacuse of that, always use Timestamps for comparisons." |
|
6046 | 1099 |
|
16933 | 1100 |
^ timeEncoding |
22839 | 1101 |
|
1102 |
" |
|
1103 |
Time now getMilliseconds |
|
1104 |
Time nowWithMilliseconds getMilliseconds |
|
1105 |
" |
|
3477 | 1106 |
! |
1107 |
||
275 | 1108 |
getSeconds |
22282 | 1109 |
"return the number of (truncated) seconds since midnight" |
6046 | 1110 |
|
16933 | 1111 |
^ timeEncoding // 1000 |
22282 | 1112 |
|
1113 |
"Modified (comment): / 21-09-2017 / 18:50:16 / cg" |
|
275 | 1114 |
! |
1115 |
||
6165 | 1116 |
setHours:h minutes:m seconds:s |
699 | 1117 |
"set my time given individual values" |
1118 |
||
6165 | 1119 |
self setSeconds:(((h\\24) * 60 * 60 ) + (m * 60) + s). |
3477 | 1120 |
! |
1121 |
||
16937 | 1122 |
setHours:h minutes:m seconds:s milliseconds:ms |
1123 |
"set my time given individual values" |
|
1124 |
||
1125 |
self setMilliseconds:((((h\\24) * 60 * 60 ) + (m * 60) + s) * 1000) + ms. |
|
1126 |
! |
|
1127 |
||
3477 | 1128 |
setMilliseconds:millis |
16933 | 1129 |
"set my time given milliseconds since midnight. |
1130 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
|
1131 |
(use TimeDuration, if you need that)." |
|
3477 | 1132 |
|
16933 | 1133 |
millis < 0 ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1134 |
timeEncoding := (24 * 3600 * 1000) - (millis negated \\ (24 * 3600 * 1000)) |
16933 | 1135 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1136 |
timeEncoding := millis |
16933 | 1137 |
]. |
1138 |
timeEncoding >= (24 * 3600 * 1000) ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1139 |
timeEncoding := timeEncoding \\ (24 * 3600 * 1000). |
16933 | 1140 |
] |
1141 |
||
1142 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1143 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1144 |
Time fromSeconds:3601 |
16933 | 1145 |
Time now seconds |
1146 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1147 |
(Time now addDays:5) seconds |
16933 | 1148 |
(Time now addDays:5) timeEncoding |
1149 |
" |
|
699 | 1150 |
! |
1151 |
||
22886 | 1152 |
setMilliseconds:millis additionalPicoseconds:ignoredPicos |
1153 |
"for protocol compatibility with timestamp. |
|
1154 |
However, the picos are ignored here" |
|
1155 |
||
1156 |
^ self setMilliseconds:millis |
|
1157 |
! |
|
1158 |
||
6904 | 1159 |
setSeconds:secs |
1160 |
"set my time given seconds since midnight. |
|
9441 | 1161 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
6904 | 1162 |
(use TimeDuration, if you need that)." |
1163 |
||
16933 | 1164 |
self setMilliseconds:secs * 1000 |
6904 | 1165 |
|
1166 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1167 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1168 |
Time fromSeconds:3601 |
6904 | 1169 |
Time now seconds |
1170 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1171 |
(Time now addDays:5) seconds |
6904 | 1172 |
(Time now addDays:5) timeEncoding |
1173 |
" |
|
1174 |
! |
|
1175 |
||
6165 | 1176 |
timeEncoding |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1177 |
"the internal encoding is stricktly private, |
6165 | 1178 |
and should not be used outside." |
1179 |
||
1180 |
^ timeEncoding |
|
1181 |
! |
|
1182 |
||
1183 |
timeEncoding:encoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1184 |
"the internal encoding is stricktly private, |
6165 | 1185 |
and should not be used outside." |
1186 |
||
1187 |
timeEncoding := encoding |
|
699 | 1188 |
! ! |
1189 |
||
22809 | 1190 |
!Time methodsFor:'visiting'! |
1191 |
||
1192 |
acceptVisitor:aVisitor with:aParameter |
|
1193 |
"dispatch for visitor pattern; send #visitTime:with: to aVisitor" |
|
1194 |
||
1195 |
^ aVisitor visitTime:self with:aParameter |
|
1196 |
! ! |
|
1197 |
||
6165 | 1198 |
!Time class methodsFor:'documentation'! |
241 | 1199 |
|
699 | 1200 |
version |
19848 | 1201 |
^ '$Header$' |
12728 | 1202 |
! |
1203 |
||
1204 |
version_CVS |
|
19848 | 1205 |
^ '$Header$' |
241 | 1206 |
! ! |
17136 | 1207 |