author | Claus Gittinger <cg@exept.de> |
Fri, 12 Apr 2019 05:48:07 +0200 | |
changeset 24063 | 6193bcaef956 |
parent 23790 | 42e8ecc961bc |
child 24118 | 02d39aaca894 |
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 |
||
23021 | 549 |
|
550 |
||
16981 | 551 |
!Time methodsFor:'Compatibility-Backward'! |
552 |
||
553 |
asMilliSeconds |
|
554 |
<resource: #obsolete> |
|
555 |
"return the number of milliseconds elapsed since midnight" |
|
556 |
||
557 |
^ self asMilliseconds |
|
6164 | 558 |
|
16981 | 559 |
" |
560 |
Time now asMilliSeconds |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
561 |
(TimeDuration days:1) asMilliSeconds |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
562 |
(TimeDuration hours:1) asMilliSeconds |
16981 | 563 |
" |
13632 | 564 |
|
16981 | 565 |
"Created: / 05-09-2011 / 10:40:15 / cg" |
566 |
! ! |
|
567 |
||
568 |
!Time methodsFor:'Compatibility-Squeak'! |
|
13632 | 569 |
|
6164 | 570 |
intervalString |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
571 |
"Treat the time as a difference. |
6164 | 572 |
Give it in hours and minutes with two digits of accuracy." |
573 |
||
6467 | 574 |
|hours minutes seconds hh mm ss s| |
6164 | 575 |
|
576 |
hours := self hours. |
|
577 |
minutes := self minutes. |
|
578 |
seconds := self seconds. |
|
6467 | 579 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
580 |
hours = 0 |
23790 | 581 |
ifTrue: [hh := ''] |
582 |
ifFalse: [ |
|
583 |
hh := hours printString, ' hour'. |
|
584 |
hours > 1 ifTrue:[ |
|
585 |
hh := hh , 's' |
|
586 |
] |
|
587 |
]. |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
588 |
minutes = 0 |
23790 | 589 |
ifTrue: [mm := ''] |
590 |
ifFalse: [ |
|
591 |
mm := minutes printString, ' minute'. |
|
592 |
minutes > 1 ifTrue:[ |
|
593 |
mm := mm , 's' |
|
594 |
] |
|
595 |
]. |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
596 |
seconds = 0 |
23790 | 597 |
ifTrue: [ss := ''] |
598 |
ifFalse: [ |
|
599 |
ss := seconds printString, ' second'. |
|
600 |
seconds > 1 ifTrue:[ |
|
601 |
ss := ss , 's' |
|
602 |
] |
|
603 |
]. |
|
6467 | 604 |
|
605 |
"/ do not show seconds, if hours are there |
|
23790 | 606 |
hh size ~~ 0 ifTrue: [ss := '']. |
6467 | 607 |
|
608 |
s := hh. |
|
6873 | 609 |
mm notEmpty ifTrue:[ |
23790 | 610 |
s notEmpty ifTrue:[ |
611 |
s := s , ' ' |
|
612 |
]. |
|
613 |
s := s , mm. |
|
6467 | 614 |
]. |
6873 | 615 |
ss notEmpty ifTrue:[ |
23790 | 616 |
s notEmpty ifTrue:[ |
617 |
s := s , ' ' |
|
618 |
]. |
|
619 |
s := s , ss |
|
6467 | 620 |
]. |
6873 | 621 |
^ s |
6164 | 622 |
|
623 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
624 |
(Time fromSeconds:3600) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
625 |
(Time fromSeconds:3605) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
626 |
(Time fromSeconds:3700) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
627 |
(Time fromSeconds:5) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
628 |
(Time fromSeconds:65) intervalString |
6164 | 629 |
" |
23790 | 630 |
|
631 |
"Modified: / 01-03-2019 / 16:14:41 / Claus Gittinger" |
|
6164 | 632 |
! |
633 |
||
7024 | 634 |
print24:prnt24FormatBoolean on:aStream |
635 |
"print me either US or 24hr format on a stream" |
|
636 |
||
637 |
^ self print24:prnt24FormatBoolean showSeconds:true on:aStream |
|
638 |
||
639 |
" |
|
640 |
Time now print24:true on:Transcript. Transcript cr. |
|
641 |
Time now print24:false on:Transcript. Transcript cr. |
|
642 |
" |
|
643 |
! |
|
644 |
||
6164 | 645 |
print24:prnt24Format showSeconds:doSeconds on:aStream |
646 |
"print me either US or 24hr format, optionally with |
|
647 |
seconds on a stream" |
|
648 |
||
649 |
|format| |
|
650 |
||
651 |
prnt24Format ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
652 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
653 |
format := '%h:%m:%s' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
654 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
655 |
format := '%h:%m' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
656 |
]. |
6164 | 657 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
658 |
"/ US format |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
659 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
660 |
format := '%u:%m:%s %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
661 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
662 |
format := '%u:%m %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
663 |
]. |
6164 | 664 |
]. |
665 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
666 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
667 |
format:format. |
6164 | 668 |
|
669 |
" |
|
670 |
Time now print24:true showSeconds:true on:Transcript. Transcript cr. |
|
671 |
Time now print24:false showSeconds:true on:Transcript. Transcript cr. |
|
672 |
Time now print24:true showSeconds:false on:Transcript. Transcript cr. |
|
673 |
Time now print24:false showSeconds:false on:Transcript. Transcript cr. |
|
674 |
" |
|
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
675 |
! ! |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
676 |
|
6164 | 677 |
!Time methodsFor:'accessing'! |
678 |
||
679 |
hours |
|
680 |
"return the number of hours since midnight (i.e. 0..23)" |
|
681 |
||
682 |
^ self getSeconds // 3600 |
|
683 |
||
684 |
" |
|
685 |
Time now hours |
|
686 |
" |
|
687 |
! |
|
275 | 688 |
|
4845 | 689 |
milliseconds |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
690 |
"get the milliseconds part |
16981 | 691 |
(notice: that is NOT the total number of millis (since midnight), |
19848 | 692 |
but the fractional part only. Use this only for printing. |
693 |
asMilliseconds or getMilliseconds is probably what you want" |
|
6164 | 694 |
|
16940 | 695 |
^ timeEncoding \\ 1000 |
6164 | 696 |
! |
697 |
||
698 |
minutes |
|
19848 | 699 |
"return the number of minutes within the hour (i.e. 0..59). |
700 |
(notice: that is NOT the total number of minutes (since midnight), |
|
701 |
but the fractional part only. Use this only for printing." |
|
6164 | 702 |
|
703 |
^ (self getSeconds \\ 3600) // 60 |
|
704 |
||
705 |
" |
|
706 |
Time now minutes |
|
707 |
" |
|
708 |
! |
|
709 |
||
710 |
seconds |
|
19848 | 711 |
"return the number of seconds within the minute (i.e. 0..59). |
712 |
(notice: that is NOT the total number of seconds (since midnight), |
|
713 |
but the fractional part only. Use this only for printing. |
|
714 |
asSeconds or getSeconds give you the nr of seconds since midnight" |
|
6164 | 715 |
|
7733 | 716 |
^ self getSeconds \\ 60 |
6164 | 717 |
|
718 |
" |
|
719 |
Time now seconds |
|
720 |
" |
|
721 |
! |
|
722 |
||
9441 | 723 |
timeZoneDeltaInMinutes |
724 |
"answer the number of minutes between local time and utc time. |
|
725 |
Delta is positive if local time is ahead of utc, negative if behind utc. |
|
726 |
||
16985 | 727 |
Time is local time, so ask a local timestamp" |
9441 | 728 |
|
729 |
^ Timestamp now timeZoneDeltaInMinutes |
|
730 |
||
731 |
||
732 |
" |
|
733 |
Time now timeZoneDeltaInMinutes |
|
734 |
" |
|
1 | 735 |
! ! |
736 |
||
6164 | 737 |
!Time methodsFor:'comparing'! |
738 |
||
23237 | 739 |
differenceFromTimestamp:aTimestamp |
740 |
"return the time difference as a timeDuration instance. |
|
741 |
Use only the time part of aTimestamp (so intrepret it as a time today)." |
|
742 |
||
743 |
^ TimeDuration basicNew setMilliseconds:aTimestamp asTime getMilliseconds - self getMilliseconds. |
|
744 |
||
745 |
" |
|
746 |
Time nowWithMilliseconds differenceFromTimestamp:Timestamp now. |
|
747 |
Time now differenceFromTimestamp:Time now + 1 seconds |
|
748 |
" |
|
749 |
||
750 |
"Created: / 27-07-2018 / 11:23:37 / Stefan Vogel" |
|
751 |
! |
|
752 |
||
6164 | 753 |
hash |
754 |
"return an integer useful for hashing on times" |
|
755 |
||
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
756 |
^ timeEncoding |
6164 | 757 |
! ! |
758 |
||
759 |
!Time methodsFor:'converting'! |
|
760 |
||
13235 | 761 |
asLocalTimestamp |
762 |
"return an Timestamp object from the receiver. |
|
763 |
So I am interpreted as a Time in the local timezone. |
|
764 |
The date components are taken from today." |
|
765 |
||
766 |
|todayTimestamp| |
|
767 |
||
768 |
todayTimestamp := Timestamp now. |
|
22038 | 769 |
todayTimestamp |
770 |
year:todayTimestamp year |
|
771 |
month:todayTimestamp month |
|
772 |
day:todayTimestamp day |
|
773 |
hour:(self hours) |
|
774 |
minute:(self minutes) |
|
775 |
second:(self seconds) |
|
776 |
millisecond:(self milliseconds). |
|
13235 | 777 |
|
778 |
^ todayTimestamp. |
|
779 |
||
780 |
" |
|
781 |
Time now asLocalTimestamp |
|
782 |
" |
|
22038 | 783 |
|
784 |
"Modified (format): / 17-07-2017 / 14:07:27 / cg" |
|
785 |
! |
|
786 |
||
787 |
asTZTimestamp |
|
788 |
"return a TZTimestamp object from the receiver. |
|
789 |
This includes the local timezone information." |
|
790 |
||
791 |
^ self asLocalTimestamp asTZTimestamp. |
|
792 |
||
793 |
" |
|
794 |
Time now asTZTimestamp -> 2017-07-17 14:11:16+02 |
|
795 |
Time now asUtcTimestamp -> 2017-07-17 12:11:16Z |
|
796 |
Time now asLocalTimestamp -> 2017-07-17 14:11:16 |
|
797 |
" |
|
798 |
||
799 |
"Created: / 17-07-2017 / 14:11:14 / cg" |
|
13235 | 800 |
! |
801 |
||
699 | 802 |
asTime |
16981 | 803 |
"return a Time object from the receiver - that's the receiver." |
699 | 804 |
|
22038 | 805 |
self class == Time ifTrue:[ |
806 |
^ self |
|
807 |
]. |
|
808 |
^ super asTime |
|
809 |
||
810 |
"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
|
811 |
! |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
812 |
|
8796 | 813 |
asTimeDuration |
814 |
"return an TimeDuration object from the receiver, taking the time since midnight." |
|
815 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
816 |
^ TimeDuration |
23618 | 817 |
hours:(self hours) minutes:(self minutes) seconds:(self seconds) |
818 |
milliseconds:(self milliseconds) |
|
8796 | 819 |
" |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
820 |
Time now asTimeDuration |
23618 | 821 |
10 asTimeDuration |
822 |
10 seconds asTimeDuration |
|
823 |
'10m 20s' asTimeDuration |
|
8796 | 824 |
" |
23618 | 825 |
|
826 |
"Modified (comment): / 21-01-2019 / 10:29:05 / Claus Gittinger" |
|
8796 | 827 |
! |
828 |
||
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
829 |
asTimestamp |
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
830 |
"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
|
831 |
The date components are taken from today." |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
832 |
|
13235 | 833 |
^ self asLocalTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
834 |
|
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
835 |
" |
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
836 |
Time now asTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
837 |
" |
13235 | 838 |
! |
839 |
||
840 |
asUtcTimestamp |
|
841 |
"return an UtcTimestamp object from the receiver. |
|
842 |
So I am interpreted as a Time in the UTC zone. |
|
843 |
The date components are taken from today." |
|
844 |
||
22038 | 845 |
^ self asLocalTimestamp asUtcTimestamp. |
13235 | 846 |
|
847 |
" |
|
22038 | 848 |
Time now asTimestamp -> 2017-07-17 14:08:22 |
849 |
Time now asLocalTimestamp -> 2017-07-17 14:08:24 |
|
850 |
Time now asUtcTimestamp -> 2017-07-17 12:08:27Z |
|
13235 | 851 |
" |
22038 | 852 |
|
853 |
"Modified (comment): / 17-07-2017 / 14:09:45 / cg" |
|
699 | 854 |
! ! |
855 |
||
6164 | 856 |
!Time methodsFor:'printing & storing'! |
857 |
||
858 |
print12HourFormatOn:aStream |
|
11151 | 859 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 860 |
Format is hh:mm:ss am/pm (i.e. 12-hour american format)." |
861 |
||
862 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
863 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
864 |
format:(self class formatString12us) |
6164 | 865 |
|
866 |
"/ |h m s ampm| |
|
867 |
"/ |
|
868 |
"/ h := self hours. |
|
869 |
"/ |
|
870 |
"/ "/ 0 -> 12 am |
|
871 |
"/ "/ 12 -> 12 pm |
|
872 |
"/ |
|
873 |
"/ h // 12 == 0 ifTrue:[ |
|
874 |
"/ ampm := ' am'. |
|
875 |
"/ ] ifFalse:[ |
|
876 |
"/ ampm := ' pm'. |
|
877 |
"/ ]. |
|
878 |
"/ |
|
879 |
"/ h == 0 ifFalse:[ |
|
880 |
"/ h := h - 1 \\ 12 + 1. |
|
881 |
"/ ]. |
|
882 |
"/ |
|
883 |
"/ h printOn:aStream. |
|
884 |
"/ aStream nextPut:$:. |
|
885 |
"/ m := self minutes. |
|
886 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
887 |
"/ m printOn:aStream. |
|
888 |
"/ aStream nextPut:$:. |
|
889 |
"/ s := self seconds. |
|
890 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
891 |
"/ s printOn:aStream. |
|
892 |
"/ aStream nextPutAll:ampm |
|
893 |
||
894 |
" |
|
895 |
Time now print12HourFormatOn:Transcript. Transcript cr |
|
896 |
(Time now subtractHours:12) print12HourFormatOn:Transcript. Transcript cr |
|
897 |
(Time hour:24 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
898 |
(Time hour:12 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
899 |
(Time hour:0 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
900 |
0 to:24 do:[:h | |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
901 |
(Time hour:h minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
6164 | 902 |
] |
903 |
" |
|
904 |
! |
|
905 |
||
906 |
print24HourFormatOn:aStream |
|
11151 | 907 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 908 |
Format is hh:mm:ss (i.e. 24-hour european format)." |
909 |
||
910 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
911 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
912 |
format:(self class formatString24). |
6164 | 913 |
|
914 |
"/ |h m s| |
|
915 |
"/ |
|
916 |
"/ h := self hours. |
|
917 |
"/ (h < 10) ifTrue:[aStream nextPut:$0]. |
|
918 |
"/ h printOn:aStream. |
|
919 |
"/ aStream nextPut:$:. |
|
920 |
"/ m := self minutes. |
|
921 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
922 |
"/ m printOn:aStream. |
|
923 |
"/ aStream nextPut:$:. |
|
924 |
"/ s := self seconds. |
|
925 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
926 |
"/ s printOn:aStream |
|
927 |
||
928 |
" |
|
929 |
Time now print24HourFormatOn:Transcript. Transcript cr |
|
930 |
" |
|
931 |
! |
|
932 |
||
22839 | 933 |
printAsUTCIso8601FormatOn:aStream |
934 |
"prints the receiver as UTC time" |
|
935 |
||
936 |
Timestamp timestampISO8601Builder |
|
937 |
print:self compact:false |
|
938 |
asLocal:false asUTC:true withMilliseconds:true |
|
939 |
timeSeparator:$T timeOnly:true |
|
940 |
on:aStream |
|
941 |
||
942 |
" |
|
943 |
Time now printString -> '04:23:33 PM' |
|
944 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
945 |
||
946 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
947 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
948 |
||
949 |
" |
|
950 |
! |
|
951 |
||
23021 | 952 |
printIso8601CompressedOn:aStream |
953 |
"prints the receiver as local time" |
|
954 |
||
955 |
Timestamp timestampISO8601Builder |
|
956 |
print:self compact:true |
|
957 |
asLocal:true asUTC:false withMilliseconds:true |
|
958 |
timeSeparator:$T timeOnly:true |
|
959 |
on:aStream |
|
960 |
||
961 |
" |
|
962 |
Time now printString -> '04:23:33 PM' |
|
963 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
964 |
||
965 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
966 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
967 |
" |
|
968 |
||
969 |
"Created: / 25-05-2018 / 12:06:35 / Claus Gittinger" |
|
970 |
! |
|
971 |
||
22839 | 972 |
printIso8601FormatOn:aStream |
973 |
"prints the receiver as local time" |
|
974 |
||
975 |
Timestamp timestampISO8601Builder |
|
976 |
print:self compact:false |
|
977 |
asLocal:true asUTC:false withMilliseconds:true |
|
978 |
timeSeparator:$T timeOnly:true |
|
979 |
on:aStream |
|
980 |
||
981 |
" |
|
982 |
Time now printString -> '04:23:33 PM' |
|
983 |
Time now printStringIso8601 -> 'T16:23:39' (notice: this is local time) |
|
984 |
||
985 |
Time now printAsUTCIso8601FormatOn:Transcript. Transcript cr. |
|
986 |
Time now printIso8601FormatOn:Transcript. Transcript cr. |
|
987 |
" |
|
988 |
! |
|
989 |
||
6164 | 990 |
printOn:aStream |
11151 | 991 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 992 |
The format is suitable for a human - not meant to be read back. |
993 |
||
994 |
Format is hh:mm:ss either in 12-hour or 24-hour format. |
|
995 |
depending on the setting of LanguageTerritory. |
|
17162 | 996 |
I don't know what ST-80 does here (12-hour format ?)" |
6164 | 997 |
|
16940 | 998 |
|format| |
999 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1000 |
format := (self milliseconds = 0) |
17162 | 1001 |
ifTrue:[self class defaultFormatString] |
1002 |
ifFalse:[self class defaultFormatStringWithMilliseconds]. |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
1003 |
^ self |
17162 | 1004 |
printOn:aStream |
1005 |
format:format |
|
6164 | 1006 |
|
1007 |
" |
|
1008 |
Time now printOn:Transcript. Transcript cr |
|
22839 | 1009 |
Time now printString |
1010 |
Time now printStringIso8601 |
|
6164 | 1011 |
" |
1012 |
||
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
1013 |
"Modified: / 16-01-2011 / 11:27:24 / cg" |
6164 | 1014 |
! |
1015 |
||
1016 |
printString12HourFormat |
|
1017 |
"return a printed representation in 12 hour format" |
|
1018 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1019 |
^ self printStringFormat:(self class formatString12us) |
6164 | 1020 |
|
1021 |
" |
|
1022 |
Time now printString12HourFormat |
|
1023 |
" |
|
1024 |
! |
|
1025 |
||
1026 |
printString24HourFormat |
|
1027 |
"return a printed representation in 24 hour format" |
|
1028 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1029 |
^ self printStringFormat:(self class formatString24) |
6164 | 1030 |
|
1031 |
" |
|
1032 |
Time now printString24HourFormat |
|
1033 |
" |
|
1034 |
||
1035 |
! |
|
1036 |
||
1037 |
shortPrintString |
|
1038 |
"dummy - for now" |
|
1039 |
||
1040 |
^ self printString |
|
1041 |
||
1042 |
"Created: 20.6.1997 / 17:17:01 / cg" |
|
1043 |
! ! |
|
1044 |
||
1045 |
!Time methodsFor:'private'! |
|
1046 |
||
1047 |
fromOSTime:osTime |
|
13235 | 1048 |
"set my time in the local timezone, given an osTime" |
6164 | 1049 |
|
7513 | 1050 |
|i| |
6164 | 1051 |
|
7513 | 1052 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
7740 | 1053 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
6164 | 1054 |
|
1055 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1056 |
! |
|
275 | 1057 |
|
16940 | 1058 |
fromOSTimeWithMilliseconds:osTime |
1059 |
"set my time in the local timezone, given an osTime" |
|
1060 |
||
1061 |
|i| |
|
1062 |
||
1063 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
|
1064 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) milliseconds:(i milliseconds) |
|
1065 |
! |
|
1066 |
||
13235 | 1067 |
fromUtcOSTime:osTime |
1068 |
"set my time in the local timezone, given an osTime" |
|
1069 |
||
1070 |
|i| |
|
1071 |
||
1072 |
i := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
1073 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
|
1074 |
||
1075 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1076 |
! |
|
1077 |
||
22839 | 1078 |
fromUtcOSTimeWithMilliseconds:osTime |
1079 |
"set my time in the local timezone, given an osTime" |
|
1080 |
||
1081 |
|i| |
|
1082 |
||
1083 |
i := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
1084 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) milliseconds:(i milliseconds) |
|
1085 |
||
1086 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
1087 |
! |
|
1088 |
||
3477 | 1089 |
getMilliseconds |
22839 | 1090 |
"return the number of milliseconds since midnight. |
1091 |
Notice that the receiver may or may not have millisecond resolution, |
|
1092 |
depending on whether it was created by Time now or by Time nowWithMilliseconds. |
|
1093 |
Notice: |
|
1094 |
does not include any timezone info (in contrast to Timestamp), |
|
1095 |
so this always represent a time depending on the context (usually: local) |
|
1096 |
Notice: |
|
1097 |
beacuse of that, always use Timestamps for comparisons." |
|
6046 | 1098 |
|
16933 | 1099 |
^ timeEncoding |
22839 | 1100 |
|
1101 |
" |
|
1102 |
Time now getMilliseconds |
|
1103 |
Time nowWithMilliseconds getMilliseconds |
|
1104 |
" |
|
3477 | 1105 |
! |
1106 |
||
275 | 1107 |
getSeconds |
22282 | 1108 |
"return the number of (truncated) seconds since midnight" |
6046 | 1109 |
|
16933 | 1110 |
^ timeEncoding // 1000 |
22282 | 1111 |
|
1112 |
"Modified (comment): / 21-09-2017 / 18:50:16 / cg" |
|
275 | 1113 |
! |
1114 |
||
6165 | 1115 |
setHours:h minutes:m seconds:s |
699 | 1116 |
"set my time given individual values" |
1117 |
||
6165 | 1118 |
self setSeconds:(((h\\24) * 60 * 60 ) + (m * 60) + s). |
3477 | 1119 |
! |
1120 |
||
16937 | 1121 |
setHours:h minutes:m seconds:s milliseconds:ms |
1122 |
"set my time given individual values" |
|
1123 |
||
1124 |
self setMilliseconds:((((h\\24) * 60 * 60 ) + (m * 60) + s) * 1000) + ms. |
|
1125 |
! |
|
1126 |
||
3477 | 1127 |
setMilliseconds:millis |
16933 | 1128 |
"set my time given milliseconds since midnight. |
1129 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
|
1130 |
(use TimeDuration, if you need that)." |
|
3477 | 1131 |
|
16933 | 1132 |
millis < 0 ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1133 |
timeEncoding := (24 * 3600 * 1000) - (millis negated \\ (24 * 3600 * 1000)) |
16933 | 1134 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1135 |
timeEncoding := millis |
16933 | 1136 |
]. |
1137 |
timeEncoding >= (24 * 3600 * 1000) ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1138 |
timeEncoding := timeEncoding \\ (24 * 3600 * 1000). |
16933 | 1139 |
] |
1140 |
||
1141 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1142 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1143 |
Time fromSeconds:3601 |
16933 | 1144 |
Time now seconds |
1145 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1146 |
(Time now addDays:5) seconds |
16933 | 1147 |
(Time now addDays:5) timeEncoding |
1148 |
" |
|
699 | 1149 |
! |
1150 |
||
22886 | 1151 |
setMilliseconds:millis additionalPicoseconds:ignoredPicos |
1152 |
"for protocol compatibility with timestamp. |
|
1153 |
However, the picos are ignored here" |
|
1154 |
||
1155 |
^ self setMilliseconds:millis |
|
1156 |
! |
|
1157 |
||
6904 | 1158 |
setSeconds:secs |
1159 |
"set my time given seconds since midnight. |
|
9441 | 1160 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
6904 | 1161 |
(use TimeDuration, if you need that)." |
1162 |
||
16933 | 1163 |
self setMilliseconds:secs * 1000 |
6904 | 1164 |
|
1165 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1166 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1167 |
Time fromSeconds:3601 |
6904 | 1168 |
Time now seconds |
1169 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1170 |
(Time now addDays:5) seconds |
6904 | 1171 |
(Time now addDays:5) timeEncoding |
1172 |
" |
|
1173 |
! |
|
1174 |
||
6165 | 1175 |
timeEncoding |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1176 |
"the internal encoding is stricktly private, |
6165 | 1177 |
and should not be used outside." |
1178 |
||
1179 |
^ timeEncoding |
|
1180 |
! |
|
1181 |
||
1182 |
timeEncoding:encoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
1183 |
"the internal encoding is stricktly private, |
6165 | 1184 |
and should not be used outside." |
1185 |
||
1186 |
timeEncoding := encoding |
|
699 | 1187 |
! ! |
1188 |
||
23021 | 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 |