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