author | Jan Vrany <jan.vrany@labware.com> |
Wed, 23 Jun 2021 12:50:05 +0100 | |
branch | jv |
changeset 25430 | acd92449dc30 |
parent 25423 | bcfde4da086a |
permissions | -rw-r--r-- |
16356 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
16357 | 12 |
"{ Package: 'stx:libbasic' }" |
16356 | 13 |
|
17388 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
16356 | 16 |
Time subclass:#TimeDuration |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
17 |
instanceVariableNames:'additionalPicoseconds' |
19849 | 18 |
classVariableNames:'DefaultFormatForPrinting TimeDurationZero' |
16356 | 19 |
poolDictionaries:'' |
20 |
category:'Magnitude-Time' |
|
21 |
! |
|
22 |
||
23 |
!TimeDuration class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
41 |
Represents a time/timestamp difference. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
42 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
43 |
The resolution is 1 picosecond. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
44 |
However, such small timedurations are usually only created by physical computations (see goodies/physic), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
45 |
or when reading timestamps from external measurement equipment. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
46 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
47 |
The typical OS-time resolution is in the milli- or microsecond range. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
48 |
External logging hardware may generate timestamps in the micro- or nanosecond range, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
49 |
and picosecond resolution should be good enough for almost any application (at least for the near future). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
50 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
51 |
Most timedurations only require/have millisecond resolution, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
52 |
so the picoseconds are held in a separate instvar (which is often nil or zero) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
53 |
and does on most cases not require aditional slow largeInteger operations. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
54 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
55 |
[class variables:] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
56 |
DefaultFormatForPrinting if non-nil, allows for the variable printFormat to be overwritten |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
57 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
58 |
[author:] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
59 |
Claus Gittinger |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
60 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
61 |
[see also:] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
62 |
Date Time Timestamp AbstractTime OperatingSystem |
16356 | 63 |
" |
64 |
! ! |
|
65 |
||
66 |
!TimeDuration class methodsFor:'instance creation'! |
|
67 |
||
68 |
days:d |
|
69 |
"return a new TimeDuration representing a duration of d days." |
|
70 |
||
71 |
d == 0 ifTrue:[^ TimeDurationZero]. |
|
72 |
^ self hours:(d*24) minutes:0 |
|
73 |
||
74 |
" |
|
75 |
TimeDuration days:1 |
|
76 |
" |
|
77 |
! |
|
78 |
||
79 |
days:d hours:h minutes:m seconds:s |
|
80 |
"return a new TimeDuration representing a duration of d days, h hours, m minutes and s seconds. |
|
81 |
See also Time now / Date today / Timestamp now." |
|
82 |
||
83 |
^ self basicNew |
|
84 |
setHours:(d*24)+h minutes:m seconds:s milliseconds:0 |
|
85 |
||
86 |
" |
|
87 |
TimeDuration days:1 hours:2 minutes:33 seconds:0 |
|
88 |
TimeDuration days:4 hours:100 minutes:33 seconds:0 |
|
89 |
" |
|
90 |
! |
|
91 |
||
92 |
fromHours:hoursInterval |
|
93 |
"return a new TimeDuration representing a duration of n hours." |
|
94 |
||
95 |
^ self new setSeconds:(hoursInterval * (60*60)) |
|
96 |
||
97 |
" |
|
98 |
TimeDuration fromHours:8 |
|
99 |
" |
|
100 |
! |
|
101 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
102 |
fromMicroseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
103 |
"return a new TimeDuration representing a duration of n microseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
104 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
105 |
^ self new setMicroseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
106 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
107 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
108 |
TimeDuration fromMicroseconds:500 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
109 |
500 microseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
110 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
111 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
112 |
"Created: / 18-07-2007 / 13:56:25 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
113 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
114 |
|
16356 | 115 |
fromMilliseconds:n |
116 |
"return a new TimeDuration representing a duration of n milliseconds." |
|
117 |
"redefined to disable wrapping at 24hours." |
|
118 |
||
119 |
^ self new setMilliseconds:n |
|
120 |
||
121 |
" |
|
122 |
TimeDuration fromMilliseconds:500 |
|
123 |
500 milliseconds |
|
124 |
" |
|
125 |
||
126 |
"Created: / 18-07-2007 / 13:56:25 / cg" |
|
127 |
! |
|
128 |
||
129 |
fromMinutes:minutesInterval |
|
130 |
"return a new TimeDuration representing a duration of n minutes." |
|
131 |
||
132 |
^ self new setSeconds:(minutesInterval * 60) |
|
133 |
||
134 |
" |
|
135 |
TimeDuration fromMinutes:120 |
|
136 |
" |
|
137 |
! |
|
138 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
139 |
fromNanoseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
140 |
"return a new TimeDuration representing a duration of n nanoseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
141 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
142 |
^ self new setNanoseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
143 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
144 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
145 |
TimeDuration fromNanoseconds:500 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
146 |
500 nanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
147 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
148 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
149 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
150 |
fromPicoseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
151 |
"return a new TimeDuration representing a duration of n picoseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
152 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
153 |
^ self new setPicoseconds:n |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
154 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
155 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
156 |
TimeDuration fromPicoseconds:500 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
157 |
500 picoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
158 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
159 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
160 |
|
16356 | 161 |
fromSeconds:secondsInterval |
162 |
"return a new TimeDuration representing a duration of n seconds." |
|
163 |
"redefined to disable wrapping at 24hours." |
|
164 |
||
165 |
^ self new setSeconds:secondsInterval |
|
166 |
||
167 |
" |
|
168 |
TimeDuration fromSeconds:3600 |
|
169 |
" |
|
170 |
! |
|
171 |
||
172 |
hours:h |
|
173 |
"return a new TimeDuration representing a duration of h hours. |
|
174 |
See also Time now / Date today / Timestamp now." |
|
175 |
||
176 |
h == 0 ifTrue:[^ TimeDurationZero]. |
|
177 |
^ self basicNew setHours:h minutes:0 seconds:0 milliseconds:0 |
|
178 |
||
179 |
" |
|
180 |
TimeDuration hours:2 |
|
181 |
TimeDuration hours:100 |
|
182 |
" |
|
183 |
||
184 |
"Created: / 14-07-2007 / 18:15:51 / cg" |
|
185 |
! |
|
186 |
||
187 |
hours:h minutes:m seconds:s millis:millis |
|
188 |
<resource: #obsolete> |
|
189 |
"return a new TimeDuration representing a duration of h hours, m minutes, s seconds and millis milliseconds. |
|
190 |
See also Time now / Date today / Timestamp now." |
|
191 |
||
192 |
self obsoleteMethodWarning:'use hours:minutes:seconds:milliseconds:'. |
|
193 |
^ self hours:h minutes:m seconds:s milliseconds:millis |
|
194 |
||
195 |
" |
|
196 |
TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123 |
|
197 |
TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123 |
|
198 |
" |
|
199 |
! |
|
200 |
||
16872 | 201 |
microseconds:microseconds |
202 |
"return a new TimeDuration representing a duration of microseconds microseconds. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
203 |
Now we support microseconds (even picoseconds) but we still round to milliseconds for backward |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
204 |
compatibility with the historic interface." |
16872 | 205 |
|
206 |
microseconds == 0 ifTrue:[^ TimeDurationZero]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
207 |
^ self basicNew setMicroseconds:microseconds rounded. |
16872 | 208 |
|
209 |
" |
|
210 |
TimeDuration microseconds:2499 |
|
211 |
TimeDuration microseconds:2500 |
|
18564 | 212 |
TimeDuration microseconds:12345678900 |
16872 | 213 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
214 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
215 |
"Modified: / 02-03-2020 / 14:16:07 / Stefan Vogel" |
16872 | 216 |
! |
217 |
||
16356 | 218 |
milliseconds:m |
219 |
"return a new TimeDuration representing a duration of m millis. |
|
220 |
See also Time now / Date today / Timestamp now." |
|
221 |
||
222 |
m == 0 ifTrue:[^ TimeDurationZero]. |
|
16872 | 223 |
^ self basicNew setMilliseconds:m |
16356 | 224 |
|
225 |
" |
|
226 |
TimeDuration milliseconds:2 |
|
227 |
" |
|
228 |
! |
|
229 |
||
230 |
minutes:m |
|
231 |
"return a new TimeDuration representing a duration of m minutes. |
|
232 |
See also Time now / Date today / Timestamp now." |
|
233 |
||
234 |
m == 0 ifTrue:[^ TimeDurationZero]. |
|
235 |
^ self basicNew setHours:0 minutes:m seconds:0 milliseconds:0 |
|
236 |
||
237 |
" |
|
238 |
TimeDuration minutes:2 |
|
239 |
" |
|
240 |
||
241 |
"Created: / 06-08-2007 / 15:32:42 / cg" |
|
242 |
! |
|
243 |
||
20704 | 244 |
readFrom:aStringOrStream defaultUnit:defaultUnitOrNilArg onError:exceptionBlock |
16356 | 245 |
"return a new TimeDuration, reading a printed representation from aStream. |
246 |
The format is either: |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
247 |
[n 'yr'] [n 'mon'] [n 'w'] [n 'd'] [n 'h'] [n 'm'] [n 's'] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
248 |
([n 'ms'] | [n 'us'] | [n 'ns'] | [n 'ps']) |
16356 | 249 |
where |
250 |
yr -> year |
|
251 |
mon -> month |
|
252 |
w -> week |
|
253 |
d -> day |
|
254 |
h -> hour |
|
255 |
m -> minutes |
|
256 |
s -> seconds |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
257 |
ms -> milliseconds (only one of ms,us,ns or ps can follow) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
258 |
us -> microseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
259 |
ns -> nanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
260 |
ps -> picoseconds |
16356 | 261 |
or: |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
262 |
h:m:s.<ms2> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
263 |
h:m:s.<fract> |
16356 | 264 |
|
265 |
The yr and mon specifiers stand for 365d and 30d respectively. |
|
266 |
If defaultUnitOrNil is non-nil, a plain number is treated as that; |
|
267 |
otherwise, a plain number raises an error. |
|
20704 | 268 |
Individual components may be negative, as in '1h -10m', which gives 50m |
269 |
or the whole duration may be negative, as in '-(1h 10m)' |
|
16356 | 270 |
" |
271 |
||
272 |
^ [ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
273 |
|seconds millis picos restMillis |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
274 |
t1 str val fraction mantissa uIdx unit unitChar1 negative defaultUnitOrNil| |
16356 | 275 |
|
20704 | 276 |
defaultUnitOrNil := defaultUnitOrNilArg. |
16356 | 277 |
str := aStringOrStream readStream. |
278 |
seconds := 0. |
|
279 |
millis := 0. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
280 |
picos := 0. |
20704 | 281 |
|
282 |
negative := false. |
|
283 |
str peek == $- ifTrue:[ |
|
284 |
str next. |
|
285 |
str peek == $( ifTrue:[ |
|
286 |
|t| |
|
287 |
str next. |
|
288 |
t := self readFrom:str defaultUnit:defaultUnitOrNil onError:[^ exceptionBlock value]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
289 |
str skipSeparators == $) ifTrue:[ |
20704 | 290 |
str next. |
291 |
^ t negated. |
|
292 |
]. |
|
293 |
^ exceptionBlock value. |
|
294 |
]. |
|
295 |
negative := true. |
|
296 |
]. |
|
297 |
||
16356 | 298 |
[ |
299 |
|nextCh| |
|
300 |
||
301 |
val := Integer readFrom:str onError:nil. |
|
302 |
val isNil ifTrue:[^ exceptionBlock value]. |
|
20704 | 303 |
negative ifTrue:[ val := val negated. negative := false. ]. |
16356 | 304 |
str peek == $: ifTrue:[ |
305 |
"/ hour:minutes format |
|
306 |
str next. |
|
307 |
seconds := val*3600. |
|
308 |
val := Integer readFrom:str onError:nil. |
|
309 |
val isNil ifTrue:[^ exceptionBlock value]. |
|
310 |
seconds := seconds + (val*60). |
|
311 |
str peek == $: ifTrue:[ |
|
312 |
"/ hour:minutes:seconds format |
|
313 |
str next. |
|
314 |
val := Integer readFrom:str onError:nil. |
|
315 |
val isNil ifTrue:[^ exceptionBlock value]. |
|
316 |
seconds := seconds + val. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
317 |
(str peek == $. or:[str peek == $,]) ifTrue:[ |
16356 | 318 |
"/ hour:minutes:seconds.millis format |
319 |
str next. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
320 |
"/ the old code here was wrong in assuming that exactly 3 digits |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
321 |
"/ are coming; thus hh:mm:ss.1 was interpreted as 1ms (instead of 100) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
322 |
"/ thus: count the zeros... |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
323 |
str peek isDigit ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
324 |
"/ fraction := Number readMantissaFrom:str radix:10. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
325 |
"/ fraction isNil ifTrue:[^ exceptionBlock value]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
326 |
"/ ignore the float value; take the fraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
327 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
328 |
mantissa := Number readMantissaAndScaleFrom:str radix:10. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
329 |
fraction := (mantissa at:2) / (10 raisedTo:(mantissa at:3)). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
330 |
(mantissa at:3) > 3 ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
331 |
picos := fraction * (1000 * 1000 * 1000 * 1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
332 |
millis := picos // (1000 * 1000 * 1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
333 |
picos := picos \\ (1000 * 1000 * 1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
334 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
335 |
millis := fraction * 1000. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
336 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
337 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
338 |
millis := 0 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
339 |
]. |
16356 | 340 |
] |
341 |
]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
342 |
t1 := self fromMilliseconds:(seconds*1000+millis). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
343 |
picos notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
344 |
t1 additionalPicoseconds:picos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
345 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
346 |
^ t1 |
16356 | 347 |
]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
348 |
((str peek == $.) or:[(str peek == $,)]) ifTrue:[ |
16356 | 349 |
str next. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
350 |
"/ fraction := Number readMantissaFrom:str radix:10. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
351 |
"/ ignore the float value; take the fraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
352 |
mantissa := Number readMantissaAndScaleFrom:str radix:10. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
353 |
fraction := (mantissa at:2) / (10 raisedTo:(mantissa at:3)). |
16356 | 354 |
val := val + fraction. |
355 |
]. |
|
356 |
str skipSeparators. |
|
357 |
str atEnd ifTrue:[ |
|
358 |
defaultUnitOrNil isNil ifTrue:[ |
|
359 |
^ exceptionBlock value |
|
360 |
]. |
|
361 |
"/ no unit given - assume defaultUnit |
|
362 |
unitChar1 := defaultUnitOrNil. |
|
20704 | 363 |
"/ can be only used for one number |
364 |
defaultUnitOrNil := nil. |
|
16356 | 365 |
] ifFalse:[ |
366 |
unitChar1 := str next. |
|
367 |
]. |
|
368 |
||
369 |
str atEnd ifFalse:[ |
|
370 |
nextCh := str peek |
|
371 |
]. |
|
372 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
373 |
"/ milli, micro, nano and pico |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
374 |
unitChar1 == $µ ifTrue:[ unitChar1 := $u]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
375 |
uIdx := 'munp' indexOf:unitChar1. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
376 |
((uIdx ~~ 0) and:[nextCh == $s]) ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
377 |
unitChar1 == $m ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
378 |
millis := millis + val. |
16356 | 379 |
] ifFalse:[ |
380 |
unit := #( |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
381 |
1000000 "us" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
382 |
1000 "ns" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
383 |
1 "ps" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
384 |
) at:uIdx-1. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
385 |
picos := (unit * val). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
386 |
millis := picos // (1000 * 1000 * 1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
387 |
picos := picos \\ (1000 * 1000 * 1000). |
16356 | 388 |
]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
389 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
390 |
uIdx := 'ywdhms' indexOf:unitChar1. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
391 |
uIdx == 0 ifTrue:[^ exceptionBlock value]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
392 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
393 |
(unitChar1 == $m and:[nextCh == $s]) ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
394 |
millis := millis + val. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
395 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
396 |
(unitChar1 == $m and:[nextCh == $o]) ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
397 |
unit := 2592000 "24*60*60*30" "mon" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
398 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
399 |
unit := #( |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
400 |
31536000 "24*60*60*365" "yr" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
401 |
604800 "24*60*60*7" "w" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
402 |
86400 "24*60*60" "d" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
403 |
3600 "h" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
404 |
60 "m" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
405 |
1 ) at:uIdx. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
406 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
407 |
seconds := seconds + (unit * val). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
408 |
]. |
16356 | 409 |
]. |
20704 | 410 |
[str atEnd not and:[str peek isSeparator not and:[str peek ~~ $)]]] whileTrue:[ str next]. |
16356 | 411 |
str skipSeparators. |
20704 | 412 |
"/ done when at the end or a $) is to be read |
413 |
str atEnd or:[aStringOrStream isString not and:[str peek == $)]] |
|
16356 | 414 |
] whileFalse. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
415 |
millis := (seconds*1000) + millis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
416 |
restMillis := millis - millis truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
417 |
millis := millis truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
418 |
picos := picos + (restMillis * 1000 * 1000 * 1000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
419 |
millis := millis + (picos // (1000*1000*1000)). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
420 |
picos := picos \\ (1000*1000*1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
421 |
t1 := self fromMilliseconds:millis asInteger. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
422 |
t1 additionalPicoseconds:picos. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
423 |
t1 |
20704 | 424 |
] on:Error do:[:ex | |
16356 | 425 |
|t| |
426 |
||
427 |
"/ retry, using inherited readFrom (Object-storeString) |
|
428 |
t := Object readFrom:aStringOrStream onError:[^ exceptionBlock value]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
429 |
(t isTimeDuration) ifFalse:[ |
16356 | 430 |
^ exceptionBlock value |
431 |
]. |
|
432 |
t |
|
433 |
] |
|
434 |
||
435 |
" |
|
20704 | 436 |
TimeDuration readFrom:'2' defaultUnit:$h onError:nil -> 2h |
437 |
TimeDuration readFrom:'100' defaultUnit:$m onError:nil -> 1h 40m |
|
438 |
TimeDuration readFrom:'100' defaultUnit:$s onError:nil -> 1m 40s |
|
439 |
TimeDuration readFrom:'0200' defaultUnit:$h onError:nil -> 1w 1d 8h |
|
16356 | 440 |
|
441 |
TimeDuration readFrom:'1h' |
|
442 |
TimeDuration readFrom:'1h 35m' |
|
443 |
TimeDuration readFrom:'25h' |
|
444 |
TimeDuration readFrom:'3d' |
|
445 |
TimeDuration readFrom:'1w' |
|
446 |
TimeDuration readFrom:'120s' |
|
20704 | 447 |
TimeDuration readFrom:'1500ms' |
16356 | 448 |
TimeDuration readFrom:'3ms' |
449 |
TimeDuration readFrom:'1yr 5d' |
|
450 |
TimeDuration readFrom:'1mon' |
|
451 |
TimeDuration readFrom:'05:10' |
|
452 |
TimeDuration readFrom:'05:10:5' |
|
453 |
TimeDuration readFrom:'05:10:5.150' |
|
454 |
||
20704 | 455 |
TimeDuration readFrom:'-1h' |
456 |
TimeDuration readFrom:'-1h 10m' |
|
457 |
TimeDuration readFrom:'1h -10m' |
|
458 |
TimeDuration readFrom:'-(1h 10m)' |
|
459 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
460 |
TimeDuration readFrom:'1ms' -> 1ms |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
461 |
TimeDuration readFrom:'5us' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
462 |
TimeDuration readFrom:'5µs' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
463 |
TimeDuration readFrom:'5ns' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
464 |
TimeDuration readFrom:'5ps' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
465 |
TimeDuration readFrom:'5005 ps' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
466 |
TimeDuration readFrom:'1.01 s' -> 1.010s |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
467 |
TimeDuration readFrom:'1.001 s' -> 1.001s |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
468 |
TimeDuration readFrom:'1.0001 s' -> 1.0001s |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
469 |
TimeDuration readFrom:'1s 5ns' -> 1.000000005s |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
470 |
(TimeDuration readFrom:'1s 5ns') = (TimeDuration fromNanoseconds:(5+1000000000)) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
471 |
|
16356 | 472 |
TimeDuration readFrom:(TimeDuration new storeString) |
473 |
" |
|
474 |
||
475 |
"Modified: / 08-10-2007 / 16:41:48 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
476 |
"Modified: / 28-09-2019 / 15:23:14 / Stefan Vogel" |
16356 | 477 |
! |
478 |
||
479 |
readFrom:aStringOrStream onError:exceptionBlock |
|
480 |
"return a new TimeDuration, reading a printed representation from aStream. |
|
481 |
The format is [n 'yr'] [n 'mon'] [n 'w'] [n 'd'] [n 'h'] [n 'm'] [n 's'] [n 'ms'] |
|
482 |
where |
|
483 |
yr -> year |
|
484 |
mon -> month |
|
485 |
w -> week |
|
486 |
d -> day |
|
487 |
h -> hour |
|
488 |
m -> minutes |
|
489 |
s -> seconds |
|
490 |
ms -> milliseconds |
|
491 |
The yr and mon specifiers stand for 365d and 30d respectively. |
|
492 |
If no unit is given (i.e. a plain number string is given), assume seconds. |
|
493 |
" |
|
494 |
||
495 |
^ self readFrom:aStringOrStream defaultUnit:$s onError:exceptionBlock |
|
496 |
||
497 |
" |
|
498 |
TimeDuration readFrom:'100' onError:nil |
|
499 |
TimeDuration readFrom:'100' defaultUnit:$m onError:nil |
|
500 |
||
501 |
TimeDuration readFrom:'1h' |
|
502 |
TimeDuration readFrom:'1h 35m' |
|
503 |
TimeDuration readFrom:'25h' |
|
504 |
TimeDuration readFrom:'3d' |
|
505 |
TimeDuration readFrom:'1w' |
|
506 |
TimeDuration readFrom:'120s' |
|
507 |
TimeDuration readFrom:'1500ms |
|
508 |
TimeDuration readFrom:'3ms' |
|
509 |
TimeDuration readFrom:'1yr 5d' |
|
510 |
TimeDuration readFrom:'1mon' |
|
511 |
" |
|
512 |
||
513 |
"Modified: / 08-10-2007 / 16:41:48 / cg" |
|
514 |
! |
|
515 |
||
516 |
seconds:s |
|
517 |
"return a new TimeDuration representing a duration of s seconds. |
|
518 |
See also Time now / Date today / Timestamp now." |
|
519 |
||
520 |
s == 0 ifTrue:[^ TimeDurationZero]. |
|
521 |
||
16872 | 522 |
^ self basicNew setMilliseconds:(s * 1000) |
16356 | 523 |
|
524 |
" |
|
525 |
TimeDuration seconds:2 |
|
526 |
" |
|
527 |
||
528 |
"Created: / 06-08-2007 / 15:32:21 / cg" |
|
529 |
! |
|
530 |
||
531 |
weeks:w |
|
532 |
"return a new TimeDuration representing a duration of w weeks." |
|
533 |
||
534 |
^ self days:(w * 7) |
|
535 |
||
536 |
" |
|
537 |
TimeDuration weeks:1 |
|
538 |
" |
|
539 |
||
540 |
"Created: / 05-09-2011 / 11:18:27 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
541 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
542 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
543 |
years:y |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
544 |
"return a new TimeDuration representing a duration of y years." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
545 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
546 |
^ self days:(y * 365) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
547 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
548 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
549 |
TimeDuration years:1 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
550 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
551 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
552 |
"Created: / 08-05-2019 / 12:42:16 / Claus Gittinger" |
16356 | 553 |
! ! |
554 |
||
555 |
!TimeDuration class methodsFor:'class initialization'! |
|
556 |
||
557 |
initialize |
|
558 |
TimeDurationZero isNil ifTrue:[ |
|
559 |
TimeDurationZero := self basicNew setHours:0 minutes:0 seconds:0 milliseconds:0. |
|
560 |
] |
|
561 |
||
562 |
"Modified: / 10-05-2011 / 10:31:35 / cg" |
|
563 |
! ! |
|
564 |
||
565 |
!TimeDuration class methodsFor:'constants'! |
|
566 |
||
567 |
zero |
|
568 |
"return the neutral element for addition (0s)" |
|
569 |
||
570 |
^ TimeDurationZero |
|
571 |
||
572 |
"Modified: 18.7.1996 / 12:26:12 / cg" |
|
573 |
! ! |
|
574 |
||
575 |
!TimeDuration class methodsFor:'format strings'! |
|
576 |
||
577 |
defaultFormatForPrinting |
|
578 |
^ DefaultFormatForPrinting |
|
579 |
! |
|
580 |
||
581 |
defaultFormatForPrinting:aString |
|
582 |
DefaultFormatForPrinting := aString |
|
583 |
! |
|
584 |
||
585 |
formatString12us |
|
586 |
"return the format string used to format US times (and other areas)" |
|
587 |
||
588 |
^ '%h:%m:%s.%i' |
|
589 |
! |
|
590 |
||
591 |
formatString24 |
|
592 |
"return the format string used to format european times (and other areas)" |
|
593 |
||
594 |
^ '%h:%m:%s.%i' |
|
595 |
! ! |
|
596 |
||
597 |
!TimeDuration class methodsFor:'timing evaluation'! |
|
598 |
||
599 |
toRun:aBlock |
|
600 |
"return the TimeDuration it takes to execute aBlock. |
|
601 |
A modern variant of Time millisecondsToRun: (which prints itself nicely)" |
|
602 |
||
16872 | 603 |
^ self microseconds:(Time microsecondsToRun:aBlock). |
16356 | 604 |
|
605 |
" |
|
606 |
TimeDuration toRun:[ 20000 factorial ] |
|
16872 | 607 |
TimeDuration toRun:[ 2000 factorial ] |
608 |
TimeDuration toRun:[ 900 factorial ] |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
609 |
TimeDuration toRun:[ 10 factorial ] |
16356 | 610 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
611 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
612 |
"Modified (comment): / 02-03-2020 / 14:15:09 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
613 |
! ! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
614 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
615 |
!TimeDuration methodsFor:'Compatibility-Squeak'! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
616 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
617 |
wait |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
618 |
"wait the receiver's timeDuration" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
619 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
620 |
Delay waitFor:self |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
621 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
622 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
623 |
5 seconds wait |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
624 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
625 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
626 |
"Modified (comment): / 26-06-2019 / 11:35:02 / Claus Gittinger" |
16356 | 627 |
! ! |
628 |
||
629 |
!TimeDuration methodsFor:'accessing'! |
|
630 |
||
631 |
days |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
632 |
"get the (truncated) total number of days. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
633 |
Use this only for printing. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
634 |
Sigh: this is inconsistent: hours, minutes, seconds etc. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
635 |
return the fraction, not the total" |
16356 | 636 |
|
20704 | 637 |
^ self |
638 |
possiblyNegatedValueFromTimeEncodingInto:[:t | |
|
639 |
t // 1000 // 3600 // 24 |
|
640 |
]. |
|
641 |
||
642 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
643 |
(Duration fromString:'1mon 1d 4h 3m 5s 10ms') days |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
644 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
645 |
(Duration days:9 hours:1 minutes:2 seconds:3) days |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
646 |
(Duration days:-9 hours:-1 minutes:-2 seconds:-3) days |
20704 | 647 |
" |
16356 | 648 |
! |
649 |
||
650 |
hours |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
651 |
"get the (truncated) number of hours. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
652 |
notice: that is NOT the total number of hours, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
653 |
but the fractional part only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
654 |
Use this only for printing" |
16356 | 655 |
|
20704 | 656 |
^ self |
657 |
possiblyNegatedValueFromTimeEncodingInto:[:t | |
|
658 |
(t // 1000 // 3600 \\ 24) |
|
659 |
] |
|
660 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
661 |
(Duration fromString:'1d 4h 3m 5s 10ms') hours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
662 |
(Duration fromString:'1d 4h 3m 1s 10ms') getHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
663 |
|
20704 | 664 |
(Duration days: 9 hours: 1 minutes: 2 seconds: 3) hours |
665 |
(Duration days: -9 hours: -1 minutes: -2 seconds: -3) hours |
|
666 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
667 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
668 |
"Modified (comment): / 21-09-2017 / 18:53:32 / cg" |
16356 | 669 |
! |
670 |
||
671 |
milliseconds |
|
672 |
"get the milliseconds part |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
673 |
notice: that is NOT the total number of millis, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
674 |
but the fractional part (within the second) only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
675 |
Use this only for printing. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
676 |
asMilliseconds is probably what you want" |
16356 | 677 |
|
20704 | 678 |
^ self |
679 |
possiblyNegatedValueFromTimeEncodingInto:[:t | |
|
680 |
t \\ 1000 |
|
681 |
]. |
|
682 |
" |
|
683 |
(Duration milliseconds:10) milliseconds |
|
684 |
(Duration milliseconds:-10) milliseconds |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
685 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
686 |
(Duration fromString:'1s 10ms') milliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
687 |
(Duration fromString:'1s 10ms') getMilliseconds |
20704 | 688 |
" |
16356 | 689 |
|
690 |
"Modified: / 05-05-2010 / 14:22:04 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
691 |
"Modified (comment): / 21-09-2017 / 18:53:26 / cg" |
16356 | 692 |
! |
693 |
||
694 |
minutes |
|
695 |
"get the number of minutes. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
696 |
notice: that is NOT the total number of minutes, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
697 |
but the fractional part only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
698 |
Use this only for printing" |
16356 | 699 |
|
20704 | 700 |
^ self |
701 |
possiblyNegatedValueFromTimeEncodingInto:[:t | |
|
702 |
t // 1000 // 60 \\ 60 |
|
703 |
] |
|
704 |
||
705 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
706 |
(Duration fromString:'1h 3m 5s 10ms') minutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
707 |
(Duration fromString:'1h 3m 1s 10ms') getMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
708 |
|
20704 | 709 |
(Duration days: 9 hours: 1 minutes: 2 seconds: 3) minutes |
710 |
(Duration days: -9 hours: -1 minutes: -2 seconds: -3) minutes |
|
711 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
712 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
713 |
"Modified (comment): / 21-09-2017 / 18:53:22 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
714 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
715 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
716 |
picoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
717 |
"get the optional additional picoseconds (0..999999999) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
718 |
notice: that is NOT the total number of picoseconds, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
719 |
but the fractional part (within the second) only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
720 |
Use this only for printing." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
721 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
722 |
^ (self milliseconds * 1000 * 1000 * 1000) + (additionalPicoseconds ? 0) |
16356 | 723 |
! |
724 |
||
725 |
seconds |
|
726 |
"get the number of seconds. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
727 |
notice: that is NOT the total number of seconds, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
728 |
but the fractional part only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
729 |
Use this only for printing. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
730 |
asSeconds is probably what you want" |
16356 | 731 |
|
20704 | 732 |
^ self |
733 |
possiblyNegatedValueFromTimeEncodingInto:[:t | |
|
734 |
t // 1000 \\ 60 |
|
735 |
] |
|
736 |
||
737 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
738 |
(TimeDuration fromString:'1m 5s 10ms') seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
739 |
(TimeDuration fromString:'1m 1s 10ms') getSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
740 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
741 |
(TimeDuration days: 9 hours: 1 minutes: 2 seconds: 3) seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
742 |
(TimeDuration days: -9 hours: -1 minutes: -2 seconds: -3) seconds |
20704 | 743 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
744 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
745 |
"Modified (comment): / 21-09-2017 / 18:53:13 / cg" |
16356 | 746 |
! ! |
747 |
||
748 |
!TimeDuration methodsFor:'arithmetic'! |
|
749 |
||
750 |
* aNumber |
|
751 |
"return a new scaled timeDuration" |
|
752 |
||
19022 | 753 |
aNumber isNumber ifTrue:[ |
754 |
^ self species basicNew |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
755 |
setMilliseconds:(timeEncoding * aNumber) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
756 |
additionalPicoseconds:(additionalPicoseconds ? 0) * aNumber. |
19022 | 757 |
]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
758 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
759 |
"/ notice: although noone seems to implement it (currently), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
760 |
"/ there are additional packages which add support (i.e. goodies/physic), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
761 |
"/ so do not remove the call below. |
19022 | 762 |
^ aNumber productFromTimeDuration:self |
763 |
||
16356 | 764 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
765 |
5 c* (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
766 |
|
16356 | 767 |
(TimeDuration fromString:'10s') * 5 |
20704 | 768 |
(TimeDuration fromString:'10s') * 10 |
769 |
(TimeDuration fromString:'10s') * 100 |
|
770 |
(TimeDuration fromString:'10s') * 1000 |
|
771 |
(TimeDuration fromString:'-10s') * 1000 |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
772 |
(TimeDuration fromString:'10s') * (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
773 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
774 |
(TimeDuration fromString:'10ms') * 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
775 |
(TimeDuration fromString:'10us') * 5 |
16356 | 776 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
777 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
778 |
"Modified: / 27-07-2018 / 10:32:02 / Stefan Vogel" |
16356 | 779 |
! |
780 |
||
781 |
+ aTimeDurationOrNumberOfSeconds |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
782 |
"return a new timeDuration. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
783 |
The argument may be a timeDuration or |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
784 |
a number, which is interpreted as seconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
785 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
786 |
|newMillis newPicos| |
16356 | 787 |
|
788 |
aTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
789 |
newMillis := timeEncoding + (aTimeDurationOrNumberOfSeconds * 1000) asInteger. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
790 |
newPicos := additionalPicoseconds ? 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
791 |
^ self species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
792 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
16356 | 793 |
]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
794 |
^ aTimeDurationOrNumberOfSeconds sumFromTimeDuration:self. |
16356 | 795 |
|
20704 | 796 |
" |
797 |
(TimeDuration fromString:'1m') + (TimeDuration fromString:'10s') |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
798 |
1 minutes - 10 seconds |
20704 | 799 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
800 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
801 |
"Created: / 25-07-2018 / 20:58:17 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
802 |
"Modified: / 27-07-2018 / 10:32:21 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
803 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
804 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
805 |
- aTimeDurationOrNumberOfSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
806 |
"return a new timeDuration. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
807 |
The argument may be a timeDuration or |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
808 |
a number, which is interpreted as seconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
809 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
810 |
|newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
811 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
812 |
aTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
813 |
newMillis := timeEncoding - (aTimeDurationOrNumberOfSeconds * 1000) asInteger. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
814 |
newPicos := additionalPicoseconds ? 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
815 |
^ self species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
816 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
817 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
818 |
^ aTimeDurationOrNumberOfSeconds differenceFromTimeDuration:self. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
819 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
820 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
821 |
(TimeDuration fromString:'1m') - (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
822 |
1 minutes - 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
823 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
824 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
825 |
"Modified: / 27-07-2018 / 10:32:29 / Stefan Vogel" |
16356 | 826 |
! |
827 |
||
828 |
/ aTimeDurationOrNumberOfSeconds |
|
829 |
"if the argument is a number, return a new timeDuration. |
|
830 |
Otherwise, return the quotient as a number." |
|
831 |
||
832 |
aTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
833 |
^ self species basicNew |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
834 |
setMilliseconds:(timeEncoding / aTimeDurationOrNumberOfSeconds) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
835 |
additionalPicoseconds:((additionalPicoseconds?0) / aTimeDurationOrNumberOfSeconds). |
16356 | 836 |
]. |
19023 | 837 |
aTimeDurationOrNumberOfSeconds isTimeDuration ifTrue:[ |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
838 |
^ self getPicoseconds / aTimeDurationOrNumberOfSeconds getPicoseconds. |
19023 | 839 |
]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
840 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
841 |
"/ notice: although noone seems to implement it (currently), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
842 |
"/ there are additional packages which add support (i.e. goodies/physic), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
843 |
"/ so do not remove the call below. |
19023 | 844 |
^ aTimeDurationOrNumberOfSeconds quotientFromTimeDuration:self |
845 |
||
16356 | 846 |
" |
847 |
(TimeDuration fromString:'10s') / (TimeDuration fromString:'5s') |
|
848 |
(TimeDuration fromString:'10s') / 5 |
|
849 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
850 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
851 |
"Modified (format): / 27-07-2018 / 10:38:07 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
852 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
853 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
854 |
// aTimeDurationOrNumberOfSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
855 |
"if the argument is a number, return a new timeDuration. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
856 |
Otherwise, return the quotient as a number." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
857 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
858 |
aTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
859 |
^ self species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
860 |
setSeconds:(self getSeconds // aTimeDurationOrNumberOfSeconds) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
861 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
862 |
aTimeDurationOrNumberOfSeconds isTimeDuration ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
863 |
^ (self getSeconds // aTimeDurationOrNumberOfSeconds getSeconds) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
864 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
865 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
866 |
"/ notice: although noone seems to implement it (currently), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
867 |
"/ there are additional packages which add support (i.e. goodies/physic), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
868 |
"/ so do not remove the call below. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
869 |
^ (aTimeDurationOrNumberOfSeconds quotientFromTimeDuration:self) truncated |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
870 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
871 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
872 |
(TimeDuration fromString:'10s') // (TimeDuration fromString:'3') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
873 |
(TimeDuration fromString:'10s') // 3 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
874 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
875 |
(TimeDuration fromString:'10s') / (TimeDuration fromString:'3') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
876 |
(TimeDuration fromString:'10s') / 3 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
877 |
" |
16356 | 878 |
! |
879 |
||
16403 | 880 |
abs |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
881 |
^ self class new setMilliseconds:(self asExactMilliseconds abs) |
16403 | 882 |
|
883 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
884 |
(TimeDuration fromSeconds:3600) abs |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
885 |
(TimeDuration fromSeconds:-3600) abs |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
886 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
887 |
(TimeDuration fromSeconds:20000) abs |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
888 |
(TimeDuration fromSeconds:-20000) abs |
16403 | 889 |
" |
890 |
! |
|
891 |
||
16356 | 892 |
negated |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
893 |
^ self class new setMilliseconds:(self asExactMilliseconds) negated |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
894 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
895 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
896 |
50 nanoseconds negated asNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
897 |
1 seconds negated asSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
898 |
" |
16356 | 899 |
! |
900 |
||
20704 | 901 |
productFromFloat:aFloat |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
902 |
"sent when aFloat does not know how to multiply the receiver. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
903 |
Return a new timeDuration" |
20704 | 904 |
|
905 |
^ self productFromNumber:aFloat |
|
906 |
||
907 |
" |
|
908 |
5.1 * (TimeDuration fromString:'10s') |
|
909 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
910 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
911 |
"Modified (comment): / 12-06-2017 / 20:51:38 / cg" |
20704 | 912 |
! |
913 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
914 |
productFromFraction:aFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
915 |
"sent when aFraction does not know how to multiply the receiver. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
916 |
Return a new timeDuration" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
917 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
918 |
^ self productFromNumber:aFraction |
16356 | 919 |
|
920 |
" |
|
921 |
(TimeDuration fromString:'10s') * 5 |
|
922 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
923 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
924 |
"Modified (comment): / 12-06-2017 / 20:51:25 / cg" |
16356 | 925 |
! |
926 |
||
20704 | 927 |
productFromInteger:anInteger |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
928 |
"sent when an integer does not know how to multiply the receiver" |
20704 | 929 |
|
930 |
^ self productFromNumber:anInteger |
|
931 |
||
932 |
" |
|
933 |
5 * (TimeDuration fromString:'10s') |
|
934 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
935 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
936 |
"Modified (comment): / 12-06-2017 / 20:50:56 / cg" |
20704 | 937 |
! |
938 |
||
16356 | 939 |
productFromNumber:aNumber |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
940 |
"sent when an integer does not know how to multiply the receiver. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
941 |
Return a new timeDuration" |
16356 | 942 |
|
943 |
^ self species basicNew |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
944 |
setMilliseconds:(timeEncoding * aNumber) additionalPicoseconds:(additionalPicoseconds ? 0) * aNumber. |
16356 | 945 |
|
946 |
" |
|
20704 | 947 |
5.1 * (TimeDuration fromString:'10s') |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
948 |
(TimeDuration fromString:'10s') * 5 |
16356 | 949 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
950 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
951 |
"Modified (comment): / 16-09-2017 / 12:52:16 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
952 |
"Modified: / 27-07-2018 / 10:33:21 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
953 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
954 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
955 |
squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
956 |
"answer a squared time (unit: s^2). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
957 |
Do NOT return a scalar here, because this breaks computations such as |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
958 |
1 meter / 1 seconds squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
959 |
(I hope, no one uses it yet )" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
960 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
961 |
"/ notice: although noone seems to implement it (currently), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
962 |
"/ there are additional packages which add support (i.e. goodies/physic), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
963 |
"/ so do not remove the call below. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
964 |
^ self productFromTimeDuration:self |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
965 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
966 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
967 |
50 nanoseconds squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
968 |
1 seconds squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
969 |
ObjectMemory traceSendsIn:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
970 |
1 meter / 1 seconds squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
971 |
] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
972 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
973 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
974 |
"Created: / 15-03-2019 / 17:57:50 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
975 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
976 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
977 |
squaredSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
978 |
"answer a float representing my value in seconds - squared. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
979 |
Used to compute e.g. variance and standard deviation." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
980 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
981 |
^ self secondsAsFloat squared |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
982 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
983 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
984 |
50 nanoseconds squaredSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
985 |
1 seconds squaredSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
986 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
987 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
988 |
"Created: / 15-03-2019 / 17:57:50 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
989 |
! ! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
990 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
991 |
!TimeDuration methodsFor:'comparing'! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
992 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
993 |
< something |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
994 |
|otherTimeEncoding| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
995 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
996 |
something class == self class ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
997 |
otherTimeEncoding :=something timeEncoding. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
998 |
timeEncoding = otherTimeEncoding ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
999 |
^ (additionalPicoseconds ? 0) < something additionalPicoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1000 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1001 |
^ timeEncoding < otherTimeEncoding |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1002 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1003 |
^ super < something |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1004 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1005 |
"Created: / 26-05-2019 / 10:02:59 / Claus Gittinger" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1006 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1007 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1008 |
= something |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1009 |
something class == self class ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1010 |
^ timeEncoding = something timeEncoding |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1011 |
and:[(additionalPicoseconds ? 0) = something additionalPicoseconds] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1012 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1013 |
^ super = something |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1014 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1015 |
"Created: / 26-05-2019 / 09:40:44 / Claus Gittinger" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1016 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1017 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1018 |
hash |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1019 |
^ timeEncoding bitXor:(additionalPicoseconds ? 0) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1020 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1021 |
"Created: / 26-05-2019 / 09:45:19 / Claus Gittinger" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1022 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1023 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1024 |
negative |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1025 |
^ timeEncoding < 0 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1026 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1027 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1028 |
positive |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1029 |
^ timeEncoding >= 0 |
16356 | 1030 |
! ! |
1031 |
||
1032 |
!TimeDuration methodsFor:'converting'! |
|
1033 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1034 |
asExactHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1035 |
"answer the duration as hours. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1036 |
In contrast to asTruncatedHours, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1037 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1038 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1039 |
^ self asExactSeconds / (3600) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1040 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1041 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1042 |
(2 hours + 10 minutes + 30 seconds) asExactHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1043 |
(2 hours + 10 minutes + 30 seconds) asExactHours asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1044 |
(2 hours + 10 minutes + 30 seconds) asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1045 |
(2 hours + 10 minutes) asExactHours asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1046 |
(2 hours + 10 minutes) asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1047 |
10 milliseconds asExactHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1048 |
10 milliseconds asExactHours asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1049 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1050 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1051 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1052 |
asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1053 |
"return the exact number of mcroseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1054 |
In contrast to asMicroSeconds, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1055 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1056 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1057 |
additionalPicoseconds isNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1058 |
^ (timeEncoding * 1000) "/ millis as micros |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1059 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1060 |
^ (timeEncoding * 1000) "/ millis as micros |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1061 |
+ (additionalPicoseconds / (1000 * 1000)) "/ picos as microseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1062 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1063 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1064 |
40 milliseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1065 |
40 microseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1066 |
40 nanoseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1067 |
40 picoseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1068 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1069 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1070 |
"Created: / 21-09-2017 / 18:52:26 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1071 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1072 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1073 |
asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1074 |
"return the exact number of milliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1075 |
In contrast to asMilliSeconds, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1076 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1077 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1078 |
additionalPicoseconds isNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1079 |
^ timeEncoding "/ millis |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1080 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1081 |
^ timeEncoding "/ millis |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1082 |
+ (additionalPicoseconds / (1000 * 1000 * 1000)) "/ picos as milliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1083 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1084 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1085 |
40 milliseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1086 |
40 microseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1087 |
40 nanoseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1088 |
40 picoseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1089 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1090 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1091 |
"Created: / 21-09-2017 / 18:52:26 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1092 |
"Modified (format): / 24-07-2018 / 16:27:10 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1093 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1094 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1095 |
asExactMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1096 |
"answer the duration as minutes. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1097 |
In contrast to asTruncatedMinutes, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1098 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1099 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1100 |
^ self asExactSeconds / 60 |
16478 | 1101 |
|
1102 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1103 |
(2 hours + 10 minutes + 30 seconds) asExactMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1104 |
(2 hours + 10 minutes + 30 seconds) asExactMinutes asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1105 |
(2 hours + 10 minutes + 30 seconds) asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1106 |
(2 hours + 10 minutes) asExactMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1107 |
(2 hours + 10 minutes) asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1108 |
10 milliseconds asExactMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1109 |
10 milliseconds asExactMinutes asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1110 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1111 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1112 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1113 |
asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1114 |
"return the exact number of nanoseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1115 |
In contrast to asNanoSeconds, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1116 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1117 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1118 |
additionalPicoseconds isNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1119 |
^ (timeEncoding * 1000 * 1000) "/ millis as nanos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1120 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1121 |
^ (timeEncoding * 1000 * 1000) "/ millis as nanos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1122 |
+ (additionalPicoseconds / (1000)) "/ picos as nanoseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1123 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1124 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1125 |
40 milliseconds asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1126 |
40 microseconds asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1127 |
40 nanoseconds asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1128 |
40 picoseconds asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1129 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1130 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1131 |
"Created: / 21-09-2017 / 18:52:26 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1132 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1133 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1134 |
asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1135 |
"return the exact number of seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1136 |
In contrast to asSeconds, which returns them truncated, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1137 |
this may return a non-integer value." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1138 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1139 |
additionalPicoseconds isNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1140 |
^ (timeEncoding / 1000) "/ millis as seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1141 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1142 |
^ (timeEncoding / 1000) "/ millis as seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1143 |
+ (additionalPicoseconds / (1000 * 1000 * 1000 * 1000)) "/ picos as seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1144 |
|
16478 | 1145 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1146 |
1.5 milliSeconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1147 |
1.5 seconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1148 |
40 seconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1149 |
40 milliseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1150 |
40 microseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1151 |
40 nanoseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1152 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1153 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1154 |
"Created: / 21-09-2017 / 18:52:26 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1155 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1156 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1157 |
asFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1158 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1159 |
"answer the duration in seconds as a fixedPoint number. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1160 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1161 |
Please change any sender to use secondsAsFixedPoint" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1162 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1163 |
^ self secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1164 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1165 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1166 |
(10 milliseconds) asFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1167 |
(10 milliseconds) asFixedPoint asFixedPoint:3 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1168 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1169 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1170 |
"Modified (comment): / 14-09-2017 / 15:15:24 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1171 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1172 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1173 |
asFixedPoint:scale |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1174 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1175 |
"answer the duration in seconds as a fixedPoint number with given scale. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1176 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1177 |
Please change any sender to use secondsAsFixedPoint" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1178 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1179 |
^ self secondsAsFixedPoint:scale |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1180 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1181 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1182 |
(1000 milliseconds) secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1183 |
(10 milliseconds) secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1184 |
(10 microseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1185 |
(10 nanoseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1186 |
(1000001 microseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1187 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1188 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1189 |
"Modified (comment): / 14-09-2017 / 15:15:24 / stefan" |
16478 | 1190 |
! |
1191 |
||
1192 |
asFloat |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1193 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1194 |
"answer the duration in seconds as a float. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1195 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1196 |
Please change any sender to use secondsAsFloat" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1197 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1198 |
^ self secondsAsFloat |
16478 | 1199 |
|
1200 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1201 |
(1000 milliseconds) asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1202 |
(10 milliseconds) asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1203 |
(10 microseconds) asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1204 |
(10 nanoseconds) asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1205 |
(1000001 microseconds) asFloat |
16478 | 1206 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1207 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1208 |
"Modified (comment): / 14-09-2017 / 15:15:18 / stefan" |
16478 | 1209 |
! |
1210 |
||
1211 |
asFraction |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1212 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1213 |
"answer the duration in seconds as a fraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1214 |
(might return an integer, if the duration is an exact multiple |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1215 |
of millis). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1216 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1217 |
Please change any sender to use secondsAsFraction" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1218 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1219 |
^ self secondsAsFraction |
16478 | 1220 |
|
1221 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1222 |
(1000 milliseconds) asFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1223 |
(10 milliseconds) asFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1224 |
(10 microseconds) asFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1225 |
(10 nanoseconds) asFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1226 |
(1000001 microseconds) asFraction asFloat |
16478 | 1227 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1228 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1229 |
"Modified (comment): / 19-01-2018 / 17:29:24 / stefan" |
16478 | 1230 |
! |
1231 |
||
1232 |
asInteger |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1233 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1234 |
"answer the duration as (truncated) integer seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1235 |
Better use the explicit asTruncatedSeconds" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1236 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1237 |
^ self asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1238 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1239 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1240 |
10 milliseconds asInteger |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1241 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1242 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1243 |
"Modified (comment): / 14-09-2017 / 15:14:49 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1244 |
"Modified (comment): / 21-09-2017 / 18:57:43 / cg" |
16478 | 1245 |
! |
1246 |
||
1247 |
asLongFloat |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1248 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1249 |
"answer the duration as longfloat seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1250 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1251 |
Please change any sender to use secondsAsFloat" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1252 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1253 |
^ self secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1254 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1255 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1256 |
(10 milliseconds) asLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1257 |
(10 microseconds) asLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1258 |
(10 nanoseconds) asLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1259 |
(1000001 microseconds) asLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1260 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1261 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1262 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1263 |
asMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1264 |
"answer the duration as microseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1265 |
Values smaller than 1 us will be returned as 0" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1266 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1267 |
^ self asTruncatedMicroseconds |
16478 | 1268 |
|
1269 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1270 |
100 nanoseconds asTruncatedMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1271 |
100 nanoseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1272 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1273 |
10 milliseconds asMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1274 |
1.5 milliseconds asMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1275 |
10 seconds asMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1276 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1277 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1278 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1279 |
asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1280 |
"answer the duration as milliseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1281 |
Values smaller than 1 ms will be returned as 0" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1282 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1283 |
^ self asTruncatedMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1284 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1285 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1286 |
10 microseconds asTruncatedMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1287 |
10 microseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1288 |
10 microseconds asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1289 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1290 |
10 milliseconds asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1291 |
10 seconds asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1292 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1293 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1294 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1295 |
asNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1296 |
"answer the duration as nanoseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1297 |
Values smaller than 1 ns will be returned as 0" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1298 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1299 |
^ self asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1300 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1301 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1302 |
10 picoseconds asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1303 |
10 picoseconds asExactNanoseconds |
16478 | 1304 |
" |
1305 |
! |
|
1306 |
||
1307 |
asNumber |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1308 |
<resource: #obsolete> |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1309 |
"answer the duration as seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1310 |
This method has a bad name (a historic leftover); |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1311 |
Please change any sender to use asTruncatedSeconds or |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1312 |
asExactSeconds, depending on what is wanted." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1313 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1314 |
^ self asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1315 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1316 |
"Modified (comment): / 14-09-2017 / 15:15:00 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1317 |
"Modified: / 21-09-2017 / 18:57:57 / cg" |
16478 | 1318 |
! |
1319 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1320 |
asPicoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1321 |
"answer the duration as picoseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1322 |
Because the smallest representable timeDuration is 1ps, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1323 |
there is no distinction between truncated and exact picos." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1324 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1325 |
^ (timeEncoding * 1000000000) + ((additionalPicoseconds ? 0)) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1326 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1327 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1328 |
10 milliseconds asPicoeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1329 |
10 seconds asPicoeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1330 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1331 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1332 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1333 |
asSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1334 |
"answer the duration as seconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1335 |
Values smaller than 1 s will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1336 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1337 |
To get the exact number, use asExactSeconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1338 |
Please change senders to use asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1339 |
to make this truncation explicit (and obvious when reading code). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1340 |
For compatibility (both backward and with other smalltalks), |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1341 |
asSeconds returns the TRUNCATED integer value |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1342 |
(many senders assume that an integer is returned)" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1343 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1344 |
^ self asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1345 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1346 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1347 |
10 milliseconds asSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1348 |
10 nanoseconds asSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1349 |
10 milliseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1350 |
10 nanoseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1351 |
2 minutes asSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1352 |
" |
16356 | 1353 |
! |
1354 |
||
1355 |
asTimeDuration |
|
20430 | 1356 |
"return a TimeDuration object from the receiver - that's the receiver." |
16356 | 1357 |
|
1358 |
^ self |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1359 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1360 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1361 |
asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1362 |
"answer the duration as hours (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1363 |
Values smaller than 1 h will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1364 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1365 |
To get the exact number, use asExactHours." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1366 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1367 |
^ self asTruncatedSeconds // (3600) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1368 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1369 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1370 |
(2 hours + 10 minutes) asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1371 |
(2 hours + 10 minutes + 30 seconds) asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1372 |
2 minutes asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1373 |
10 milliseconds asTruncatedHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1374 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1375 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1376 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1377 |
asTruncatedMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1378 |
"answer the duration as microseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1379 |
Values smaller than 1 us will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1380 |
This is the total number of microseconds - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1381 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1382 |
^ (timeEncoding * 1000) + ((additionalPicoseconds ? 0) // (1000 * 1000)) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1383 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1384 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1385 |
100 nanoseconds asTruncatedMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1386 |
100 nanoseconds asExactMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1387 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1388 |
10 milliseconds asTruncatedMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1389 |
10 seconds asTruncatedMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1390 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1391 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1392 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1393 |
asTruncatedMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1394 |
"answer the duration as milliseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1395 |
Values smaller than 1 ms will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1396 |
This is the total number of milliseconds - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1397 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1398 |
^ timeEncoding |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1399 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1400 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1401 |
0.1 milliseconds asTruncatedMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1402 |
0.1 milliseconds asExactMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1403 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1404 |
10 milliseconds asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1405 |
10 seconds asMilliseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1406 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1407 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1408 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1409 |
asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1410 |
"answer the duration as minutes (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1411 |
Values smaller than 1 m will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1412 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1413 |
To get the exact number, use asExactMinutes." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1414 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1415 |
^ self asTruncatedSeconds // 60 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1416 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1417 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1418 |
(2 hours + 10 minutes) asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1419 |
(2 hours + 10 minutes + 30 seconds) asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1420 |
2 minutes asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1421 |
10 milliseconds asTruncatedMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1422 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1423 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1424 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1425 |
asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1426 |
"answer the duration as nanoseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1427 |
Values smaller than 1 ns will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1428 |
This is the total number of nanoseconds - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1429 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1430 |
^ (timeEncoding * 1000000) + ((additionalPicoseconds ? 0) // (1000)) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1431 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1432 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1433 |
10 picoseconds asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1434 |
10 picoseconds asExactNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1435 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1436 |
10 milliseconds asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1437 |
10 seconds asTruncatedNanoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1438 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1439 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1440 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1441 |
asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1442 |
"answer the duration as seconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1443 |
Values smaller than 1 s will be returned as 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1444 |
This is the total number of seconds - not just the fractional part. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1445 |
To get the exact number, use asExactSeconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1446 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1447 |
^ timeEncoding // 1000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1448 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1449 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1450 |
10 milliseconds asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1451 |
10 milliseconds asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1452 |
2 minutes asTruncatedSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1453 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1454 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1455 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1456 |
secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1457 |
"answer the duration in seconds as a fixedPoint number." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1458 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1459 |
^ self secondsAsFixedPoint:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1460 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1461 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1462 |
(10 milliseconds) secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1463 |
(10 milliseconds) secondsAsFixedPoint asFixedPoint:3 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1464 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1465 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1466 |
"Modified (comment): / 14-09-2017 / 15:15:24 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1467 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1468 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1469 |
secondsAsFixedPoint:scale |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1470 |
"answer the duration in seconds as a fixedPoint number with given scale." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1471 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1472 |
|t| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1473 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1474 |
t := FixedPoint numerator:timeEncoding denominator:1000 scale:scale. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1475 |
additionalPicoseconds notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1476 |
t := t + (FixedPoint numerator:additionalPicoseconds denominator:((1000*1000)*(1000*1000)) scale:scale) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1477 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1478 |
^ t |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1479 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1480 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1481 |
(1000 milliseconds) secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1482 |
(10 milliseconds) secondsAsFixedPoint |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1483 |
(10 microseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1484 |
(10 nanoseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1485 |
(1000001 microseconds) secondsAsFixedPoint scale:8 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1486 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1487 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1488 |
"Modified (comment): / 14-09-2017 / 15:15:24 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1489 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1490 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1491 |
secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1492 |
"answer the duration in seconds as a float." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1493 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1494 |
|t| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1495 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1496 |
t := timeEncoding / 1000.0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1497 |
additionalPicoseconds notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1498 |
t := t + (additionalPicoseconds / ((1000.0*1000.0) * (1000.0*1000.0))). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1499 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1500 |
^ t |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1501 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1502 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1503 |
(1000 milliseconds) secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1504 |
(10 milliseconds) secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1505 |
(10 microseconds) secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1506 |
(10 nanoseconds) secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1507 |
(1000001 microseconds) secondsAsFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1508 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1509 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1510 |
"Modified (comment): / 14-09-2017 / 15:15:18 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1511 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1512 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1513 |
secondsAsFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1514 |
"answer the duration in seconds as a fraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1515 |
(might return an integer, if the duration is an exact multiple |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1516 |
of millis)." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1517 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1518 |
|t| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1519 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1520 |
t := timeEncoding / 1000. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1521 |
additionalPicoseconds notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1522 |
t := t + (additionalPicoseconds / ((1000*1000)*(1000*1000))). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1523 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1524 |
^ t |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1525 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1526 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1527 |
(1000 milliseconds) secondsAsFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1528 |
(10 milliseconds) secondsAsFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1529 |
(10 microseconds) secondsAsFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1530 |
(10 nanoseconds) secondsAsFraction |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1531 |
(1000001 microseconds) secondsAsFraction asFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1532 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1533 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1534 |
"Modified (comment): / 19-01-2018 / 17:29:24 / stefan" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1535 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1536 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1537 |
secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1538 |
"answer the duration as longfloat seconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1539 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1540 |
|t| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1541 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1542 |
t := timeEncoding / 1000 asLongFloat. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1543 |
additionalPicoseconds notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1544 |
t := t + (additionalPicoseconds / (((1000*1000) asLongFloat) * (1000*1000) asLongFloat)). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1545 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1546 |
^ t |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1547 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1548 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1549 |
(10 milliseconds) secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1550 |
(10 microseconds) secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1551 |
(10 nanoseconds) secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1552 |
(1000001 microseconds) secondsAsLongFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1553 |
" |
16356 | 1554 |
! ! |
1555 |
||
1556 |
!TimeDuration methodsFor:'double dispatching'! |
|
1557 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1558 |
differenceFromFloat:aFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1559 |
"treat the float as a number of seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1560 |
Might be questionable, but adding numbers to timeDurations is also allowed, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1561 |
and addition is commutative... |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1562 |
...maybe mixing should be forbidden." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1563 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1564 |
^ (self species seconds:aFloat) - self |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1565 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1566 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1567 |
10 seconds - 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1568 |
10 - 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1569 |
10.0 - 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1570 |
10 seconds - 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1571 |
10 seconds - 5.0 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1572 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1573 |
10 seconds * 2 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1574 |
10 seconds * 2.5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1575 |
2 * 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1576 |
2.5 * 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1577 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1578 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1579 |
"Created: / 16-09-2017 / 12:49:33 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1580 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1581 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1582 |
differenceFromInteger:anInteger |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1583 |
"treat the integer as a number of seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1584 |
Might be questionable, but adding integers to timeDurations is also allowed, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1585 |
and addition is commutative... |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1586 |
...maybe mixing should be forbidden." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1587 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1588 |
^ (self species seconds:anInteger) - self |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1589 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1590 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1591 |
10 seconds - 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1592 |
10 - 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1593 |
10 seconds - 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1594 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1595 |
10 seconds * 2 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1596 |
2 * 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1597 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1598 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1599 |
"Created: / 16-09-2017 / 12:49:33 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1600 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1601 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1602 |
differenceFromTimeDuration:aTimeDuration |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1603 |
"return a new timeDuration" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1604 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1605 |
|newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1606 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1607 |
newMillis := aTimeDuration getMilliseconds - timeEncoding. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1608 |
newPicos := (aTimeDuration additionalPicoseconds) - (additionalPicoseconds ? 0). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1609 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1610 |
^ aTimeDuration species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1611 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1612 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1613 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1614 |
(TimeDuration fromString:'1m') - (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1615 |
1 minutes - 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1616 |
10 - 1 minutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1617 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1618 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1619 |
"Created: / 25-07-2018 / 21:17:50 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1620 |
"Modified: / 27-07-2018 / 10:32:53 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1621 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1622 |
|
16356 | 1623 |
differenceFromTimestamp:aTimestamp |
1624 |
"return the timestamp this timeDuration before aTimestamp" |
|
1625 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1626 |
|newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1627 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1628 |
newMillis := aTimestamp getMilliseconds - timeEncoding. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1629 |
newPicos := (aTimestamp additionalPicoseconds) - (additionalPicoseconds ? 0). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1630 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1631 |
^ aTimestamp species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1632 |
setMilliseconds:newMillis additionalPicoseconds:newPicos. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1633 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1634 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1635 |
Timestamp now - 100 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1636 |
Time now - 100 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1637 |
Timestamp now - 100 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1638 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1639 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1640 |
"Modified (comment): / 16-09-2017 / 12:51:38 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1641 |
"Modified (format): / 27-07-2018 / 10:50:13 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1642 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1643 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1644 |
productFromTimeDuration:aTimeDuration |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1645 |
"return a new timeDuration" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1646 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1647 |
|t newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1648 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1649 |
(t := Smalltalk at:#'Physic::Time') notNil ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1650 |
^ t dispatchProductFromAmount:(aTimeDuration asExactSeconds) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1651 |
into:t |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1652 |
value:self asExactSeconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1653 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1654 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1655 |
"/ the code below is completely bogus. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1656 |
"/ a square-second is NOT a second!! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1657 |
newMillis := timeEncoding * aTimeDuration getMilliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1658 |
newPicos := (additionalPicoseconds ? 0) * (aTimeDuration additionalPicoseconds). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1659 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1660 |
^ aTimeDuration species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1661 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1662 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1663 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1664 |
1 minutes * 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1665 |
10 * 1 minutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1666 |
1 minutes * 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1667 |
(TimeDuration fromString:'10s') * (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1668 |
(TimeDuration fromString:'10s') / (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1669 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1670 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1671 |
"Created: / 25-07-2018 / 21:11:40 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1672 |
"Modified: / 27-07-2018 / 10:33:29 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1673 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1674 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1675 |
sumFromFloat:aFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1676 |
"treat the float as a number of seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1677 |
Might be questionable, but adding floats to timeDurations is also allowed, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1678 |
and addition is commutative... |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1679 |
...maybe mixing should be forbidden." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1680 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1681 |
^ self addSeconds:aFloat |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1682 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1683 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1684 |
10 + 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1685 |
10.0 + 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1686 |
10 seconds + 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1687 |
10 seconds + 5.0 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1688 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1689 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1690 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1691 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1692 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1693 |
sumFromInteger:anInteger |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1694 |
"treat the integer as a number of seconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1695 |
Might be questionable, but adding integers to timeDurations is also allowed, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1696 |
and addition is commutative... |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1697 |
...maybe mixing should be forbidden." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1698 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1699 |
^ self addSeconds:anInteger |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1700 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1701 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1702 |
10 + 5 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1703 |
10 seconds + 5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1704 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1705 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1706 |
"Created: / 16-09-2017 / 12:46:20 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1707 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1708 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1709 |
sumFromTimeDuration:aTimeDuration |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1710 |
"return a new timeDuration" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1711 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1712 |
|newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1713 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1714 |
newMillis := timeEncoding + aTimeDuration getMilliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1715 |
newPicos := (additionalPicoseconds ? 0) + (aTimeDuration additionalPicoseconds). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1716 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1717 |
^ aTimeDuration species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1718 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1719 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1720 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1721 |
(TimeDuration fromString:'1m') + (TimeDuration fromString:'10s') |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1722 |
1 minutes + 10 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1723 |
10 + 1 minutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1724 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1725 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1726 |
"Created: / 16-09-2017 / 12:43:28 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1727 |
"Modified: / 27-07-2018 / 10:33:47 / Stefan Vogel" |
16356 | 1728 |
! |
1729 |
||
1730 |
sumFromTimestamp:aTimestamp |
|
1731 |
"return the timestamp this timeDuration after aTimestamp" |
|
1732 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1733 |
|newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1734 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1735 |
newMillis := timeEncoding + aTimestamp getMilliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1736 |
newPicos := (additionalPicoseconds ? 0) + (aTimestamp additionalPicoseconds). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1737 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1738 |
^ aTimestamp species basicNew |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1739 |
setMilliseconds:newMillis additionalPicoseconds:newPicos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1740 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1741 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1742 |
Timestamp now + 100 seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1743 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1744 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1745 |
"Modified (comment): / 16-09-2017 / 12:53:14 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1746 |
"Modified: / 27-07-2018 / 10:30:13 / Stefan Vogel" |
16356 | 1747 |
! ! |
1748 |
||
1749 |
!TimeDuration methodsFor:'printing'! |
|
1750 |
||
1751 |
addPrintBindingsTo:aDictionary language:languageOrNil |
|
1752 |
"private print support: add bindings for printing to aDictionary. |
|
1753 |
languageOrNil can only be #en or nil for the current language. |
|
1754 |
||
1755 |
Additional formats available here (for timeDuration) are: |
|
1756 |
%(Hd) hours in day (i.e. 0..23) |
|
1757 |
%(hd) hours in day padded to 2 chars (i.e. 00..23) |
|
1758 |
||
19930 | 1759 |
%(yrR) years rounded (i.e. for 730 days, we get 2 asFixedPoint:1 ) |
1760 |
%(monR) month rounded (i.e. for 45 days, we get 1.5 asFixedPoint:1 ) |
|
1761 |
%(w) weeks |
|
1762 |
%(wR) weeks rounded (i.e. for 45 days, we get 6.xxx asFixedPoint:1 ) |
|
1763 |
%(dR) days rounded (i.e. for 36 hours, we get 1.5 asFixedPoint:1 ) |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1764 |
%(dw) days in week (rest days after taking out the weeks) |
19930 | 1765 |
%(hR) hours rounded (i.e. for 3h 30m, we get 3.5 asFixedPoint:1 ) |
1766 |
%(mR) minutes rounded (i.e. for 2m 30s, we get 2.5 asFixedPoint:1 ) |
|
1767 |
%(sR) seconds rounded to 1 postDecimal (i.e. for 2s 100ms, we get 2.1 asFixedPoint:1 ) |
|
16356 | 1768 |
" |
1769 |
||
19930 | 1770 |
|hoursInDay s yearsRounded monthsRounded weeksRounded daysRounded hoursRounded minutesRounded secondsRounded| |
16356 | 1771 |
|
16830 | 1772 |
self addBasicPrintBindingsTo:aDictionary language:languageOrNil. |
16356 | 1773 |
aDictionary at:$d put:self days. |
1774 |
||
1775 |
hoursInDay := self hours \\ 24. |
|
1776 |
aDictionary at:#Hd put:(s := hoursInDay printString). |
|
1777 |
aDictionary at:#hd put:(s leftPaddedTo:2 with:$0). |
|
1778 |
||
19930 | 1779 |
aDictionary at:#dw put:(self days \\ 7). |
1780 |
||
16356 | 1781 |
yearsRounded := (self hours / 24 / 365). |
1782 |
yearsRounded isInteger ifFalse:[ |
|
1783 |
yearsRounded := yearsRounded asFixedPoint:1. |
|
1784 |
]. |
|
1785 |
aDictionary at:#yrR put:yearsRounded. |
|
1786 |
||
19930 | 1787 |
monthsRounded := self days / 30. |
16356 | 1788 |
monthsRounded isInteger ifFalse:[ |
1789 |
monthsRounded := monthsRounded asFixedPoint:1. |
|
1790 |
monthsRounded roundedToScale = monthsRounded asInteger ifTrue:[ |
|
1791 |
monthsRounded := monthsRounded truncated |
|
1792 |
]. |
|
1793 |
]. |
|
1794 |
aDictionary at:#monR put:monthsRounded. |
|
1795 |
||
19930 | 1796 |
aDictionary at:#w put:(self days // 7). |
1797 |
weeksRounded := self days / 7. |
|
1798 |
weeksRounded isInteger ifFalse:[ |
|
1799 |
weeksRounded := weeksRounded asFixedPoint:1. |
|
1800 |
weeksRounded roundedToScale = weeksRounded asInteger ifTrue:[ |
|
1801 |
weeksRounded := weeksRounded truncated |
|
1802 |
]. |
|
1803 |
]. |
|
1804 |
aDictionary at:#wR put:weeksRounded. |
|
1805 |
||
16356 | 1806 |
daysRounded := (self hours / 24). |
1807 |
daysRounded isInteger ifFalse:[ |
|
1808 |
daysRounded := daysRounded asFixedPoint:1. |
|
1809 |
daysRounded roundedToScale = daysRounded asInteger ifTrue:[ |
|
1810 |
daysRounded := daysRounded truncated |
|
1811 |
]. |
|
1812 |
]. |
|
1813 |
aDictionary at:#dR put:daysRounded. |
|
1814 |
||
1815 |
hoursRounded := self hours + (self minutes / 60). |
|
1816 |
hoursRounded isInteger ifFalse:[ |
|
1817 |
hoursRounded := hoursRounded asFixedPoint:1. |
|
1818 |
hoursRounded roundedToScale = hoursRounded asInteger ifTrue:[ |
|
1819 |
hoursRounded := hoursRounded truncated |
|
1820 |
]. |
|
1821 |
]. |
|
1822 |
aDictionary at:#hR put:hoursRounded. |
|
1823 |
||
1824 |
minutesRounded := self minutes + (self seconds / 60). |
|
1825 |
minutesRounded isInteger ifFalse:[ |
|
1826 |
minutesRounded := minutesRounded asFixedPoint:1. |
|
1827 |
minutesRounded roundedToScale = minutesRounded asInteger ifTrue:[ |
|
1828 |
minutesRounded := minutesRounded truncated |
|
1829 |
]. |
|
1830 |
]. |
|
1831 |
aDictionary at:#mR put:minutesRounded. |
|
1832 |
||
1833 |
secondsRounded := self seconds + (self milliseconds / 1000). |
|
1834 |
secondsRounded isInteger ifFalse:[ |
|
1835 |
secondsRounded := secondsRounded asFixedPoint:1. |
|
1836 |
secondsRounded roundedToScale = secondsRounded asInteger ifTrue:[ |
|
1837 |
secondsRounded := secondsRounded truncated |
|
1838 |
]. |
|
1839 |
]. |
|
1840 |
aDictionary at:#sR put:secondsRounded. |
|
1841 |
||
1842 |
"Modified: / 22-02-2011 / 15:55:38 / cg" |
|
1843 |
! |
|
1844 |
||
1845 |
formatForApproximatePrinting |
|
1846 |
"Return a format which is suitable for a human - not meant to be read back. |
|
1847 |
In contrast to the regular format, this one only gives a rounded approximation |
|
1848 |
of the time duration as useful in information-dialogs or other user-hint-GUI elements. |
|
1849 |
For example, in a timeDuration of more than 2hours, the user might not be interested in |
|
1850 |
individual seconds or even milliseconds. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1851 |
The way this is done is pure magic heuristics - let me know, if you have a better algorithm." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1852 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1853 |
|hours mins secs millis| |
16356 | 1854 |
|
1855 |
hours := self hours. |
|
1856 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1857 |
hours >= (24*365*2) ifTrue:[ |
16356 | 1858 |
^ '%(yrR)yr'. |
1859 |
]. |
|
1860 |
hours >= (24*40) ifTrue:[ |
|
1861 |
^ '%(monR)mon'. |
|
1862 |
]. |
|
1863 |
hours >= 48 ifTrue:[ |
|
1864 |
^ '%(dR)d'. |
|
1865 |
]. |
|
1866 |
hours >= 24 ifTrue:[ |
|
1867 |
^ '%dd %(Hd)h'. |
|
1868 |
]. |
|
1869 |
hours >= 2 ifTrue:[ |
|
1870 |
^ '%(hR)h'. |
|
1871 |
]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1872 |
hours > 0 ifTrue:[ |
16356 | 1873 |
^ '%Hh %Mm'. |
1874 |
]. |
|
1875 |
||
1876 |
"/ no hours |
|
1877 |
mins := self minutes. |
|
1878 |
mins >= 5 ifTrue:[ |
|
1879 |
^ '%(mR)m'. |
|
1880 |
]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1881 |
mins > 0 ifTrue:[ |
16356 | 1882 |
^ '%Mm %Ss'. |
1883 |
]. |
|
1884 |
||
1885 |
"/ no mins |
|
1886 |
secs := self seconds. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1887 |
secs > 0 ifTrue:[ |
16356 | 1888 |
secs >= 30 ifTrue:[ |
1889 |
^ '%(S)s'. |
|
1890 |
]. |
|
1891 |
^ '%(sR)s'. |
|
1892 |
]. |
|
1893 |
||
1894 |
"/ no secs |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1895 |
millis := self milliseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1896 |
millis > 500 ifTrue:[ |
16356 | 1897 |
^ '%(sR)s' |
1898 |
]. |
|
1899 |
||
1900 |
^ self formatForPrinting |
|
1901 |
||
1902 |
" |
|
1903 |
(TimeDuration hours:0 minutes:0 seconds:0 millis:12) printStringForApproximation |
|
1904 |
||
1905 |
(TimeDuration hours:0 minutes:0 seconds:10 millis:123) printStringForApproximation |
|
1906 |
(TimeDuration hours:0 minutes:1 seconds:10 millis:123) printStringForApproximation |
|
1907 |
(TimeDuration hours:0 minutes:2 seconds:10 millis:123) printStringForApproximation |
|
1908 |
(TimeDuration hours:0 minutes:33 seconds:0 millis:123) printStringForApproximation |
|
1909 |
(TimeDuration hours:2 minutes:0 seconds:0 millis:123) printStringForApproximation |
|
1910 |
(TimeDuration hours:2 minutes:33 seconds:0 millis:123) printStringForApproximation |
|
1911 |
(TimeDuration hours:100 minutes:33 seconds:0 millis:123) printStringForApproximation |
|
1912 |
(TimeDuration hours:10000 minutes:33 seconds:0 millis:123) printStringForApproximation |
|
1913 |
(TimeDuration hours:1000000 minutes:33 seconds:0 millis:123) printStringForApproximation |
|
1914 |
||
1915 |
(TimeDuration hours:2 minutes:33 seconds:0 millis:0) printStringForApproximation |
|
1916 |
(TimeDuration hours:2 minutes:0 seconds:0 millis:0) printStringForApproximation |
|
1917 |
(TimeDuration hours:24 minutes:0 seconds:0 millis:0) printStringForApproximation |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1918 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1919 |
(TimeDuration fromMicroseconds:20) printStringForApproximation |
16356 | 1920 |
" |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1921 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1922 |
"Modified: / 21-09-2017 / 22:19:53 / cg" |
16356 | 1923 |
! |
1924 |
||
1925 |
formatForPrinting |
|
1926 |
"Return the format for printing" |
|
1927 |
||
1928 |
DefaultFormatForPrinting notNil ifTrue:[ |
|
1929 |
^ DefaultFormatForPrinting |
|
1930 |
]. |
|
1931 |
^ self formatForPrinting:false |
|
1932 |
||
1933 |
" |
|
1934 |
(TimeDuration readFrom:'10h 3s') formatForPrinting |
|
1935 |
(TimeDuration readFrom:'3s') formatForPrinting |
|
1936 |
(TimeDuration readFrom:'1d 2ms') formatForPrinting |
|
19930 | 1937 |
(TimeDuration readFrom:'1 week') formatForPrinting |
16356 | 1938 |
" |
1939 |
! |
|
1940 |
||
1941 |
formatForShortPrinting |
|
1942 |
"Return the short format for printing (without ms)" |
|
1943 |
||
1944 |
^ self formatForPrinting:true |
|
1945 |
! |
|
1946 |
||
1947 |
printAsApproximationOn:aStream |
|
1948 |
"append a human readable printed representation of the receiver to aStream. |
|
1949 |
The format is meant for a human and does not give all information; |
|
1950 |
especially, useless detail is hidden. |
|
1951 |
This means, that seconds are rounded or hidden, if the dT is more than a few minutes; |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1952 |
minutes rounded into the hour or hidden, if it's more than a few hours etc. |
16356 | 1953 |
The way this is done is pure magic heuristics - let me know, if you have a better algorithm." |
1954 |
||
1955 |
^ self |
|
1956 |
printOn:aStream |
|
1957 |
format:(self formatForApproximatePrinting). |
|
1958 |
||
1959 |
" |
|
1960 |
(TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1961 |
(TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printAsApproximationOn:Transcript |
|
1962 |
(TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1963 |
(TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1964 |
(TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1965 |
(TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1966 |
(TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1967 |
(TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printAsApproximationOn:Transcript |
|
1968 |
||
1969 |
(TimeDuration hours:2 minutes:33 seconds:0) printAsApproximationOn:Transcript |
|
1970 |
(TimeDuration hours:2 minutes:0 seconds:0) printAsApproximationOn:Transcript |
|
1971 |
(TimeDuration hours:24 minutes:0 seconds:0) printAsApproximationOn:Transcript |
|
1972 |
" |
|
1973 |
||
1974 |
"Modified: / 18-07-2007 / 14:06:17 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
1975 |
"Modified (comment): / 13-02-2017 / 20:32:54 / cg" |
16356 | 1976 |
! |
1977 |
||
1978 |
printOn:aStream |
|
1979 |
"append a human readable printed representation of the receiver to aStream. |
|
1980 |
The format is suitable for a human - not meant to be read back." |
|
1981 |
||
1982 |
timeEncoding negative ifTrue:[ |
|
20704 | 1983 |
aStream nextPutAll:'-('. |
16356 | 1984 |
(self class basicNew timeEncoding:timeEncoding negated) printOn:aStream. |
20704 | 1985 |
aStream nextPutAll:')'. |
16356 | 1986 |
^ self |
1987 |
]. |
|
1988 |
^ self |
|
1989 |
printOn:aStream |
|
1990 |
format:(self formatForPrinting). |
|
1991 |
||
1992 |
" |
|
1993 |
TimeDuration hours:0 minutes:0 seconds:0 millis:12 |
|
1994 |
||
1995 |
TimeDuration hours:0 minutes:0 seconds:0 millis:123 |
|
1996 |
TimeDuration hours:0 minutes:0 seconds:10 millis:123 |
|
1997 |
TimeDuration hours:0 minutes:33 seconds:0 millis:123 |
|
1998 |
TimeDuration hours:2 minutes:0 seconds:0 millis:123 |
|
1999 |
TimeDuration hours:2 minutes:33 seconds:0 millis:123 |
|
2000 |
TimeDuration hours:100 minutes:33 seconds:0 millis:123 |
|
2001 |
TimeDuration hours:10000 minutes:33 seconds:0 millis:123 |
|
2002 |
TimeDuration hours:1000000 minutes:33 seconds:0 millis:123 |
|
2003 |
||
2004 |
TimeDuration hours:2 minutes:33 seconds:0 millis:0 |
|
2005 |
TimeDuration hours:2 minutes:0 seconds:0 millis:0 |
|
2006 |
TimeDuration hours:24 minutes:0 seconds:0 millis:0 |
|
2007 |
||
2008 |
(TimeDuration hours:0 minutes:0 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2009 |
(TimeDuration hours:0 minutes:0 seconds:10 millis:123) printStringFormat:'%h:%m:%s' |
|
2010 |
(TimeDuration hours:0 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2011 |
(TimeDuration hours:2 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2012 |
(TimeDuration hours:100 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2013 |
(TimeDuration hours:10000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2014 |
(TimeDuration hours:1000000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2015 |
" |
|
2016 |
||
2017 |
"Modified: / 18-07-2007 / 14:06:17 / cg" |
|
2018 |
! |
|
2019 |
||
2020 |
printShortOn:aStream |
|
2021 |
"append a human readable printed representation |
|
2022 |
of the receiver to aStream (without milliseconds)" |
|
2023 |
||
2024 |
^ self |
|
2025 |
printOn:aStream |
|
2026 |
format:(self formatForShortPrinting). |
|
2027 |
||
2028 |
" |
|
2029 |
TimeDuration hours:0 minutes:0 seconds:0 millis:12 |
|
2030 |
||
2031 |
TimeDuration hours:0 minutes:0 seconds:0 millis:123 |
|
2032 |
TimeDuration hours:0 minutes:0 seconds:10 millis:123 |
|
2033 |
TimeDuration hours:0 minutes:33 seconds:0 millis:123 |
|
2034 |
TimeDuration hours:2 minutes:0 seconds:0 millis:123 |
|
2035 |
TimeDuration hours:2 minutes:33 seconds:0 millis:123 |
|
2036 |
TimeDuration hours:100 minutes:33 seconds:0 millis:123 |
|
2037 |
TimeDuration hours:10000 minutes:33 seconds:0 millis:123 |
|
2038 |
TimeDuration hours:1000000 minutes:33 seconds:0 millis:123 |
|
2039 |
||
2040 |
TimeDuration hours:2 minutes:33 seconds:0 millis:0 |
|
2041 |
TimeDuration hours:2 minutes:0 seconds:0 millis:0 |
|
2042 |
TimeDuration hours:24 minutes:0 seconds:0 millis:0 |
|
2043 |
||
2044 |
(TimeDuration hours:0 minutes:0 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2045 |
(TimeDuration hours:0 minutes:0 seconds:10 millis:123) printStringFormat:'%h:%m:%s' |
|
2046 |
(TimeDuration hours:0 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2047 |
(TimeDuration hours:2 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2048 |
(TimeDuration hours:100 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2049 |
(TimeDuration hours:10000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2050 |
(TimeDuration hours:1000000 minutes:33 seconds:0 millis:123) printStringFormat:'%h:%m:%s' |
|
2051 |
" |
|
2052 |
||
2053 |
"Modified: / 18-07-2007 / 14:06:17 / cg" |
|
2054 |
! |
|
2055 |
||
2056 |
printStringForApproximation |
|
2057 |
"return a human readable printed representation of the receiver to aStream. |
|
2058 |
The format is meant for a human and does not give all information; |
|
2059 |
especially, useless detail is hidden. |
|
2060 |
This means, that seconds are rounded or hidden, if the dT is more than a few minutes; |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2061 |
minutes rounded into the hour or hidden, if it's more than a few hours etc. |
16356 | 2062 |
The way this is done is pure magic heuristics - let me know, if you have a better algorithm." |
2063 |
||
20837 | 2064 |
^ self printStringFormat:(self formatForApproximatePrinting). |
16356 | 2065 |
|
2066 |
" |
|
2067 |
(TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringForApproximation |
|
2068 |
(TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringForApproximation |
|
2069 |
(TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringForApproximation |
|
2070 |
(TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) printStringForApproximation |
|
2071 |
(TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringForApproximation |
|
2072 |
(TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringForApproximation |
|
2073 |
(TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringForApproximation |
|
2074 |
(TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringForApproximation |
|
2075 |
||
2076 |
(TimeDuration hours:2 minutes:33 seconds:0) printStringForApproximation |
|
2077 |
(TimeDuration hours:2 minutes:0 seconds:0) printStringForApproximation |
|
2078 |
(TimeDuration hours:24 minutes:0 seconds:0) printStringForApproximation |
|
2079 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2080 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2081 |
"Modified (comment): / 13-02-2017 / 20:32:59 / cg" |
16356 | 2082 |
! ! |
2083 |
||
2084 |
!TimeDuration methodsFor:'private'! |
|
2085 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2086 |
additionalPicoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2087 |
"get the optional additional picoseconds (0..999999999) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2088 |
notice: that is NOT the total number of picoseconds, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2089 |
but the fractional part only. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2090 |
Use this only for printing." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2091 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2092 |
^ additionalPicoseconds ? 0 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2093 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2094 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2095 |
additionalPicoseconds:picosecondPart |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2096 |
"set the optional additional picoseconds (0..999999999)" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2097 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2098 |
self assert:(picosecondPart isInteger). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2099 |
self assert:(picosecondPart < (1000*1000*1000)). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2100 |
additionalPicoseconds := picosecondPart |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2101 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2102 |
|
16356 | 2103 |
formatForPrinting:shortFlag |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2104 |
"Return a format which is suitable for a human (i.e. not ISO8601) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2105 |
(not meant to be read back because it will not print tiny fractions, |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2106 |
but instead round it heuristically. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2107 |
However, the reader can read that format, but you'll loose some precision if you do). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2108 |
If shortFlag is true, some millisecond-info is omitted for longer times. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2109 |
For timeDurations to be read back exactly, use iso8601 format." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2110 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2111 |
|fmt days weeks hours mins secs |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2112 |
overAllSeconds overAllMicros overAllNanos millis| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2113 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2114 |
days := self days. "/ that's the total |
19930 | 2115 |
weeks := days // 7. |
16356 | 2116 |
hours := self hours. |
2117 |
mins := self minutes. |
|
2118 |
secs := self seconds. |
|
2119 |
millis := self milliseconds. |
|
2120 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2121 |
"/ q: for up to 2 weeks, whould we better generate: "10d" instead of "1w 3d" ?? |
19930 | 2122 |
weeks > 0 ifTrue:[ |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2123 |
"/ notice: dw here, which prints the remaining days, after taking out the weeks |
19930 | 2124 |
fmt := '%(w)w %(dw)d %(Hd)h %Mm'. |
2125 |
secs = 0 ifTrue:[ |
|
2126 |
fmt := '%(w)w %(dw)d %(Hd)h %Mm'. |
|
2127 |
mins = 0 ifTrue:[ |
|
2128 |
fmt := '%(w)w %(dw)d %(Hd)h'. |
|
2129 |
(hours \\ 24) = 0 ifTrue:[ |
|
2130 |
fmt := '%(w)w %(dw)d'. |
|
2131 |
(days \\ 7) = 0 ifTrue:[ |
|
2132 |
fmt := '%(w)w'. |
|
2133 |
]. |
|
2134 |
]. |
|
2135 |
]. |
|
2136 |
]. |
|
2137 |
] ifFalse:[days > 0 ifTrue:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2138 |
"/ notice: d here, which prints the total number of days |
16356 | 2139 |
fmt := '%dd %(Hd)h %Mm'. |
2140 |
secs = 0 ifTrue:[ |
|
2141 |
fmt := '%dd %(Hd)h %Mm'. |
|
2142 |
mins = 0 ifTrue:[ |
|
2143 |
fmt := '%dd %(Hd)h'. |
|
2144 |
(hours \\ 24) = 0 ifTrue:[ |
|
2145 |
fmt := '%dd'. |
|
2146 |
]. |
|
2147 |
]. |
|
2148 |
]. |
|
2149 |
] ifFalse:[ |
|
2150 |
hours > 0 ifTrue:[ |
|
2151 |
fmt := '%Hh %Mm'. |
|
2152 |
secs = 0 ifTrue:[ |
|
2153 |
fmt := '%Hh %Mm'. |
|
2154 |
mins = 0 ifTrue:[ |
|
2155 |
fmt := '%Hh'. |
|
2156 |
]. |
|
2157 |
]. |
|
2158 |
] ifFalse:[ |
|
2159 |
mins > 0 ifTrue:[ |
|
2160 |
fmt := '%Mm'. |
|
2161 |
secs = 0 ifTrue:[ |
|
2162 |
fmt := '%Mm' |
|
2163 |
]. |
|
2164 |
] ifFalse:[ |
|
2165 |
fmt := '' |
|
2166 |
]. |
|
2167 |
]. |
|
19930 | 2168 |
]]. |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2169 |
((secs ~= 0) or:[millis ~= 0 or:[(additionalPicoseconds?0) ~= 0]]) ifTrue:[ |
16356 | 2170 |
fmt size ~~ 0 ifTrue:[ |
2171 |
fmt := fmt , ' ' |
|
2172 |
]. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2173 |
((millis = 0) and:[(additionalPicoseconds?0) = 0]) ifTrue:[ |
16356 | 2174 |
fmt := fmt , '%Ss' |
2175 |
] ifFalse:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2176 |
(secs = 0 and:[(additionalPicoseconds?0) = 0]) ifTrue:[ |
16356 | 2177 |
fmt := fmt , '%Ims' |
2178 |
] ifFalse:[ |
|
2179 |
shortFlag ifFalse:[ |
|
2180 |
"/ show millis |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2181 |
(millis ~= 0) ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2182 |
fmt := fmt , '%S.%is' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2183 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2184 |
overAllMicros := self microseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2185 |
overAllMicros > 2 ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2186 |
fmt := fmt , '%(micro)µs'. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2187 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2188 |
overAllNanos := self nanoseconds. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2189 |
overAllNanos > 2 ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2190 |
fmt := fmt , '%(nano)ns'. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2191 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2192 |
fmt := fmt , '%(pico)ps'. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2193 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2194 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2195 |
]. |
16356 | 2196 |
] ifTrue:[ |
2197 |
"/ only show millis if the number of seconds is small |
|
2198 |
overAllSeconds := self asSeconds. |
|
2199 |
overAllSeconds > 2 ifTrue:[ |
|
2200 |
overAllSeconds > 10 ifTrue:[ |
|
2201 |
overAllSeconds > 300 ifTrue:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2202 |
"/ no decimal above 300 seconds |
16356 | 2203 |
fmt := fmt , '%Ss' |
2204 |
] ifFalse:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2205 |
"/ 1 decimals up to 300 seconds |
16356 | 2206 |
fmt := fmt , '%S.%(milli1)s' |
2207 |
] |
|
2208 |
] ifFalse:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2209 |
"/ 2 decimals up to 10seconds |
16356 | 2210 |
fmt := fmt , '%S.%(milli2)s' |
2211 |
] |
|
2212 |
] ifFalse:[ |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2213 |
"/ millis up to 2seconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2214 |
fmt := fmt , '%S.%is'. |
16356 | 2215 |
] |
2216 |
] |
|
2217 |
] |
|
2218 |
]. |
|
2219 |
] ifFalse:[ |
|
2220 |
fmt isEmpty ifTrue:[ |
|
2221 |
fmt := '%Ss' |
|
2222 |
]. |
|
2223 |
]. |
|
2224 |
||
2225 |
^ fmt. |
|
2226 |
||
2227 |
" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2228 |
3001 seconds formatForPrinting:false |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2229 |
3001 seconds formatForPrinting:true |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2230 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2231 |
(TimeDuration fromString:'1w 3d') formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2232 |
(TimeDuration fromString:'1w 3d') printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2233 |
(TimeDuration fromString:'7d') printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2234 |
(TimeDuration fromString:'6d') printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2235 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2236 |
10 microSeconds formatForPrinting:false |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2237 |
1microSeconds formatForPrinting:false |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2238 |
(TimeDuration fromMilliseconds:0.5) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2239 |
(TimeDuration fromMilliseconds:0.05) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2240 |
(TimeDuration fromMilliseconds:0.005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2241 |
(TimeDuration fromMilliseconds:0.0005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2242 |
(TimeDuration fromMilliseconds:0.00005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2243 |
(TimeDuration fromMilliseconds:0.000005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2244 |
(TimeDuration fromMilliseconds:0.0000005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2245 |
(TimeDuration fromMilliseconds:0.00000005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2246 |
(TimeDuration fromMilliseconds:0.000000005) printString |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2247 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2248 |
(TimeDuration hours:0 minutes:0 seconds:0 milliseconds:12) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2249 |
(TimeDuration hours:0 minutes:0 seconds:2 milliseconds:12) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2250 |
(TimeDuration hours:0 minutes:0 seconds:8 milliseconds:12) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2251 |
(TimeDuration hours:0 minutes:0 seconds:10 milliseconds:12) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2252 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2253 |
(TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2254 |
(TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2255 |
(TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2256 |
(TimeDuration hours:2 minutes:0 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2257 |
(TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2258 |
(TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2259 |
(TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2260 |
(TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2261 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2262 |
(TimeDuration hours:0 minutes:38 seconds:22 milliseconds:123) formatForPrinting:true |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2263 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2264 |
(TimeDuration hours:2 minutes:33 seconds:0 milliseconds:0) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2265 |
(TimeDuration hours:2 minutes:0 seconds:0 milliseconds:0) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2266 |
(TimeDuration hours:24 minutes:0 seconds:0 milliseconds:0) formatForPrinting |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2267 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2268 |
(TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2269 |
(TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2270 |
(TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2271 |
(TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2272 |
(TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2273 |
(TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2274 |
(TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s' |
16356 | 2275 |
" |
2276 |
||
2277 |
"Modified: / 18-07-2007 / 14:06:17 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2278 |
"Modified (comment): / 17-05-2017 / 16:35:56 / mawalch" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2279 |
"Modified: / 23-05-2018 / 10:36:21 / Claus Gittinger" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2280 |
"Modified (comment): / 02-03-2020 / 11:54:02 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2281 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2282 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2283 |
getHours |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2284 |
"return the number of hours (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2285 |
This is the total number of hours - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2286 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2287 |
^ self getSeconds // 60 // 60 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2288 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2289 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2290 |
getMicroseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2291 |
"return the number of microseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2292 |
This is the total number of microseconds - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2293 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2294 |
^ (timeEncoding * 1000) + ((additionalPicoseconds ? 0) // (1000 * 1000)) |
16356 | 2295 |
! |
2296 |
||
2297 |
getMilliseconds |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2298 |
"return the number of milliseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2299 |
This is the total number of milliseconds - not just the fractional part" |
16356 | 2300 |
|
2301 |
^ timeEncoding |
|
2302 |
||
2303 |
"Modified: / 18-07-2007 / 13:44:33 / cg" |
|
2304 |
! |
|
2305 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2306 |
getMinutes |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2307 |
"return the number of minutes (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2308 |
This is the total number of minutes - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2309 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2310 |
^ self getSeconds // 60 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2311 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2312 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2313 |
getPicoseconds |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2314 |
"return the number of picoseconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2315 |
This is the total number of picoseconds - not just the fractional part" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2316 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2317 |
^ (timeEncoding * 1000000000) + ((additionalPicoseconds ? 0)) |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2318 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2319 |
|
16356 | 2320 |
getSeconds |
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2321 |
"return the number of seconds (truncated). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2322 |
This is the total number of seconds - not just the fractional part" |
16356 | 2323 |
|
2324 |
^ timeEncoding // 1000 |
|
2325 |
||
2326 |
"Modified: / 18-07-2007 / 13:44:37 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2327 |
"Modified (comment): / 21-09-2017 / 18:50:03 / cg" |
16356 | 2328 |
! |
2329 |
||
20704 | 2330 |
possiblyNegatedValueFromTimeEncodingInto:aBlock |
2331 |
timeEncoding < 0 ifTrue:[ |
|
2332 |
^ (aBlock value:(timeEncoding negated)) negated |
|
2333 |
]. |
|
2334 |
^ aBlock value:timeEncoding |
|
2335 |
! |
|
2336 |
||
16356 | 2337 |
setHours:h minutes:m seconds:s millis:millis |
2338 |
<resource: #obsolete> |
|
2339 |
"set my time given individual values" |
|
2340 |
||
2341 |
self obsoleteMethodWarning:'use setHours:minutes:seconds:milliseconds:'. |
|
2342 |
self setHours:h minutes:m seconds:s milliseconds:millis. |
|
2343 |
! |
|
2344 |
||
2345 |
setHours:h minutes:m seconds:s milliseconds:millis |
|
2346 |
"set my time given individual values" |
|
2347 |
||
2348 |
self setMilliseconds:((h * 60 * 60 ) + (m * 60) + s) * 1000 + millis. |
|
2349 |
! |
|
2350 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2351 |
setMicroseconds:micros |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2352 |
"set my duration given microseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2353 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2354 |
|restMicros| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2355 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2356 |
timeEncoding := micros // 1000. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2357 |
micros isInteger ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2358 |
additionalPicoseconds := (micros \\ 1000) * 1000000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2359 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2360 |
restMicros := micros - (timeEncoding * 1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2361 |
additionalPicoseconds := (restMicros * 1000000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2362 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2363 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2364 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2365 |
self new setMicroseconds:100 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2366 |
self new setMicroseconds:2 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2367 |
self new setMicroseconds:1.5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2368 |
self new setMicroseconds:0.1 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2369 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2370 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2371 |
"Modified: / 18-07-2007 / 13:44:16 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2372 |
"Modified: / 27-07-2018 / 11:53:05 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2373 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2374 |
|
16356 | 2375 |
setMilliseconds:millis |
2376 |
"set my duration given milliseconds. |
|
2377 |
Duration can be longer than a day" |
|
2378 |
||
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2379 |
millis isInteger ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2380 |
timeEncoding := millis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2381 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2382 |
timeEncoding := millis // 1. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2383 |
additionalPicoseconds := ((millis \\ 1) * 1000000000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2384 |
] |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2385 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2386 |
"Modified: / 18-07-2007 / 13:44:16 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2387 |
"Modified: / 22-05-2018 / 16:51:30 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2388 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2389 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2390 |
setMilliseconds:millis additionalPicoseconds:picos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2391 |
"set my duration given milliseconds and addon picos. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2392 |
Duration can be longer than a day; |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2393 |
values may be negative (eg. if resulting from a subtraction)" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2394 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2395 |
|rest newMillis newPicos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2396 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2397 |
millis isInteger ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2398 |
newMillis := millis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2399 |
newPicos := 0. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2400 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2401 |
newMillis := millis truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2402 |
rest := millis - newMillis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2403 |
newPicos := (rest * 1000000000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2404 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2405 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2406 |
picos ~= 0 ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2407 |
newPicos := (newPicos + picos) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2408 |
newMillis := newMillis + (newPicos // 1000000000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2409 |
newPicos := newPicos \\ 1000000000. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2410 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2411 |
timeEncoding := newMillis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2412 |
additionalPicoseconds := newPicos. |
16356 | 2413 |
|
2414 |
"Modified: / 18-07-2007 / 13:44:16 / cg" |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2415 |
"Modified: / 22-05-2018 / 16:55:53 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2416 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2417 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2418 |
setNanoseconds:nanos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2419 |
"set my duration given nanoseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2420 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2421 |
|millis restNanos| |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2422 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2423 |
millis := nanos // (1000*1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2424 |
timeEncoding := millis. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2425 |
nanos isInteger ifTrue:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2426 |
restNanos := nanos \\ (1000*1000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2427 |
additionalPicoseconds := restNanos * 1000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2428 |
] ifFalse:[ |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2429 |
restNanos := nanos - (millis * 1000000). |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2430 |
additionalPicoseconds := (restNanos * 1000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2431 |
]. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2432 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2433 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2434 |
self new setMicroseconds:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2435 |
self new setNanoseconds:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2436 |
self new setNanoseconds:4000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2437 |
self new setNanoseconds:4000000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2438 |
self new setNanoseconds:40000000 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2439 |
self new setNanoseconds:0.1 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2440 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2441 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2442 |
"Modified: / 18-07-2007 / 13:44:16 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2443 |
"Modified: / 27-07-2018 / 11:53:41 / Stefan Vogel" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2444 |
! |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2445 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2446 |
setPicoseconds:picos |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2447 |
"set my duration given picoseconds." |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2448 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2449 |
timeEncoding := picos // 1000000000. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2450 |
additionalPicoseconds := (picos \\ 1000000000) truncated. |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2451 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2452 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2453 |
self new setMicroseconds:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2454 |
self new setNanoseconds:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2455 |
self new setPicoseconds:4 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2456 |
self new setPicoseconds:4.5 |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2457 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2458 |
self assert: (self new setPicoseconds:4000) = (self new setNanoseconds:4) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2459 |
self assert: (self new setPicoseconds:4000000) = (self new setNanoseconds:4000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2460 |
self assert: (self new setPicoseconds:4000000) = (self new setMicroseconds:4) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2461 |
self assert: (self new setPicoseconds:4000000000) = (self new setNanoseconds:4000000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2462 |
self assert: (self new setPicoseconds:4000000000) = (self new setMicroseconds:4000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2463 |
self assert: (self new setPicoseconds:4000000000) = (self new setMilliseconds:4) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2464 |
self assert: (self new setPicoseconds:4000000000000) = (self new setMilliseconds:4000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2465 |
self assert: (self new setPicoseconds:4000000000000) = (self new setMicroseconds:4000000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2466 |
self assert: (self new setPicoseconds:4000000000000) = (self new setNanoseconds:4000000000) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2467 |
self assert: (self new setPicoseconds:4000000000000) = (self new setSeconds:4) . |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2468 |
" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2469 |
|
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2470 |
"Modified: / 18-07-2007 / 13:44:16 / cg" |
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2471 |
"Modified: / 22-05-2018 / 16:51:45 / Stefan Vogel" |
16356 | 2472 |
! |
2473 |
||
2474 |
setSeconds:secs |
|
2475 |
"set my timeduration given seconds. |
|
2476 |
Notice that (in contrast to Time), there is no modulu operation here. |
|
25423
bcfde4da086a
Cherry-picked `AbstractTime.st`, `Time`, `TimeDuration`, `Timestamp` `TZTimestamp` and `UtcTimestamp`
Jan Vrany <jan.vrany@labware.com>
parents:
20837
diff
changeset
|
2477 |
Duration can be longer than a day, and (much) smaller than a second" |
16356 | 2478 |
|
2479 |
self setMilliseconds:(secs * 1000). |
|
2480 |
||
2481 |
"Modified: / 18-07-2007 / 13:44:24 / cg" |
|
2482 |
! ! |
|
2483 |
||
2484 |
!TimeDuration methodsFor:'testing'! |
|
2485 |
||
2486 |
isTimeDuration |
|
2487 |
^ true |
|
2488 |
! |
|
2489 |
||
2490 |
isZero |
|
2491 |
^ self = self class zero |
|
2492 |
! ! |
|
2493 |
||
2494 |
!TimeDuration class methodsFor:'documentation'! |
|
2495 |
||
2496 |
version |
|
18564 | 2497 |
^ '$Header$' |
16356 | 2498 |
! |
2499 |
||
2500 |
version_CVS |
|
18564 | 2501 |
^ '$Header$' |
16356 | 2502 |
! ! |
2503 |
||
2504 |
||
2505 |
TimeDuration initialize! |