author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 01 Apr 2015 10:20:10 +0100 | |
branch | jv |
changeset 18120 | e3a375d5f6a8 |
parent 18011 | deb0c3355881 |
parent 17641 | e28a4212f412 |
child 18457 | 214d760f8247 |
permissions | -rw-r--r-- |
17641 | 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. |
51 |
Use Time utcNow to get the time in the UTC zone. |
|
52 |
||
16940 | 53 |
Note: time was changed recently to keep the number of milliseconds since midnight. |
17641 | 54 |
However, all existing instance creators so far only create time instances with 0-millis. |
55 |
I.e. Time now still returns a time with second precision. |
|
16940 | 56 |
|
17641 | 57 |
It is not done currently, to remain backward compatible, as users may get confused |
58 |
to see t1 > t2 although they print the same (as long as the printed representation does not |
|
59 |
include the milli seconds). |
|
60 |
On the other side: a change of the default printformat is not done now, |
|
61 |
as it may affect many existing applications. |
|
16937 | 62 |
|
17641 | 63 |
Any application which needs the millisecond precision time should call the new |
64 |
Time nowWithMilliseconds. |
|
16940 | 65 |
|
241 | 66 |
Examples: |
17641 | 67 |
|t| |
241 | 68 |
|
17641 | 69 |
t := Time now. |
70 |
Transcript showCR:t. |
|
241 | 71 |
|
72 |
||
17641 | 73 |
|t1 t2| |
241 | 74 |
|
17641 | 75 |
t1 := Time now. |
76 |
(Delay forSeconds:10) wait. |
|
77 |
t2 := Time now. |
|
78 |
t2 - t1 |
|
1295 | 79 |
|
80 |
[author:] |
|
17641 | 81 |
Claus Gittinger |
1295 | 82 |
|
83 |
[see also:] |
|
17641 | 84 |
Date Timestamp AbstractTime OperatingSystem |
85 |
Filename |
|
88 | 86 |
" |
87 |
! ! |
|
1 | 88 |
|
6165 | 89 |
!Time class methodsFor:'instance creation'! |
90 |
||
13603
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
91 |
fromString: aString |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
92 |
^ self readFrom: (ReadStream on: aString). |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
93 |
|
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
94 |
"Modified (format): / 20-08-2011 / 16:46:39 / cg" |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
95 |
! |
d9baa85cd3ba
comment/format in: #fromString:
Claus Gittinger <cg@exept.de>
parents:
13235
diff
changeset
|
96 |
|
8749 | 97 |
hour:h minute:m |
98 |
"compatibility" |
|
99 |
||
100 |
^ self hours:h minutes:m seconds:0 |
|
101 |
||
102 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
103 |
Time hour:2 minute:33 |
8749 | 104 |
" |
105 |
! |
|
106 |
||
7818 | 107 |
hour:h minute:m second:s |
108 |
"compatibility" |
|
109 |
||
110 |
^ self hours:h minutes:m seconds:s |
|
111 |
||
112 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
113 |
Time hour:2 minute:33 second:0 |
7818 | 114 |
" |
115 |
! |
|
116 |
||
6165 | 117 |
hour:h minutes:m seconds:s |
118 |
"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
|
119 |
See also Time now / Date today / Timestamp now. |
6165 | 120 |
Obsolete: please use #hours:minutes:seconds:" |
121 |
||
122 |
<resource:#obsolete> |
|
123 |
||
9061 | 124 |
self obsoleteMethodWarning:'use #hours:minutes:seconds:'. |
6165 | 125 |
|
126 |
^ self hours:h minutes:m seconds:s |
|
127 |
||
128 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
129 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
130 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
131 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
132 |
Time hours23 minutes:59 seconds:59 |
6165 | 133 |
" |
134 |
||
135 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
136 |
! |
|
137 |
||
138 |
hours:h minutes:m seconds:s |
|
4031 | 139 |
"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
|
140 |
See also Time now / Date today / Timestamp now." |
4031 | 141 |
|
6165 | 142 |
^ self basicNew setHours:h minutes:m seconds:s |
4031 | 143 |
|
144 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
145 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
146 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
147 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
148 |
Time hours:23 minutes:59 seconds:59 |
95 | 149 |
" |
6165 | 150 |
|
151 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
152 |
! |
|
153 |
||
16937 | 154 |
hours:h minutes:m seconds:s milliseconds:ms |
155 |
"return an instance of Time representing the given time. |
|
156 |
See also Time now / Date today / Timestamp now." |
|
157 |
||
158 |
^ self basicNew setHours:h minutes:m seconds:s milliseconds:ms |
|
159 |
||
160 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
161 |
Time hours:2 minutes:33 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
162 |
Time hours:0 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
163 |
Time hours:24 minutes:0 seconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
164 |
Time hours:23 minutes:59 seconds:59 |
16937 | 165 |
" |
166 |
||
167 |
"Modified: 19.4.1996 / 15:32:40 / cg" |
|
168 |
! |
|
169 |
||
7293 | 170 |
midnight |
171 |
"Answer a new instance at midnight." |
|
172 |
||
13235 | 173 |
^ self fromSeconds: 0 |
7293 | 174 |
|
175 |
" |
|
176 |
Time midnight |
|
177 |
" |
|
178 |
! |
|
179 |
||
180 |
noon |
|
181 |
"Answer a new instance at noon." |
|
182 |
||
13235 | 183 |
^ self fromSeconds: 43200 "12*60*60" |
7293 | 184 |
|
185 |
" |
|
186 |
Time noon |
|
187 |
" |
|
188 |
! |
|
189 |
||
6165 | 190 |
readFrom:aStringOrStream onError:exceptionBlock |
191 |
"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
|
192 |
If no am/pm follows the time, the string is interpreted as |
6165 | 193 |
either 24 hour format or being am." |
194 |
||
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6467
diff
changeset
|
195 |
^ [ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
196 |
|str hour min sec peekC millis| |
6165 | 197 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
198 |
str := aStringOrStream readStream. |
6165 | 199 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
200 |
hour := Integer readFrom:str. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
201 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
6165 | 202 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
203 |
min := 0. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
204 |
sec := 0. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
205 |
millis := 0. |
16940 | 206 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
207 |
str atEnd ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
208 |
peekC := str peek. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
209 |
(peekC == $:) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
210 |
str next. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
211 |
min := Integer readFrom:str. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
212 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
6165 | 213 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
214 |
(str peek == $:) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
215 |
str next. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
216 |
sec := Integer readFrom:str. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
217 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
218 |
(str peek == $.) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
219 |
str next. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
220 |
millis := ((Fraction readDecimalFractionFrom:str onError:[^ exceptionBlock value]) * 1000) asInteger. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
221 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
222 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
223 |
peekC := str peek. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
224 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
225 |
[peekC == Character space] whileTrue:[str next. peekC := str peek]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
226 |
(peekC == $p or:[peekC == $P]) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
227 |
str next. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
228 |
(str peek == $m or:[str peek == $M]) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
229 |
str next |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
230 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
231 |
(hour <= 0 or:[hour > 12]) ifTrue:[^ exceptionBlock value]. |
6165 | 232 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
233 |
"pm" |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
234 |
hour ~~ 12 ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
235 |
hour := hour + 12 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
236 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
237 |
peekC := str peek |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
238 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
239 |
(peekC == $a or:[peekC == $A]) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
240 |
str next. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
241 |
(str peek == $m or:[str peek == $M]) ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
242 |
str next |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
243 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
244 |
hour == 12 ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
245 |
hour := 0. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
246 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
247 |
hour > 12 ifTrue:[^ exceptionBlock value]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
248 |
peekC := str peek |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
249 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
250 |
"/ cg: dont be too picky here - we do not care, what comes after the |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
251 |
"/ time string. (Needed to be able to read rfc822 strings where a timezone |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
252 |
"/ 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
|
253 |
"/ 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
|
254 |
"/ 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
|
255 |
"/ ] |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
256 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
257 |
] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
258 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
259 |
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
|
260 |
] on:Error do:exceptionBlock. |
6165 | 261 |
|
262 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
263 |
Time readFrom:'0:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
264 |
Time readFrom:'2:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
265 |
Time readFrom:'12:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
266 |
Time readFrom:'14:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
267 |
Time readFrom:'23:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
268 |
Time readFrom:'24:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
269 |
Time readFrom:'2:30 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
270 |
Time readFrom:'2:30 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
271 |
Time readFrom:'14' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
272 |
Time readFrom:'2 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
273 |
Time readFrom:'2 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
274 |
Time readFrom:'12:05 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
275 |
Time readFrom:'12:06 am' |
6165 | 276 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
277 |
Time readFrom:'18:22:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
278 |
Time readFrom:'14:00:11' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
279 |
Time readFrom:'7:00:11' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
280 |
Time readFrom:'24:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
281 |
Time readFrom:'0:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
282 |
Time readFrom:'12:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
283 |
Time readFrom:'0:00:00' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
284 |
Time readFrom:'6:22:00 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
285 |
Time readFrom:'2:00:11 pm' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
286 |
Time readFrom:'7:00:11 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
287 |
Time readFrom:'12:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
288 |
Time readFrom:'0:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
289 |
Time readFrom:'24:00:00 am' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
290 |
Time readFrom:'12:00:00 pm' |
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6467
diff
changeset
|
291 |
Time readFrom:'0:00:00 pm' onError:'invalid' |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
292 |
Time readFrom:'24:00:00 pm' |
16940 | 293 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
294 |
Time readFrom:'13:00:00.5' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
295 |
Time readFrom:'13:00:00.123' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
296 |
Time readFrom:'1:00:00.123 pm' |
6165 | 297 |
" |
298 |
||
299 |
"Modified: 8.10.1996 / 19:32:11 / cg" |
|
13235 | 300 |
! |
301 |
||
302 |
utcNow |
|
17136 | 303 |
"return an instance of myself representing this moment in UTC. |
304 |
That is, the current time in London without any daylight saving adjustments." |
|
13235 | 305 |
|
306 |
^ self basicNew fromUtcOSTime:(OperatingSystem getOSTime) |
|
307 |
||
308 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
309 |
Timestamp now |
13235 | 310 |
Timestamp utcNow |
311 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
312 |
Time now |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
313 |
Time utcNow |
13235 | 314 |
" |
315 |
||
316 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
1 | 317 |
! ! |
318 |
||
6165 | 319 |
!Time class methodsFor:'format strings'! |
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
320 |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
321 |
defaultFormatString |
16985 | 322 |
"a language specific format string to present times in user interfaces. |
323 |
Do not use this to store/retrieve times (use ISO8601 for that)" |
|
324 |
||
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
325 |
LanguageTerritory == #us ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
326 |
^ self formatString12us |
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
327 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
328 |
^ self formatString24 |
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
329 |
] |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
330 |
|
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
331 |
"Created: / 16-01-2011 / 11:23:36 / cg" |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
332 |
! |
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
333 |
|
16940 | 334 |
defaultFormatStringWithMilliseconds |
335 |
LanguageTerritory == #us ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
336 |
^ self formatStringWithMilliseconds12us |
16940 | 337 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
338 |
^ self formatStringWithMilliseconds24 |
16940 | 339 |
] |
340 |
! |
|
341 |
||
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
342 |
formatString12us |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
343 |
"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
|
344 |
|
8231 | 345 |
^ '%u:%m:%s %A' |
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
346 |
! |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
347 |
|
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
348 |
formatString24 |
8231 | 349 |
"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
|
350 |
|
6164 | 351 |
^ '%h:%m:%s' |
16940 | 352 |
! |
353 |
||
354 |
formatStringWithMilliseconds12us |
|
355 |
"return the format string used to format US times (and other areas)" |
|
356 |
||
16949 | 357 |
^ '%u:%m:%s.%i %A' |
16940 | 358 |
! |
359 |
||
360 |
formatStringWithMilliseconds24 |
|
361 |
"return the format string used to format non US times" |
|
362 |
||
363 |
^ '%h:%m:%s.%i' |
|
6164 | 364 |
! ! |
365 |
||
16981 | 366 |
!Time methodsFor:'Compatibility-Backward'! |
367 |
||
368 |
asMilliSeconds |
|
369 |
<resource: #obsolete> |
|
370 |
"return the number of milliseconds elapsed since midnight" |
|
371 |
||
372 |
^ self asMilliseconds |
|
6164 | 373 |
|
16981 | 374 |
" |
375 |
Time now asMilliSeconds |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
376 |
(TimeDuration days:1) asMilliSeconds |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
377 |
(TimeDuration hours:1) asMilliSeconds |
16981 | 378 |
" |
13632 | 379 |
|
16981 | 380 |
"Created: / 05-09-2011 / 10:40:15 / cg" |
381 |
! ! |
|
382 |
||
383 |
!Time methodsFor:'Compatibility-Squeak'! |
|
13632 | 384 |
|
6164 | 385 |
intervalString |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
386 |
"Treat the time as a difference. |
6164 | 387 |
Give it in hours and minutes with two digits of accuracy." |
388 |
||
6467 | 389 |
|hours minutes seconds hh mm ss s| |
6164 | 390 |
|
391 |
hours := self hours. |
|
392 |
minutes := self minutes. |
|
393 |
seconds := self seconds. |
|
6467 | 394 |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
395 |
hours = 0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
396 |
ifTrue: [hh := ''] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
397 |
ifFalse: [ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
398 |
hh := hours printString, ' hour'. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
399 |
hours > 1 ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
400 |
hh := hh , 's' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
401 |
] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
402 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
403 |
minutes = 0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
404 |
ifTrue: [mm := ''] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
405 |
ifFalse: [ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
406 |
mm := minutes printString, ' minute'. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
407 |
minutes > 1 ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
408 |
mm := mm , 's' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
409 |
] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
410 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
411 |
seconds = 0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
412 |
ifTrue: [ss := ''] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
413 |
ifFalse: [ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
414 |
ss := seconds printString, ' second'. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
415 |
seconds > 1 ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
416 |
ss := ss , 's' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
417 |
] |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
418 |
]. |
6467 | 419 |
|
420 |
"/ do not show seconds, if hours are there |
|
6164 | 421 |
hh size > 0 ifTrue: [ss := '']. |
6467 | 422 |
|
423 |
s := hh. |
|
6873 | 424 |
mm notEmpty ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
425 |
s notEmpty ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
426 |
s := s , ' ' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
427 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
428 |
s := s , mm. |
6467 | 429 |
]. |
6873 | 430 |
ss notEmpty ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
431 |
s notEmpty ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
432 |
s := s , ' ' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
433 |
]. |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
434 |
s := s , ss |
6467 | 435 |
]. |
6873 | 436 |
^ s |
6164 | 437 |
|
438 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
439 |
(Time fromSeconds:3600) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
440 |
(Time fromSeconds:3605) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
441 |
(Time fromSeconds:3700) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
442 |
(Time fromSeconds:5) intervalString |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
443 |
(Time fromSeconds:65) intervalString |
6164 | 444 |
" |
445 |
! |
|
446 |
||
7024 | 447 |
print24:prnt24FormatBoolean on:aStream |
448 |
"print me either US or 24hr format on a stream" |
|
449 |
||
450 |
^ self print24:prnt24FormatBoolean showSeconds:true on:aStream |
|
451 |
||
452 |
" |
|
453 |
Time now print24:true on:Transcript. Transcript cr. |
|
454 |
Time now print24:false on:Transcript. Transcript cr. |
|
455 |
" |
|
456 |
! |
|
457 |
||
6164 | 458 |
print24:prnt24Format showSeconds:doSeconds on:aStream |
459 |
"print me either US or 24hr format, optionally with |
|
460 |
seconds on a stream" |
|
461 |
||
462 |
|format| |
|
463 |
||
464 |
prnt24Format ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
465 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
466 |
format := '%h:%m:%s' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
467 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
468 |
format := '%h:%m' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
469 |
]. |
6164 | 470 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
471 |
"/ US format |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
472 |
doSeconds ifTrue:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
473 |
format := '%u:%m:%s %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
474 |
] ifFalse:[ |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
475 |
format := '%u:%m %a' |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
476 |
]. |
6164 | 477 |
]. |
478 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
479 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
480 |
format:format. |
6164 | 481 |
|
482 |
" |
|
483 |
Time now print24:true showSeconds:true on:Transcript. Transcript cr. |
|
484 |
Time now print24:false showSeconds:true on:Transcript. Transcript cr. |
|
485 |
Time now print24:true showSeconds:false on:Transcript. Transcript cr. |
|
486 |
Time now print24:false showSeconds:false on:Transcript. Transcript cr. |
|
487 |
" |
|
4411
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
488 |
! ! |
684a2b944463
much improved formatting (see #printOn:format:)
Claus Gittinger <cg@exept.de>
parents:
4392
diff
changeset
|
489 |
|
6164 | 490 |
!Time methodsFor:'accessing'! |
491 |
||
492 |
hours |
|
493 |
"return the number of hours since midnight (i.e. 0..23)" |
|
494 |
||
495 |
^ self getSeconds // 3600 |
|
496 |
||
497 |
" |
|
498 |
Time now hours |
|
499 |
" |
|
500 |
! |
|
275 | 501 |
|
4845 | 502 |
milliseconds |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
503 |
"get the milliseconds part |
16981 | 504 |
(notice: that is NOT the total number of millis (since midnight), |
16940 | 505 |
but the fractional part only. Use this only for printing" |
6164 | 506 |
|
16940 | 507 |
^ timeEncoding \\ 1000 |
6164 | 508 |
! |
509 |
||
510 |
minutes |
|
511 |
"return the number of minutes within the hour (i.e. 0..59)" |
|
512 |
||
513 |
^ (self getSeconds \\ 3600) // 60 |
|
514 |
||
515 |
" |
|
516 |
Time now minutes |
|
517 |
" |
|
518 |
! |
|
519 |
||
520 |
seconds |
|
521 |
"return the number of seconds within the minute (i.e. 0..59)" |
|
522 |
||
7733 | 523 |
^ self getSeconds \\ 60 |
6164 | 524 |
|
525 |
" |
|
526 |
Time now seconds |
|
527 |
" |
|
528 |
! |
|
529 |
||
9441 | 530 |
timeZoneDeltaInMinutes |
531 |
"answer the number of minutes between local time and utc time. |
|
532 |
Delta is positive if local time is ahead of utc, negative if behind utc. |
|
533 |
||
16985 | 534 |
Time is local time, so ask a local timestamp" |
9441 | 535 |
|
536 |
^ Timestamp now timeZoneDeltaInMinutes |
|
537 |
||
538 |
||
539 |
" |
|
540 |
Time now timeZoneDeltaInMinutes |
|
541 |
" |
|
1 | 542 |
! ! |
543 |
||
6164 | 544 |
!Time methodsFor:'comparing'! |
545 |
||
546 |
< aTime |
|
547 |
"return true if the receiver is before the argument" |
|
548 |
||
17141 | 549 |
|milliseconds| |
550 |
||
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
551 |
aTime class == self class ifTrue:[ |
17141 | 552 |
^ timeEncoding < aTime timeEncoding |
553 |
]. |
|
554 |
aTime isNumber ifTrue:[ |
|
555 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
556 |
milliseconds := (aTime * 1000) asInteger. "integer seconds" |
|
557 |
] ifFalse:[ |
|
558 |
milliseconds := aTime getMilliseconds. |
|
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
559 |
]. |
17141 | 560 |
^ self getMilliseconds < milliseconds |
561 |
||
562 |
" |
|
563 |
(Timestamp now + 10) - Timestamp now < 10 |
|
564 |
(Timestamp now + 10) - Timestamp now < 11 |
|
565 |
" |
|
566 |
! |
|
567 |
||
568 |
<= aTime |
|
569 |
"return true if the receiver is before the argument" |
|
570 |
||
571 |
|milliseconds| |
|
572 |
||
573 |
aTime class == self class ifTrue:[ |
|
574 |
^ timeEncoding <= aTime timeEncoding |
|
575 |
]. |
|
576 |
aTime isNumber ifTrue:[ |
|
577 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
578 |
milliseconds := (aTime * 1000) asInteger. "integer seconds" |
|
579 |
] ifFalse:[ |
|
580 |
milliseconds := aTime getMilliseconds. |
|
581 |
]. |
|
582 |
^ self getMilliseconds <= milliseconds |
|
583 |
||
584 |
" |
|
585 |
(Timestamp now + 10) - Timestamp now <= 10 |
|
586 |
(Timestamp now + 10) - Timestamp now <= 11 |
|
587 |
(Timestamp now + 10) - Timestamp now <= 9 |
|
588 |
" |
|
6164 | 589 |
! |
590 |
||
591 |
= aTime |
|
592 |
"return true if the argument, aTime represents the same timeOfDay" |
|
593 |
||
17141 | 594 |
|milliseconds| |
595 |
||
6164 | 596 |
aTime class == self class ifTrue:[ |
17141 | 597 |
^ timeEncoding = aTime timeEncoding |
6164 | 598 |
]. |
17141 | 599 |
aTime isNumber ifTrue:[ |
600 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
601 |
milliseconds := (aTime * 1000) asInteger. "integer seconds" |
|
602 |
] ifFalse:[ |
|
603 |
aTime species == self species ifFalse:[^ false]. |
|
604 |
milliseconds := aTime getMilliseconds. |
|
605 |
]. |
|
606 |
^ self getMilliseconds = milliseconds |
|
10666
609bedc85066
changed #'=' (for largeinteger timeEncodings in TimeDuration)
Claus Gittinger <cg@exept.de>
parents:
9441
diff
changeset
|
607 |
|
17141 | 608 |
" |
609 |
(Timestamp now + 10) - Timestamp now = 10 |
|
610 |
(Timestamp now + 10) - Timestamp now = 9 |
|
611 |
" |
|
6164 | 612 |
! |
613 |
||
614 |
> aTime |
|
615 |
"return true if the receiver is before the argument" |
|
616 |
||
17141 | 617 |
|milliseconds| |
618 |
||
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
619 |
aTime class == self class ifTrue:[ |
17141 | 620 |
^ timeEncoding > aTime timeEncoding |
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
621 |
]. |
17141 | 622 |
aTime isNumber ifTrue:[ |
623 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
624 |
milliseconds := (aTime * 1000) asInteger. "integer seconds" |
|
625 |
] ifFalse:[ |
|
626 |
milliseconds := aTime getMilliseconds. |
|
627 |
]. |
|
628 |
^ self getMilliseconds > milliseconds |
|
629 |
||
630 |
" |
|
631 |
(Timestamp now + 10) - Timestamp now > 10 |
|
632 |
(Timestamp now + 10) - Timestamp now > 9 |
|
633 |
" |
|
6164 | 634 |
! |
635 |
||
636 |
hash |
|
637 |
"return an integer useful for hashing on times" |
|
638 |
||
10744
afd1835c12d2
comparison did only care for seconds, when used with timeDurations
sr
parents:
10666
diff
changeset
|
639 |
^ timeEncoding |
6164 | 640 |
! ! |
641 |
||
642 |
!Time methodsFor:'converting'! |
|
643 |
||
13235 | 644 |
asLocalTimestamp |
645 |
"return an Timestamp object from the receiver. |
|
646 |
So I am interpreted as a Time in the local timezone. |
|
647 |
The date components are taken from today." |
|
648 |
||
649 |
|todayTimestamp| |
|
650 |
||
651 |
todayTimestamp := Timestamp now. |
|
652 |
todayTimestamp year:todayTimestamp year month:todayTimestamp month day:todayTimestamp day |
|
17141 | 653 |
hour:(self hours) minute:(self minutes) second:(self seconds) |
654 |
millisecond:(self milliseconds). |
|
13235 | 655 |
|
656 |
^ todayTimestamp. |
|
657 |
||
658 |
" |
|
659 |
Time now asLocalTimestamp |
|
660 |
" |
|
661 |
! |
|
662 |
||
699 | 663 |
asTime |
16981 | 664 |
"return a Time object from the receiver - that's the receiver." |
699 | 665 |
|
6164 | 666 |
^ self |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
667 |
! |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
668 |
|
8796 | 669 |
asTimeDuration |
670 |
"return an TimeDuration object from the receiver, taking the time since midnight." |
|
671 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
672 |
^ TimeDuration |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
673 |
hours:(self hours) minutes:(self minutes) seconds:(self seconds) |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
674 |
milliseconds:(self milliseconds) |
8796 | 675 |
" |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
676 |
Time now asTimeDuration |
8796 | 677 |
" |
678 |
! |
|
679 |
||
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
680 |
asTimestamp |
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
681 |
"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
|
682 |
The date components are taken from today." |
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
683 |
|
13235 | 684 |
^ self asLocalTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
685 |
|
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
686 |
" |
8994
cbf9e75584fe
asTimeStamp -> asTimestamp for AbstractTime protocol compatibility
Stefan Vogel <sv@exept.de>
parents:
8796
diff
changeset
|
687 |
Time now asTimestamp |
8249
bdcae1232e6d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8231
diff
changeset
|
688 |
" |
13235 | 689 |
! |
690 |
||
691 |
asUtcTimestamp |
|
692 |
"return an UtcTimestamp object from the receiver. |
|
693 |
So I am interpreted as a Time in the UTC zone. |
|
694 |
The date components are taken from today." |
|
695 |
||
696 |
|todayTimestamp| |
|
697 |
||
16981 | 698 |
todayTimestamp := Timestamp now. |
13235 | 699 |
todayTimestamp year:todayTimestamp year month:todayTimestamp month day:todayTimestamp day |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
700 |
hour:(self hours) minute:(self minutes) second:(self seconds) |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
701 |
millisecond:(self milliseconds). |
13235 | 702 |
|
16981 | 703 |
^ todayTimestamp asUtcTimestamp. |
13235 | 704 |
|
705 |
" |
|
16981 | 706 |
Time now asUtcTimestamp |
13235 | 707 |
" |
699 | 708 |
! ! |
709 |
||
17641 | 710 |
|
6164 | 711 |
!Time methodsFor:'printing & storing'! |
712 |
||
713 |
print12HourFormatOn:aStream |
|
11151 | 714 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 715 |
Format is hh:mm:ss am/pm (i.e. 12-hour american format)." |
716 |
||
717 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
718 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
719 |
format:(self class formatString12us) |
6164 | 720 |
|
721 |
"/ |h m s ampm| |
|
722 |
"/ |
|
723 |
"/ h := self hours. |
|
724 |
"/ |
|
725 |
"/ "/ 0 -> 12 am |
|
726 |
"/ "/ 12 -> 12 pm |
|
727 |
"/ |
|
728 |
"/ h // 12 == 0 ifTrue:[ |
|
729 |
"/ ampm := ' am'. |
|
730 |
"/ ] ifFalse:[ |
|
731 |
"/ ampm := ' pm'. |
|
732 |
"/ ]. |
|
733 |
"/ |
|
734 |
"/ h == 0 ifFalse:[ |
|
735 |
"/ h := h - 1 \\ 12 + 1. |
|
736 |
"/ ]. |
|
737 |
"/ |
|
738 |
"/ h printOn:aStream. |
|
739 |
"/ aStream nextPut:$:. |
|
740 |
"/ m := self minutes. |
|
741 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
742 |
"/ m printOn:aStream. |
|
743 |
"/ aStream nextPut:$:. |
|
744 |
"/ s := self seconds. |
|
745 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
746 |
"/ s printOn:aStream. |
|
747 |
"/ aStream nextPutAll:ampm |
|
748 |
||
749 |
" |
|
750 |
Time now print12HourFormatOn:Transcript. Transcript cr |
|
751 |
(Time now subtractHours:12) print12HourFormatOn:Transcript. Transcript cr |
|
752 |
(Time hour:24 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
753 |
(Time hour:12 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
754 |
(Time hour:0 minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
|
755 |
0 to:24 do:[:h | |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
756 |
(Time hour:h minutes:0 seconds:0) print12HourFormatOn:Transcript. Transcript cr |
6164 | 757 |
] |
758 |
" |
|
759 |
! |
|
760 |
||
761 |
print24HourFormatOn:aStream |
|
11151 | 762 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 763 |
Format is hh:mm:ss (i.e. 24-hour european format)." |
764 |
||
765 |
^ self |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
766 |
printOn:aStream |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
767 |
format:(self class formatString24). |
6164 | 768 |
|
769 |
"/ |h m s| |
|
770 |
"/ |
|
771 |
"/ h := self hours. |
|
772 |
"/ (h < 10) ifTrue:[aStream nextPut:$0]. |
|
773 |
"/ h printOn:aStream. |
|
774 |
"/ aStream nextPut:$:. |
|
775 |
"/ m := self minutes. |
|
776 |
"/ (m < 10) ifTrue:[aStream nextPut:$0]. |
|
777 |
"/ m printOn:aStream. |
|
778 |
"/ aStream nextPut:$:. |
|
779 |
"/ s := self seconds. |
|
780 |
"/ (s < 10) ifTrue:[aStream nextPut:$0]. |
|
781 |
"/ s printOn:aStream |
|
782 |
||
783 |
" |
|
784 |
Time now print24HourFormatOn:Transcript. Transcript cr |
|
785 |
" |
|
786 |
! |
|
787 |
||
788 |
printOn:aStream |
|
11151 | 789 |
"append a human readable printed representation of the receiver to aStream. |
6164 | 790 |
The format is suitable for a human - not meant to be read back. |
791 |
||
792 |
Format is hh:mm:ss either in 12-hour or 24-hour format. |
|
793 |
depending on the setting of LanguageTerritory. |
|
17162 | 794 |
I don't know what ST-80 does here (12-hour format ?)" |
6164 | 795 |
|
16940 | 796 |
|format| |
797 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
798 |
format := (self milliseconds = 0) |
17162 | 799 |
ifTrue:[self class defaultFormatString] |
800 |
ifFalse:[self class defaultFormatStringWithMilliseconds]. |
|
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
801 |
^ self |
17162 | 802 |
printOn:aStream |
803 |
format:format |
|
6164 | 804 |
|
805 |
" |
|
806 |
Time now printOn:Transcript. Transcript cr |
|
807 |
" |
|
808 |
||
13213
d37c29bad3da
added: #defaultFormatString
Claus Gittinger <cg@exept.de>
parents:
12829
diff
changeset
|
809 |
"Modified: / 16-01-2011 / 11:27:24 / cg" |
6164 | 810 |
! |
811 |
||
812 |
printString12HourFormat |
|
813 |
"return a printed representation in 12 hour format" |
|
814 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
815 |
^ self printStringFormat:(self class formatString12us) |
6164 | 816 |
|
817 |
" |
|
818 |
Time now printString12HourFormat |
|
819 |
" |
|
820 |
! |
|
821 |
||
822 |
printString24HourFormat |
|
823 |
"return a printed representation in 24 hour format" |
|
824 |
||
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
825 |
^ self printStringFormat:(self class formatString24) |
6164 | 826 |
|
827 |
" |
|
828 |
Time now printString24HourFormat |
|
829 |
" |
|
830 |
||
831 |
! |
|
832 |
||
833 |
shortPrintString |
|
834 |
"dummy - for now" |
|
835 |
||
836 |
^ self printString |
|
837 |
||
838 |
"Created: 20.6.1997 / 17:17:01 / cg" |
|
839 |
! ! |
|
840 |
||
841 |
!Time methodsFor:'private'! |
|
842 |
||
843 |
fromOSTime:osTime |
|
13235 | 844 |
"set my time in the local timezone, given an osTime" |
6164 | 845 |
|
7513 | 846 |
|i| |
6164 | 847 |
|
7513 | 848 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
7740 | 849 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
6164 | 850 |
|
851 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
852 |
! |
|
275 | 853 |
|
16940 | 854 |
fromOSTimeWithMilliseconds:osTime |
855 |
"set my time in the local timezone, given an osTime" |
|
856 |
||
857 |
|i| |
|
858 |
||
859 |
i := OperatingSystem computeTimeAndDateFrom:osTime. |
|
860 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) milliseconds:(i milliseconds) |
|
861 |
! |
|
862 |
||
13235 | 863 |
fromUtcOSTime:osTime |
864 |
"set my time in the local timezone, given an osTime" |
|
865 |
||
866 |
|i| |
|
867 |
||
868 |
i := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
869 |
self setHours:(i hours) minutes:(i minutes) seconds:(i seconds) |
|
870 |
||
871 |
"Modified: 1.7.1996 / 15:21:06 / cg" |
|
872 |
! |
|
873 |
||
3477 | 874 |
getMilliseconds |
6046 | 875 |
"return the number of milliseconds since midnight" |
876 |
||
16933 | 877 |
^ timeEncoding |
3477 | 878 |
! |
879 |
||
275 | 880 |
getSeconds |
6046 | 881 |
"return the number of seconds since midnight" |
882 |
||
16933 | 883 |
^ timeEncoding // 1000 |
275 | 884 |
! |
885 |
||
6165 | 886 |
setHours:h minutes:m seconds:s |
699 | 887 |
"set my time given individual values" |
888 |
||
6165 | 889 |
self setSeconds:(((h\\24) * 60 * 60 ) + (m * 60) + s). |
3477 | 890 |
! |
891 |
||
16937 | 892 |
setHours:h minutes:m seconds:s milliseconds:ms |
893 |
"set my time given individual values" |
|
894 |
||
895 |
self setMilliseconds:((((h\\24) * 60 * 60 ) + (m * 60) + s) * 1000) + ms. |
|
896 |
! |
|
897 |
||
3477 | 898 |
setMilliseconds:millis |
16933 | 899 |
"set my time given milliseconds since midnight. |
900 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
|
901 |
(use TimeDuration, if you need that)." |
|
3477 | 902 |
|
16933 | 903 |
millis < 0 ifTrue:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
904 |
timeEncoding := (24 * 3600 * 1000) - (millis negated \\ (24 * 3600 * 1000)) |
16933 | 905 |
] ifFalse:[ |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
906 |
timeEncoding := millis |
16933 | 907 |
]. |
908 |
timeEncoding >= (24 * 3600 * 1000) ifTrue:[ |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
909 |
timeEncoding := timeEncoding \\ (24 * 3600 * 1000). |
16933 | 910 |
] |
911 |
||
912 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
913 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
914 |
Time fromSeconds:3601 |
16933 | 915 |
Time now seconds |
916 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
917 |
(Time now addDays:5) seconds |
16933 | 918 |
(Time now addDays:5) timeEncoding |
919 |
" |
|
699 | 920 |
! |
921 |
||
6904 | 922 |
setSeconds:secs |
923 |
"set my time given seconds since midnight. |
|
9441 | 924 |
Notice the modulo operations here - there cannot be a time beyond 24hours |
6904 | 925 |
(use TimeDuration, if you need that)." |
926 |
||
16933 | 927 |
self setMilliseconds:secs * 1000 |
6904 | 928 |
|
929 |
" |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
930 |
Time basicNew setSeconds:0 |
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
931 |
Time fromSeconds:3601 |
6904 | 932 |
Time now seconds |
933 |
Time now timeEncoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
934 |
(Time now addDays:5) seconds |
6904 | 935 |
(Time now addDays:5) timeEncoding |
936 |
" |
|
937 |
! |
|
938 |
||
6165 | 939 |
timeEncoding |
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
940 |
"the internal encoding is stricktly private, |
6165 | 941 |
and should not be used outside." |
942 |
||
943 |
^ timeEncoding |
|
944 |
! |
|
945 |
||
946 |
timeEncoding:encoding |
|
17066
983f61f73c8f
wrong parenthesis (fraction asInteger)
Claus Gittinger <cg@exept.de>
parents:
16985
diff
changeset
|
947 |
"the internal encoding is stricktly private, |
6165 | 948 |
and should not be used outside." |
949 |
||
950 |
timeEncoding := encoding |
|
699 | 951 |
! ! |
952 |
||
6165 | 953 |
!Time class methodsFor:'documentation'! |
241 | 954 |
|
699 | 955 |
version |
17641 | 956 |
^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.103 2015-03-24 07:20:13 cg Exp $' |
12728 | 957 |
! |
958 |
||
959 |
version_CVS |
|
17641 | 960 |
^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.103 2015-03-24 07:20:13 cg Exp $' |
241 | 961 |
! ! |
17136 | 962 |