author | Claus Gittinger <cg@exept.de> |
Tue, 22 Aug 2006 12:30:37 +0200 | |
changeset 9619 | 6f1fc553757f |
parent 9449 | 6ba774be6aa1 |
child 9620 | 85969e75395d |
permissions | -rw-r--r-- |
30 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 3 |
All Rights Reserved |
30 | 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 |
" |
|
12 |
||
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
14 |
|
8246 | 15 |
AbstractTime subclass:#Timestamp |
795 | 16 |
instanceVariableNames:'osTime' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
8246 | 19 |
category:'Magnitude-Time' |
30 | 20 |
! |
21 |
||
8246 | 22 |
!Timestamp class methodsFor:'documentation'! |
30 | 23 |
|
82 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 27 |
All Rights Reserved |
82 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
30 | 38 |
documentation |
39 |
" |
|
8264
b14c26a88e96
Change AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
8254
diff
changeset
|
40 |
This class represents time values in milliSeconds starting some |
1501 | 41 |
time in the past. |
42 |
(typically, from 1st. Jan 1970, as used in the Unix operating system, |
|
43 |
but other systems may bias the time differently. |
|
44 |
Actually, the implementation does not depend or even know which time/date |
|
45 |
the OperatingSystem bases its time upon - it is simply keeping the value(s) |
|
7671 | 46 |
as returned from the OS. |
1501 | 47 |
For conversion, these values are given back to the OS, which will know |
7671 | 48 |
how to convert these times. This has the advantage, that timestamps on files |
49 |
(such as last-access-time or last-modification-time) can be handled transparently - |
|
50 |
especially when performing comparisons). |
|
241 | 51 |
|
1501 | 52 |
You should not interpret the osTime instance variable directly, instead |
7671 | 53 |
(if at all), ask the OS to convert. |
30 | 54 |
|
7671 | 55 |
The implementation of this class is not the same as in ST-80 |
56 |
(which represents the time as seconds from Jan 1., 1901). |
|
30 | 57 |
|
241 | 58 |
This class should not be confused with Time (which only represents the |
7671 | 59 |
time within one day). Time instances cannot be used to compare times across midnight; |
8246 | 60 |
instances of Timestamp can. |
241 | 61 |
|
8264
b14c26a88e96
Change AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
8254
diff
changeset
|
62 |
Notice: this class was once called AbsoluteTime. Einstein told us in 1905, that talking |
b14c26a88e96
Change AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
8254
diff
changeset
|
63 |
about a absolute time is not a good idea (at least in our universe). So the class |
b14c26a88e96
Change AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
8254
diff
changeset
|
64 |
has been renamed to Timestamp which makes us more compatible to other ST dialects (e.g. VW) |
b14c26a88e96
Change AbsoluteTime to Timestamp
Stefan Vogel <sv@exept.de>
parents:
8254
diff
changeset
|
65 |
AbsoluteTime is still kept as an alias for backward compatibility. |
3479 | 66 |
|
1306 | 67 |
[author:] |
7671 | 68 |
Claus Gittinger |
1306 | 69 |
|
1282 | 70 |
[See also:] |
7671 | 71 |
Time Date |
72 |
Delay ProcessorScheduler |
|
30 | 73 |
" |
74 |
! ! |
|
75 |
||
8246 | 76 |
!Timestamp class methodsFor:'initialization'! |
77 |
||
78 |
initialize |
|
79 |
||
80 |
AbsoluteTime := self. "backward compatibility" |
|
81 |
! ! |
|
82 |
||
83 |
!Timestamp class methodsFor:'instance creation'! |
|
30 | 84 |
|
4378 | 85 |
UTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
1501 | 86 |
"return an instance of the receiver, given individual components. |
8246 | 87 |
See also `Timestamp now' and other protocol inherited |
1501 | 88 |
from my superclass." |
89 |
||
423 | 90 |
^ self basicNew |
8246 | 91 |
fromOSTime:(OperatingSystem |
92 |
computeOSTimeFromUTCYear:y month:m day:d |
|
93 |
hour:h minute:min second:s |
|
94 |
millisecond:millis) |
|
30 | 95 |
|
241 | 96 |
" |
8246 | 97 |
Timestamp UTCYear:1970 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
98 |
Timestamp UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:0 |
|
99 |
Timestamp UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
100 |
Timestamp UTCYear:1999 month:7 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
101 |
Timestamp UTCYear:2000 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
241 | 102 |
" |
1228 | 103 |
|
4378 | 104 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
105 |
"Created: / 13.7.1999 / 12:34:37 / stefan" |
|
106 |
"Modified: / 13.7.1999 / 12:42:30 / stefan" |
|
107 |
! |
|
108 |
||
109 |
day:d month:m year:y hour:h minutes:min seconds:s |
|
110 |
"This is obsolete. User #year:month:day:hour:minute:second:" |
|
111 |
||
112 |
^ self |
|
8246 | 113 |
year:y month:m day:d hour:h |
114 |
minute:min second:s millisecond:0 |
|
4378 | 115 |
|
116 |
" |
|
8246 | 117 |
Timestamp day:2 month:1 year:1991 hour:12 minute:30 second:0 |
118 |
Timestamp day:8 month:1 year:1995 hour:0 minute:43 second:48 |
|
4378 | 119 |
" |
120 |
||
121 |
"Modified: / 1.7.1996 / 15:22:26 / cg" |
|
122 |
"Modified: / 13.7.1999 / 12:29:56 / stefan" |
|
123 |
! |
|
124 |
||
125 |
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis |
|
126 |
"This is obsolete. User #year:month:day:hour:minute:second:millisecond:" |
|
127 |
||
128 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
129 |
||
130 |
" |
|
8246 | 131 |
Timestamp day:1 month:1 year:1970 hour:1 minute:0 second:0 |
132 |
Timestamp day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
133 |
Timestamp day:2 month:1 year:1991 hour:12 minute:30 second:0 millisecond:100 |
|
4378 | 134 |
" |
135 |
||
136 |
"Created: / 1.7.1996 / 14:46:09 / cg" |
|
137 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
138 |
"Modified: / 13.7.1999 / 12:30:26 / stefan" |
|
275 | 139 |
! |
140 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
141 |
decodeFromLiteralArray:anArray |
8246 | 142 |
"decode an Timestamp literalArray. |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
143 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
144 |
anArray may be: |
8246 | 145 |
#(Timestamp '200004182000.123') |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
146 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
147 |
or the deprecated old format, that is not portable between different architectures. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
148 |
We parse this for backward compatibility (will be eventually removed). |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
149 |
|
8246 | 150 |
#(Timestamp #osTime: 12345678) |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
151 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
152 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
153 |
(anArray at:2) == #osTime: ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
154 |
^ self new osTime:(anArray at:3). |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
155 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
156 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
157 |
^ self readGeneralizedFrom:(anArray at:2) onError:[self error:'literal array decoding'] |
8797 | 158 |
|
159 |
" |
|
160 |
Timestamp |
|
161 |
decodeFromLiteralArray:#(Timestamp '20050323175226.014') |
|
162 |
" |
|
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
163 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
164 |
|
423 | 165 |
fromDate:aDate andTime:aTime |
166 |
"return an instance of the receiver, initialized from a time and a date |
|
1228 | 167 |
object. |
8246 | 168 |
See also `Timestamp now' and other protocol inherited |
1228 | 169 |
from my superclass." |
423 | 170 |
|
171 |
^ self |
|
8246 | 172 |
year:aDate year |
173 |
month:aDate month |
|
174 |
day:aDate day |
|
175 |
hour:aTime hours |
|
176 |
minute:aTime minutes |
|
177 |
second:aTime seconds |
|
423 | 178 |
|
179 |
" |
|
8246 | 180 |
Timestamp fromDate:(Date today) andTime:(Time now) |
181 |
Timestamp fromDate:(Date today plusDays:1) andTime:(Time now) |
|
182 |
Timestamp now |
|
423 | 183 |
" |
184 |
||
4378 | 185 |
"Modified: / 8.9.1995 / 15:07:30 / claus" |
186 |
"Modified: / 19.4.1996 / 15:25:46 / cg" |
|
187 |
"Modified: / 13.7.1999 / 12:30:47 / stefan" |
|
423 | 188 |
! |
189 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
190 |
newDay:dayInYear year:year |
8246 | 191 |
"return a new Timestamp, given the year and the day-in-year (starting at 1). |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
192 |
Date protocol compatibility" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
193 |
|
8246 | 194 |
^ (Date newDay:dayInYear year:year) asTimestamp |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
195 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
196 |
" |
8246 | 197 |
Timestamp newDay:183 year:1996 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
198 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
199 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
200 |
"Modified: 2.7.1996 / 09:39:30 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
201 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
202 |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
203 |
readFrom:aStringOrStream onError:exceptionBlock |
8246 | 204 |
"return a new Timestamp, reading a printed representation from aStream. |
275 | 205 |
The string is interpreted as 24 hour format, as printed. |
206 |
Notice, that this is not the storeString format and |
|
4898 | 207 |
is different from the format expected by readFrom:. |
208 |
The format read here is dd-mm-yyyy hh:mm:ss.iii" |
|
275 | 209 |
|
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
210 |
|stream newTime| |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
211 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
212 |
stream := aStringOrStream readStream. |
275 | 213 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7058
diff
changeset
|
214 |
Error handle:[:ex | |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
215 |
newTime := super readFrom:stream onError:exceptionBlock |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
216 |
] do:[ |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
217 |
newTime := self basicReadFrom:stream. |
275 | 218 |
]. |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
219 |
^ newTime |
275 | 220 |
|
221 |
" |
|
8246 | 222 |
Timestamp readFrom:'20-2-1995 13:11:06' |
223 |
Timestamp readFrom:'20-2-1995 13:11' |
|
224 |
Timestamp readFrom:'20-2-2001 13:11' |
|
225 |
Timestamp readFrom:'20-2-1995 13:11:06.100' |
|
226 |
Timestamp readFrom:'32-2-1995 13:11:06.100' onError:'wrong' |
|
227 |
Timestamp readFrom:'32-foo-1995 13:11:06.100' onError:'wrong' |
|
228 |
Timestamp readFrom:'20-2-1995 24:01:00.100' onError:'wrong' |
|
229 |
Timestamp readFrom:'20-2-1995 24:00:01.100' onError:'wrong' |
|
230 |
Timestamp readFrom:'2002-08-02 24:00:01.100' onError:'wrong' |
|
231 |
Timestamp readFrom:'foo' onError:'wrong' |
|
232 |
Timestamp readFrom:(Timestamp now storeString) onError:'wrong' |
|
275 | 233 |
" |
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
234 |
|
4378 | 235 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
236 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
|
2311 | 237 |
! |
238 |
||
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
239 |
readGeneralizedFrom:aStringOrStream onError:exceptionBlock |
8246 | 240 |
"return a new Timestamp, reading a printed representation from aStream. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
241 |
The string is interpreted as 24 hour format, as printed. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
242 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
243 |
Notice, that this is not the storeString format and |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
244 |
is different from the format expected by readFrom:. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
245 |
The format read here is either |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
246 |
yyyymmddHHMMSS.iii+uuuu, which is the ASN1 GeneralizedTime format. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
247 |
or: |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
248 |
yyyy-mm-dd HH:MM:SS.iii +uuuu. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
249 |
" |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
250 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
251 |
|newTime| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
252 |
|
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
253 |
^ [ |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
254 |
|str day month year hour min sec millis c tzDelta| |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
255 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
256 |
sec := millis := 0. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
257 |
str := aStringOrStream readStream. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
258 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
259 |
year := Integer readFrom:(str next:4). |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
260 |
str peek == $- ifTrue:[ str next]. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
261 |
month := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
262 |
(month between:1 and:12) ifFalse:[^ exceptionBlock value]. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
263 |
str peek == $- ifTrue:[ str next]. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
264 |
day := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
265 |
(day between:1 and:31) ifFalse:[^ exceptionBlock value]. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
266 |
|
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
267 |
str skipSeparators. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
268 |
hour:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
269 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
270 |
str peek == $: ifTrue:[ str next]. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
271 |
min:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
272 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
273 |
str atEnd ifFalse:[ |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
274 |
str peek == $: ifTrue:[ str next]. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
275 |
sec := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
276 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
277 |
str atEnd ifFalse:[ |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
278 |
str peek == $. ifTrue:[ |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
279 |
str next. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
280 |
millis := Integer readFrom:str. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
281 |
]. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
282 |
str skipSeparators. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
283 |
]. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
284 |
]. |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
285 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
286 |
str atEnd ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
287 |
"/ this is local time |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
288 |
newTime := self year:year month:month day:day |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
289 |
hour:hour minute:min second:sec millisecond:millis. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
290 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
291 |
c := str next. |
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
292 |
c ~~ $Z ifTrue:[ |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
293 |
|tzh tzmin| |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
294 |
tzh := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
295 |
tzmin := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
296 |
c == $+ ifTrue:[ |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
297 |
"the timezone is ahead of UTC or EAST from Greenwich: subtract hours and minutes" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
298 |
hour := hour - tzh. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
299 |
min := min - tzmin. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
300 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
301 |
c ~~ $- ifTrue:[ |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
302 |
^ exceptionBlock value. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
303 |
]. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
304 |
"the timezone is behind of UTC or WEST from Greenwich: add hours and minutes" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
305 |
hour := hour + tzh. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
306 |
min := min + tzmin. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
307 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
308 |
]. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
309 |
"this is UTC time" |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
310 |
newTime := self UTCYear:year month:month day:day |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
311 |
hour:hour minute:min second:sec millisecond:millis. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
312 |
]. |
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
313 |
newTime |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
314 |
] on:Error do:exceptionBlock. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
315 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
316 |
" |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
317 |
|s| |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
318 |
s := '' writeStream. |
8246 | 319 |
Timestamp now printGeneralizedOn:s. |
320 |
Timestamp readGeneralizedFrom:s contents onError:[] |
|
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
321 |
|
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
322 |
Daylight saving time: |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
323 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
324 |
Timestamp readGeneralizedFrom:'20000718120000Z' onError:[] |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
325 |
Timestamp readGeneralizedFrom:'20000718120000+0200' onError:[] |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
326 |
Timestamp readGeneralizedFrom:'20000718120000+0300' onError:[] |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
327 |
|
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
328 |
No daylight saving time: |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
329 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
330 |
Timestamp readGeneralizedFrom:'20000202120000Z' onError:[] |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
331 |
Timestamp readGeneralizedFrom:'20000202120000+0100' onError:[] |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
332 |
Timestamp readGeneralizedFrom:'20000202120000+0200' onError:[] |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
333 |
|
8246 | 334 |
Timestamp readGeneralizedFrom:'19950220131106' onError:[] |
335 |
Timestamp readGeneralizedFrom:'199502201311' onError:[] |
|
336 |
Timestamp readGeneralizedFrom:'19950220131106.100' onError:[] |
|
337 |
Timestamp readGeneralizedFrom:'19950232131106.100' onError:'wrong' |
|
338 |
Timestamp readGeneralizedFrom:'19950fo2131106.100' onError:'wrong' |
|
339 |
Timestamp readGeneralizedFrom:'foo' onError:'wrong' |
|
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
340 |
|
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
341 |
Timestamp readGeneralizedFrom:'2000-02-02 12:00:00' onError:[] |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
342 |
Timestamp readGeneralizedFrom:'2000-02-02 12:00:00.100' onError:[] |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
343 |
Timestamp readGeneralizedFrom:'2000-02-02 12:00:00.100 +0100' onError:[] |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
344 |
Timestamp readGeneralizedFrom:'2000-02-02 12:00:00 -0100' onError:[] |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
345 |
Timestamp readGeneralizedFrom:'2000-02-02 12:00:00 +0000' onError:[] |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
346 |
" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
347 |
|
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
348 |
"Modified: / 13-07-1999 / 12:31:14 / stefan" |
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
349 |
"Modified: / 22-08-2006 / 12:30:11 / cg" |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
350 |
! |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
351 |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
352 |
readIso8601FormatFrom:aStringOrStream |
8246 | 353 |
"return a new Timestamp, reading an iso8601 UTC representation from aStream. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
354 |
Missing month/day values are replaced with 1; i.e. 1999T24:00 |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
355 |
is the same as 1999-01-01T24:00:00. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
356 |
Missing minute, second and ms values are replaced with 0; |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
357 |
i.e. 1999T12 is the same as 1999-01-01T12:00:00.000. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
358 |
Of course, a 24 hour clock is used. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
359 |
On error, raise an exception. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
360 |
Please use this format for all external representations - its the standard." |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
361 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
362 |
^ self |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
363 |
readIso8601FormatFrom:aStringOrStream yearAlreadyRead:nil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
364 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
365 |
" |
8246 | 366 |
Timestamp readIso8601FormatFrom:'1995-02-20T13:11:06' |
367 |
Timestamp readIso8601FormatFrom:'1995-02T13:11:06' |
|
368 |
Timestamp readIso8601FormatFrom:'1995T13:11:06' |
|
369 |
Timestamp readIso8601FormatFrom:'1995T13:11' |
|
370 |
Timestamp readIso8601FormatFrom:'1995T13' |
|
371 |
Timestamp readIso8601FormatFrom:'1995' |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
372 |
|
8246 | 373 |
Timestamp readIso8601FormatFrom:'1995-02-20 13:11:06' |
374 |
Timestamp readIso8601FormatFrom:'1995-02-20 13:11' |
|
375 |
Timestamp readIso8601FormatFrom:'1995-02-20 13' |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
376 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
377 |
24 is allowed with ISO, and is 00:00 of the next day: |
8246 | 378 |
Timestamp readIso8601FormatFrom:'1995-02-20 24:00:00' |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
379 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
380 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
381 |
! |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
382 |
|
8432 | 383 |
readIso8601FormatFrom:aStringOrStream onError:exceptionValue |
384 |
"return a new Timestamp, reading an iso8601 UTC representation from aStream. |
|
385 |
Missing month/day values are replaced with 1; i.e. 1999T24:00 |
|
386 |
is the same as 1999-01-01T24:00:00. |
|
387 |
Missing minute, second and ms values are replaced with 0; |
|
388 |
i.e. 1999T12 is the same as 1999-01-01T12:00:00.000. |
|
389 |
Of course, a 24 hour clock is used. |
|
390 |
On error, raise an exception. |
|
391 |
Please use this format for all external representations - its the standard." |
|
392 |
||
393 |
^ self |
|
394 |
readIso8601FormatFrom:aStringOrStream |
|
395 |
yearAlreadyRead:nil |
|
396 |
onError:exceptionValue |
|
397 |
! |
|
398 |
||
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
399 |
secondsSince1970:sec |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
400 |
"set time from elapsed seconds since 1-1-1970, 0:0:0. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
401 |
This is the format used in the UNIX world" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
402 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
403 |
|divMod| |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
404 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
405 |
divMod := sec divMod:3600. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
406 |
^ self year:1970 month:1 day:1 hour:(divMod at:1) minute:0 second:(divMod at:2) millisecond:0. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
407 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
408 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
409 |
Timestamp secondsSince1970:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
410 |
Timestamp secondsSince1970:3600 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
411 |
Timestamp secondsSince1970:3600*24 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
412 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
413 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
414 |
"Created: / 21.10.1996 / 17:48:30 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
415 |
"Modified: / 13.7.1999 / 12:31:22 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
416 |
! |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
417 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
418 |
year:y month:m day:d hour:h minute:min second:s |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
419 |
"return an instance of the receiver, given individual components. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
420 |
See also `Timestamp now' and other protocol inherited |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
421 |
from my superclass." |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
422 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
423 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
424 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
425 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
426 |
Timestamp year:1970 month:1 day:1 hour:1 minute:0 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
427 |
Timestamp year:1991 month:1 day:2 hour:12 minute:30 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
428 |
Timestamp year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
429 |
Timestamp year:2000 month:1 day:1 hour:1 minutes:0 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
430 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
431 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
432 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
433 |
"Created: / 13.7.1999 / 12:06:39 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
434 |
"Modified: / 13.7.1999 / 12:27:47 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
435 |
! |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
436 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
437 |
year:y month:m day:d hour:h minute:min second:s millisecond:millis |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
438 |
"return an instance of the receiver, given individual components. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
439 |
See also `Timestamp now' and other protocol inherited |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
440 |
from my superclass." |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
441 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
442 |
^ self basicNew |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
443 |
fromOSTime:(OperatingSystem |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
444 |
computeOSTimeFromYear:y month:m day:d |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
445 |
hour:h minute:min seconds:s millis:millis) |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
446 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
447 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
448 |
Timestamp year:1970 month:1 day:1 hour:0 minute:0 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
449 |
Timestamp year:1991 month:1 day:2 hour:12 minute:30 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
450 |
Timestamp year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
451 |
Timestamp year:2000 month:1 day:1 hour:1 minute:0 second:0 |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
452 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
453 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
454 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
455 |
"Created: / 13.7.1999 / 12:28:44 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
456 |
"Modified: / 13.7.1999 / 12:37:57 / stefan" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
457 |
! ! |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
458 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
459 |
!Timestamp class methodsFor:'private'! |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
460 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
461 |
basicReadFrom:aStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
462 |
"return a new Timestamp, reading a printed representation from aStream. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
463 |
The string is interpreted as 24 hour format, as printed. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
464 |
Notice, that this is not the storeString format and |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
465 |
is different from the format expected by readFrom:. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
466 |
KLUDGE: |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
467 |
us and non-us format have different ordering of day and month; |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
468 |
The format read here is (non-us) dd-mm-yyyy hh:mm:ss.iii |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
469 |
or (us-format, for Travis) mm/dd/yyyy hh:mm:ss.iii. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
470 |
On error, raise an exception" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
471 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
472 |
|firstNumber secondNumber day month year hour min sec millis usFormat| |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
473 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
474 |
firstNumber := Integer readFrom:aStream onError:[ConversionError raiseErrorString:' - integer expected']. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
475 |
firstNumber > 31 ifTrue:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
476 |
"/ assume iso8601 format; |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
477 |
^ self readIso8601FormatFrom:aStream yearAlreadyRead:firstNumber. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
478 |
]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
479 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
480 |
"/ consider this a kludge |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
481 |
usFormat := (aStream peek == $/ ). |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
482 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
483 |
[aStream peek isDigit] whileFalse:[aStream next]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
484 |
secondNumber := Integer readFrom:aStream onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
485 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
486 |
usFormat ifTrue:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
487 |
month := firstNumber. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
488 |
day := secondNumber. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
489 |
] ifFalse:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
490 |
month := secondNumber. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
491 |
day := firstNumber. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
492 |
]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
493 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
494 |
(day between:1 and:31) ifFalse:[ ConversionError raiseErrorString:' - bad day' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
495 |
(month between:1 and:12) ifFalse:[ ConversionError raiseErrorString:' - bad month' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
496 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
497 |
[aStream peek isDigit] whileFalse:[aStream next]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
498 |
year := Integer readFrom:aStream onError:[ ConversionError raiseErrorString:' - bad year' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
499 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
500 |
[aStream peek isDigit] whileFalse:[aStream next]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
501 |
hour := Integer readFrom:aStream onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
502 |
(hour between:0 and:24) ifFalse:[ ConversionError raiseErrorString:' - bad hour' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
503 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
504 |
[aStream peek isDigit] whileFalse:[aStream next]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
505 |
min := Integer readFrom:aStream onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
506 |
(min between:0 and:59) ifFalse:[ ConversionError raiseErrorString:' - bad minute' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
507 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
508 |
aStream atEnd ifTrue:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
509 |
sec := millis := 0. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
510 |
] ifFalse:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
511 |
[aStream peek isDigit] whileFalse:[aStream next]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
512 |
sec := Integer readFrom:aStream onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
513 |
(sec between:0 and:59) ifFalse:[ ConversionError raiseErrorString:' - bad second' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
514 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
515 |
aStream peek = $. ifTrue:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
516 |
aStream next. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
517 |
millis := Integer readFrom:aStream onError:0. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
518 |
millis >= 1000 ifTrue:[ ConversionError raiseErrorString:' - bad millisecond' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
519 |
] ifFalse:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
520 |
millis := 0. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
521 |
]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
522 |
]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
523 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
524 |
"special check - only 24:00:00 is allowed; |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
525 |
every time after that must wrap" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
526 |
hour == 24 ifTrue:[ |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
527 |
(min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ ConversionError raiseErrorString:' - bad hour' ]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
528 |
]. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
529 |
^ self year:year month:month day:day hour:hour minute:min second:sec millisecond:millis. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
530 |
|
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
531 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
532 |
Timestamp basicReadFrom:'20-2-1995 13:11:06' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
533 |
Timestamp basicReadFrom:'20-2-1995 13:11:06.' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
534 |
(Timestamp basicReadFrom:'10-9-1995 13:11:06' readStream) month |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
535 |
(Timestamp basicReadFrom:'10/9/1995 13:11:06' readStream) month |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
536 |
Timestamp basicReadFrom:'20-2-1995 13:11' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
537 |
Timestamp basicReadFrom:'20-2-1995 13:11:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
538 |
Timestamp basicReadFrom:'32-2-1995 13:11:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
539 |
Timestamp basicReadFrom:'32-foo-1995 13:11:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
540 |
Timestamp basicReadFrom:'20-13-1995 13:11:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
541 |
Timestamp basicReadFrom:'20-12-1995 25:11:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
542 |
Timestamp basicReadFrom:'20-12-1995 23:61:06.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
543 |
Timestamp basicReadFrom:'20-12-1995 23:10:66.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
544 |
Timestamp basicReadFrom:'20-12-1995 23:10:00.1000' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
545 |
Timestamp basicReadFrom:'20-2-1995 24:01:00.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
546 |
Timestamp basicReadFrom:'20-2-1995 24:00:01.100' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
547 |
Timestamp basicReadFrom:'foo' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
548 |
Timestamp basicReadFrom:(Timestamp now printString readStream) |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
549 |
Timestamp basicReadFrom:'1995-10-20 24:00:00.000' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
550 |
Timestamp basicReadFrom:'1995-10-20 12:10:00.000' readStream |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
551 |
" |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
552 |
! |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
553 |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
554 |
readIso8601FormatFrom:aStringOrStream yearAlreadyRead:yearOrNil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
555 |
"common helper for read methods. |
8246 | 556 |
Return a new Timestamp, reading an iso8601 UTC representation from aStream. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
557 |
Missing month/day values are replaced with 1; i.e. 1999T24:00 |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
558 |
is the same as 1999-01-01T24:00:00. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
559 |
Missing minute, second and ms values are replaced with 0; |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
560 |
i.e. 1999T12 is the same as 1999-01-01T12:00:00.000. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
561 |
Of course, a 24 hour clock is used. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
562 |
On error, raise an exception. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
563 |
Please use this format for all external representations - its the standard." |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
564 |
|
7008 | 565 |
|str day month year hour min sec millis fraction| |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
566 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
567 |
str := aStringOrStream readStream. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
568 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
569 |
month := day := 1. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
570 |
hour := min := sec := millis := 0. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
571 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
572 |
yearOrNil notNil ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
573 |
year := yearOrNil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
574 |
] ifFalse:[ |
8479 | 575 |
year := Integer readFrom:str onError:nil. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
576 |
year isNil ifTrue:[ ConversionError raiseErrorString:' - bad year' ] |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
577 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
578 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
579 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
580 |
str peek == $- ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
581 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
582 |
"/ month follows. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
583 |
month := Integer readFrom:str. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
584 |
(month between:1 and:12) ifFalse:[ ConversionError raiseErrorString:' - bad month' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
585 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
586 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
587 |
str peek == $- ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
588 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
589 |
"/ day follows. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
590 |
day := Integer readFrom:str. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
591 |
(day between:1 and:31) ifFalse:[ ConversionError raiseErrorString:' - bad day' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
592 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
593 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
594 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
595 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
596 |
str atEnd ifFalse:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
597 |
"time follows" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
598 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
599 |
str peek == $T ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
600 |
"we treat the T as optional here" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
601 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
602 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
603 |
]. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
604 |
hour := Integer readFrom:str onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
605 |
(hour between:0 and:24) ifFalse:[ ConversionError raiseErrorString:' - bad hour' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
606 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
607 |
str peek == $: ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
608 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
609 |
"/ minutes follow. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
610 |
min := Integer readFrom:str onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
611 |
(min between:0 and:59) ifFalse:[ ConversionError raiseErrorString:' - bad minute' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
612 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
613 |
str peek == $: ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
614 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
615 |
"/ seconds follow. |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
616 |
sec := Integer readFrom:str onError:-1. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
617 |
(sec between:0 and:59) ifFalse:[ ConversionError raiseErrorString:' - bad seconds' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
618 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
619 |
str peek == $. ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
620 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
621 |
"/ millis follow. |
8479 | 622 |
fraction := Number readMantissaFrom:str radix:10. |
623 |
millis := (1000 * fraction) rounded. "/ mhmh - should it be truncated ? |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
624 |
] |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
625 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
626 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
627 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
628 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
629 |
"special check - only 24:00:00 is allowed; |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
630 |
every time after that must wrap" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
631 |
hour == 24 ifTrue:[ |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
632 |
(min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ ConversionError raiseErrorString:' - bad hour' ]. |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
633 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
634 |
^ self |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
635 |
year:year month:month day:day |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
636 |
hour:hour minute:min second:sec millisecond:millis. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
637 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
638 |
" |
8479 | 639 |
Timestamp readIso8601FormatFrom:'1995-02-20T13:11:06.123' |
8246 | 640 |
Timestamp readIso8601FormatFrom:'1995-02-20T13:11:06' |
641 |
Timestamp readIso8601FormatFrom:'1995-02T13:11:06' |
|
642 |
Timestamp readIso8601FormatFrom:'1995T13:11:06' |
|
643 |
Timestamp readIso8601FormatFrom:'1995T13:11' |
|
644 |
Timestamp readIso8601FormatFrom:'1995T13' |
|
645 |
Timestamp readIso8601FormatFrom:'1995' |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
646 |
|
8246 | 647 |
Timestamp readIso8601FormatFrom:'1995-02-20 13:11:06' |
648 |
Timestamp readIso8601FormatFrom:'1995-02-20 13:11' |
|
649 |
Timestamp readIso8601FormatFrom:'1995-02-20 13' |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
650 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
651 |
24 is allowed with ISO, and is 00:00 of the next day: |
8246 | 652 |
Timestamp readIso8601FormatFrom:'1995-02-20 24:00:00' |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
653 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
654 |
! |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
655 |
|
8432 | 656 |
readIso8601FormatFrom:aStringOrStream yearAlreadyRead:yearOrNil onError:exceptionValue |
657 |
"common helper for read methods. |
|
658 |
Return a new Timestamp, reading an iso8601 UTC representation from aStream. |
|
659 |
Missing month/day values are replaced with 1; i.e. 1999T24:00 |
|
660 |
is the same as 1999-01-01T24:00:00. |
|
661 |
Missing minute, second and ms values are replaced with 0; |
|
662 |
i.e. 1999T12 is the same as 1999-01-01T12:00:00.000. |
|
663 |
Of course, a 24 hour clock is used. |
|
664 |
On error, raise an exception. |
|
665 |
Please use this format for all external representations - its the standard." |
|
666 |
||
667 |
|retVal| |
|
668 |
||
669 |
ConversionError handle:[:ex | |
|
670 |
retVal := exceptionValue value |
|
671 |
] do:[ |
|
672 |
retVal := self readIso8601FormatFrom:aStringOrStream yearAlreadyRead:yearOrNil |
|
673 |
]. |
|
674 |
^ retVal |
|
241 | 675 |
! ! |
30 | 676 |
|
8246 | 677 |
!Timestamp methodsFor:'accessing'! |
30 | 678 |
|
679 |
day |
|
92 | 680 |
"return the day-in-month of the receiver (1..31). |
275 | 681 |
For compatibility, use instances of Date for this." |
30 | 682 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
683 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) day. |
54 | 684 |
|
92 | 685 |
" |
8246 | 686 |
Timestamp now day |
92 | 687 |
" |
1501 | 688 |
|
689 |
"Modified: 1.7.1996 / 15:23:02 / cg" |
|
690 |
! |
|
691 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
692 |
dayInWeek |
7327 | 693 |
"return the week-day of the receiver - 1 for monday, 7 for sunday |
694 |
WARNING: different from ANSIs dayOfWeek (which returns 1 for sunday, ... 7 for saturday). |
|
695 |
WARNING: does not care for pre-julian dates |
|
696 |
(i.e. do not use this for dates before 1752)" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
697 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
698 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) dayInWeek |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
699 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
700 |
" |
8246 | 701 |
Timestamp now dayInWeek |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
702 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
703 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
704 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
705 |
"Created: 2.7.1996 / 09:35:48 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
706 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
707 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
708 |
dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
709 |
"return the year-day of the receiver - 1 for Jan, 1st." |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
710 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
711 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) dayInYear |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
712 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
713 |
" |
8246 | 714 |
Timestamp now dayInYear |
715 |
Timestamp newDay:184 year:1996 |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
716 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
717 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
718 |
"Modified: 2.7.1996 / 10:21:02 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
719 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
720 |
|
1501 | 721 |
hour |
722 |
"return the hour (0..23). |
|
723 |
ST-80 Timestamp compatibility (I'd prefer the name #hours, for Time compatibility)." |
|
724 |
||
725 |
^ self hours |
|
726 |
||
727 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
728 |
"Modified: 1.7.1996 / 15:15:32 / cg" |
|
30 | 729 |
! |
730 |
||
241 | 731 |
hours |
732 |
"return the hours (0..23)" |
|
733 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
734 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) hours |
54 | 735 |
|
92 | 736 |
" |
8246 | 737 |
Timestamp now hours |
241 | 738 |
" |
739 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
740 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
1501 | 741 |
! |
742 |
||
743 |
millisecond |
|
744 |
"return the millisecond (0..999). |
|
745 |
ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)." |
|
746 |
||
747 |
^ self milliseconds |
|
748 |
||
749 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
750 |
"Modified: 1.7.1996 / 15:15:24 / cg" |
|
751 |
! |
|
752 |
||
753 |
milliseconds |
|
754 |
"return the milliseconds (0..999)" |
|
755 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
756 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) milliseconds |
1501 | 757 |
|
758 |
" |
|
8246 | 759 |
Timestamp now milliseconds |
1501 | 760 |
" |
761 |
||
762 |
"Created: 1.7.1996 / 15:15:02 / cg" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
763 |
"Modified: 2.7.1996 / 09:21:41 / cg" |
1501 | 764 |
! |
765 |
||
766 |
minute |
|
767 |
"return the minute (0..59). |
|
768 |
ST-80 Timestamp compatibility (I'd prefer the name #minutes, for Time compatibility)." |
|
769 |
||
770 |
^ self minutes |
|
771 |
||
772 |
"Created: 1.7.1996 / 15:14:29 / cg" |
|
773 |
"Modified: 1.7.1996 / 15:15:37 / cg" |
|
241 | 774 |
! |
775 |
||
776 |
minutes |
|
777 |
"return the minutes (0..59)" |
|
778 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
779 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) minutes |
241 | 780 |
|
781 |
" |
|
8246 | 782 |
Timestamp now minutes |
92 | 783 |
" |
241 | 784 |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
785 |
"Modified: 2.7.1996 / 09:20:49 / cg" |
241 | 786 |
! |
787 |
||
699 | 788 |
month |
789 |
"return the month of the receiver (1..12). |
|
790 |
For compatibility, use instances of Date for this." |
|
791 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
792 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) month |
699 | 793 |
|
794 |
" |
|
8246 | 795 |
Timestamp now month |
699 | 796 |
" |
1501 | 797 |
|
798 |
"Modified: 1.7.1996 / 15:23:05 / cg" |
|
799 |
! |
|
800 |
||
8286 | 801 |
osTime |
802 |
"get the internal representation of the time. |
|
803 |
Warning: do not depend on the value (unix vs. win32 - differences)" |
|
804 |
||
805 |
^ osTime |
|
806 |
! |
|
807 |
||
4807 | 808 |
osTime:aTime |
5726 | 809 |
"set the internal representation of the time" |
810 |
||
4807 | 811 |
osTime := aTime. |
812 |
! |
|
813 |
||
1501 | 814 |
second |
815 |
"return the second (0..59). |
|
816 |
ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)." |
|
817 |
||
818 |
^ self seconds |
|
819 |
||
820 |
"Created: 1.7.1996 / 15:14:19 / cg" |
|
821 |
"Modified: 1.7.1996 / 15:15:49 / cg" |
|
699 | 822 |
! |
823 |
||
241 | 824 |
seconds |
825 |
"return the seconds (0..59)" |
|
826 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
827 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) seconds |
241 | 828 |
|
829 |
" |
|
8246 | 830 |
Timestamp now seconds |
241 | 831 |
" |
832 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
833 |
"Modified: 2.7.1996 / 09:20:54 / cg" |
92 | 834 |
! |
835 |
||
7734 | 836 |
timeInfo |
837 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) |
|
838 |
! |
|
839 |
||
799 | 840 |
utcOffset |
8886 | 841 |
"return the difference between UTC (Greenwich Mean Time) and the local time in seconds. |
842 |
If daylight saving time applies to ourself, take that into account. |
|
8888
4171ed260947
Fix #utcSecondsSince1970 and #utcSecondsSince1901 (wrong direction of utcOffset)
Stefan Vogel <sv@exept.de>
parents:
8886
diff
changeset
|
843 |
|
8886 | 844 |
Add utcOffset to convert from local time to UTC time. |
8888
4171ed260947
Fix #utcSecondsSince1970 and #utcSecondsSince1901 (wrong direction of utcOffset)
Stefan Vogel <sv@exept.de>
parents:
8886
diff
changeset
|
845 |
Subtract utcOffset to convert from UTC time to local time. |
8886 | 846 |
|
847 |
If utcOffset is negative, the local timezone is east of Greenwich. |
|
848 |
If utcOffset is positive, the local timezone is west of Greenwich." |
|
799 | 849 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
850 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) utcOffset |
799 | 851 |
|
852 |
" |
|
8246 | 853 |
Timestamp now utcOffset |
854 |
(Timestamp day:1 month:7 year:1995 hour:12 minutes:0 seconds:0) utcOffset |
|
799 | 855 |
" |
856 |
||
857 |
"Modified: 20.12.1995 / 17:28:49 / stefan" |
|
1501 | 858 |
"Modified: 1.7.1996 / 15:21:29 / cg" |
799 | 859 |
! |
860 |
||
699 | 861 |
year |
862 |
"return the year of the receiver i.e. 1992. |
|
863 |
For compatibility, use instances of Date for this." |
|
241 | 864 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
865 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) year |
241 | 866 |
|
867 |
" |
|
8246 | 868 |
Timestamp now year |
241 | 869 |
" |
1501 | 870 |
|
871 |
"Modified: 1.7.1996 / 15:23:08 / cg" |
|
241 | 872 |
! ! |
873 |
||
8246 | 874 |
!Timestamp methodsFor:'arithmetic'! |
30 | 875 |
|
8246 | 876 |
millisecondDeltaFrom:aTimestamp |
3510 | 877 |
"return the delta in milliseconds between 2 absolute times. |
9056 | 878 |
The argument is supposed to be BEFORE the receiver" |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
879 |
|
8246 | 880 |
^ self getMilliseconds - (aTimestamp getMilliseconds) |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
881 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
882 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
883 |
|t1 t2| |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
884 |
|
8246 | 885 |
t1 := Timestamp now. |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
886 |
Delay waitForSeconds:0.5. |
8246 | 887 |
t2 := Timestamp now. |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
888 |
t2 millisecondDeltaFrom:t1 |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
889 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
890 |
|
3510 | 891 |
"Modified: / 5.6.1998 / 04:21:33 / cg" |
9056 | 892 |
! |
893 |
||
894 |
secondDeltaFrom:aTimestamp |
|
895 |
"return the delta in seconds between 2 absolute times. |
|
896 |
The argument is supposed to be BEFORE the receiver" |
|
897 |
||
898 |
^ self getSeconds - (aTimestamp getSeconds) |
|
899 |
||
900 |
" |
|
901 |
|t1 t2| |
|
902 |
||
903 |
t1 := Timestamp now. |
|
904 |
Delay waitForSeconds:5. |
|
905 |
t2 := Timestamp now. |
|
906 |
t2 secondDeltaFrom:t1 |
|
907 |
" |
|
908 |
||
909 |
"Modified: / 5.6.1998 / 04:21:33 / cg" |
|
30 | 910 |
! ! |
911 |
||
8246 | 912 |
!Timestamp methodsFor:'comparing'! |
699 | 913 |
|
914 |
= aTime |
|
915 |
"return true if the argument, aTime represents the same time" |
|
916 |
||
917 |
(aTime species == self species) ifFalse:[^ false]. |
|
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
918 |
^ (self getMilliseconds = aTime getMilliseconds) |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
919 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
920 |
"Modified: 3.7.1996 / 13:10:24 / cg" |
699 | 921 |
! |
922 |
||
923 |
hash |
|
924 |
"return an integer useful for hashing on times" |
|
925 |
||
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
926 |
^ osTime // 1000 |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
927 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
928 |
"Modified: 3.7.1996 / 13:10:52 / cg" |
699 | 929 |
! ! |
930 |
||
8246 | 931 |
!Timestamp methodsFor:'converting'! |
699 | 932 |
|
933 |
asAbsoluteTime |
|
8254
73b6109ab982
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8246
diff
changeset
|
934 |
"deprecated, use #asTimestamp" |
8246 | 935 |
|
936 |
<resource:#obsolete> |
|
699 | 937 |
|
9061 | 938 |
self obsoleteMethodWarning:'use #asTimestamp'. |
699 | 939 |
^ self |
940 |
! |
|
941 |
||
942 |
asDate |
|
943 |
"return a Date object from the receiver. |
|
944 |
The returned date will only represent the day - not the timeOfDay." |
|
945 |
||
946 |
^ Date fromOSTime:osTime |
|
947 |
||
948 |
" |
|
8246 | 949 |
Timestamp now |
950 |
Timestamp now asDate |
|
951 |
(Timestamp now addTime:3600) asDate |
|
952 |
(Timestamp now addTime:3600) asTime |
|
953 |
Timestamp fromSeconds:(Timestamp now asSeconds + 3600) |
|
954 |
(Timestamp fromSeconds:(Timestamp now asSeconds + 3600)) asDate |
|
699 | 955 |
" |
956 |
! |
|
957 |
||
7466
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
958 |
asMilliseconds |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
959 |
"return the number of milliSeconds elapsed since whatever time the |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
960 |
OperatingSystem bases its time upon. Since this is totally |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
961 |
OS-dependent, do not interpret the value returned by this method. |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
962 |
You can use it to add/subtract milliSeconds or get time deltas, though." |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
963 |
|
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
964 |
^ self getMilliseconds |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
965 |
! |
87775b24d5ea
category and comment change;
Claus Gittinger <cg@exept.de>
parents:
7327
diff
changeset
|
966 |
|
699 | 967 |
asSeconds |
968 |
"return the number of seconds elapsed since whatever time the |
|
969 |
OperatingSystem bases its time upon. Since this is totally |
|
970 |
OS-dependent, do not interpret the value returned by this method. |
|
971 |
You can use it to add/subtract seconds or get time deltas, though." |
|
972 |
||
973 |
^ self getSeconds |
|
974 |
||
7004 | 975 |
" |
8246 | 976 |
Timestamp now asSeconds |
977 |
Timestamp fromSeconds:(Timestamp now asSeconds + 3600) |
|
699 | 978 |
Time hour:23 minutes:33 seconds:0 |
979 |
Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) |
|
980 |
" |
|
981 |
! |
|
982 |
||
983 |
asTime |
|
984 |
"return a Time object from the receiver. |
|
985 |
The returned time will only represent the timeOfDay - not the day." |
|
986 |
||
987 |
^ Time fromOSTime:osTime |
|
988 |
||
989 |
" |
|
8246 | 990 |
Timestamp now |
991 |
Timestamp now asTime |
|
992 |
(Timestamp now addTime:3600) asTime |
|
699 | 993 |
" |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
994 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
995 |
|
8246 | 996 |
asTimestamp |
997 |
"return an Timestamp object from the receiver - thats the receiver." |
|
998 |
||
999 |
^ self |
|
1000 |
! |
|
1001 |
||
9402 | 1002 |
asUtcTimestamp |
1003 |
"convert a local time timestamp to UTC" |
|
1004 |
||
1005 |
^ self + self utcOffset |
|
1006 |
||
1007 |
" |
|
1008 |
Timestamp now asUtcTimestamp |
|
1009 |
" |
|
1010 |
! |
|
1011 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1012 |
literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1013 |
"encode myself as an array, from which a copy of the receiver |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1014 |
can be reconstructed with #decodeAsLiteralArray. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1015 |
The encoding is: |
8246 | 1016 |
(#Timestamp YYYYMMDDhhmmss.iii) |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1017 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1018 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1019 |
|s| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1020 |
|
8223
56da5d8f8bc1
replaced '' writeStream by String writeStream
Claus Gittinger <cg@exept.de>
parents:
8111
diff
changeset
|
1021 |
s := WriteStream on:(String new:18). |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1022 |
self printGeneralizedOn:s isLocal:true. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1023 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1024 |
^ Array |
9416 | 1025 |
with:self class name |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1026 |
with:s contents |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1027 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1028 |
" |
9416 | 1029 |
Timestamp now literalArrayEncoding |
1030 |
decodeAsLiteralArray |
|
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1031 |
" |
7006 | 1032 |
! |
1033 |
||
1034 |
utcSecondsSince1901 |
|
1035 |
"return the number of seconds elapsed since Jan, 1st 1901" |
|
1036 |
||
9430
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1037 |
" |
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1038 |
secondsBetween1901and1970 := |
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1039 |
((Date day:1 month:1 year:1970) subtractDate:(Date day:1 month:1 year:1901)) |
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1040 |
* (24 * 60 * 60) |
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1041 |
" |
7006 | 1042 |
|
9449
6ba774be6aa1
stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents:
9433
diff
changeset
|
1043 |
^ self utcSecondsSince1970 + 2177452800. |
7006 | 1044 |
|
1045 |
" |
|
8246 | 1046 |
Timestamp now utcSecondsSince1901 |
7006 | 1047 |
" |
699 | 1048 |
! ! |
1049 |
||
8246 | 1050 |
!Timestamp methodsFor:'printing & storing'! |
30 | 1051 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7817
diff
changeset
|
1052 |
addPrintBindingsTo:dict language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7817
diff
changeset
|
1053 |
"private print support: add bindings for printing to aDictionary |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7817
diff
changeset
|
1054 |
languageOrNil can only be #en or nil for the current language." |
5726 | 1055 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7817
diff
changeset
|
1056 |
self asDate addPrintBindingsTo:dict language:languageOrNil. |
6795
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1057 |
|
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1058 |
self year == Date today year ifTrue:[ |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1059 |
dict at:#yearOrTime put:(self asTime printStringFormat:'%h:%m'). |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1060 |
]. |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1061 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7817
diff
changeset
|
1062 |
super addPrintBindingsTo:dict language:languageOrNil. |
4843 | 1063 |
! |
1064 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1065 |
printGeneralizedOn:aStream |
5290 | 1066 |
"append a representation of the receiver to aStream in a general format, |
9385 | 1067 |
top-down, without separators: 'yyyymmddHHMMSS.mmm+0100' |
5290 | 1068 |
This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33, |
1069 |
so read this before changing the output format." |
|
1070 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1071 |
^ self printGeneralizedOn:aStream isLocal:false. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1072 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1073 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1074 |
printGeneralizedOn:aStream isLocal:isLocal |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1075 |
"append a representation of the receiver to aStream in a general format, |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1076 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1077 |
This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33, |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1078 |
so read this before changing the output format. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1079 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1080 |
If isLocal is true, represent as local time, otherwise add UTC time offset." |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1081 |
|
5290 | 1082 |
|t off| |
1083 |
||
1084 |
t := OperatingSystem computeTimeAndDateFrom:osTime. |
|
1085 |
||
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1086 |
t year printOn:aStream leftPaddedTo:4 with:$0. |
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1087 |
t month printOn:aStream leftPaddedTo:2 with:$0. |
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1088 |
t day printOn:aStream leftPaddedTo:2 with:$0. |
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1089 |
t hours printOn:aStream leftPaddedTo:2 with:$0. |
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1090 |
t minutes printOn:aStream leftPaddedTo:2 with:$0. |
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1091 |
t seconds printOn:aStream leftPaddedTo:2 with:$0. |
5290 | 1092 |
aStream nextPut:$.. |
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1093 |
t milliseconds printOn:aStream leftPaddedTo:3 with:$0. |
5290 | 1094 |
|
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1095 |
isLocal ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1096 |
"/ this should be printed as non-local-time |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1097 |
|
7512
07c56e8934f4
OS returns OSTimeInfo (instead of an Array)
Claus Gittinger <cg@exept.de>
parents:
7474
diff
changeset
|
1098 |
off := t utcOffset. |
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1099 |
off == 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1100 |
aStream nextPut:$Z. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1101 |
] ifFalse:[ |min| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1102 |
off < 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1103 |
aStream nextPut:$+. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1104 |
off := off negated. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1105 |
] ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1106 |
aStream nextPut:$-. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1107 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1108 |
min := off // 60. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1109 |
min // 60 printOn:aStream leftPaddedTo:2 with:$0. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1110 |
min \\ 60 printOn:aStream leftPaddedTo:2 with:$0. |
5290 | 1111 |
]. |
1112 |
]. |
|
1113 |
||
1114 |
" |
|
8246 | 1115 |
Timestamp now printGeneralizedOn:Transcript. Transcript cr. |
1116 |
(Timestamp fromSeconds:0) printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 1117 |
Time now printOn:Transcript. Transcript cr. |
1118 |
Date today printOn:Transcript. Transcript cr. |
|
1119 |
||
8246 | 1120 |
Time now asTimestamp printGeneralizedOn:Transcript. Transcript cr. |
1121 |
Timestamp now printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 1122 |
|
8246 | 1123 |
Date today asTimestamp printGeneralizedOn:Transcript. Transcript cr. |
5290 | 1124 |
Date today printOn:Transcript. Transcript cr. |
1125 |
" |
|
1126 |
||
1127 |
"Modified: / 1.7.1996 / 15:20:59 / cg" |
|
1128 |
"Modified: / 17.1.2000 / 15:53:02 / stefan" |
|
1129 |
! |
|
1130 |
||
8479 | 1131 |
printIso8601FormatOn:aStream |
1132 |
"append the iso8601 UTC representation of the receiver to aStream. |
|
1133 |
This format looks like: |
|
1134 |
1999-01-01T24:00:00 |
|
1135 |
or, for zero hr:min:sec, |
|
1136 |
1999-01-01 |
|
1137 |
Of course, a 24 hour clock is used." |
|
1138 |
||
1139 |
|format| |
|
1140 |
||
1141 |
format := '%(year)-%(month)-%(day)T%h:%m:%s.%i'. |
|
1142 |
self milliseconds = 0 ifTrue:[ |
|
1143 |
format := '%(year)-%(month)-%(day)T%h:%m:%s'. |
|
1144 |
self seconds = 0 ifTrue:[ |
|
1145 |
format := '%(year)-%(month)-%(day)T%h:%m'. |
|
1146 |
((self hours = 0) and:[self minutes = 0]) ifTrue:[ |
|
1147 |
format := '%(year)-%(month)-%(day)'. |
|
1148 |
] |
|
1149 |
] |
|
1150 |
]. |
|
1151 |
self printOn:aStream format:format |
|
1152 |
||
1153 |
" |
|
1154 |
Timestamp now printIso8601FormatOn:Transcript |
|
1155 |
Timestamp readIso8601FormatFrom:(Timestamp now printStringIso8601Format). |
|
1156 |
" |
|
1157 |
! |
|
1158 |
||
241 | 1159 |
printOn:aStream |
275 | 1160 |
"append a user readable representation of the receiver to aStream. |
1161 |
The format is compatible with readFromString:, but not with readFrom:." |
|
1162 |
||
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
1163 |
"/ now, use ISO format... |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
1164 |
self printOn:aStream format:'%(year)-%(mon)-%(day) %h:%m:%s.%i' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
1165 |
"/ self printOn:aStream format:'%(Day)-%(mon)-%(year) %h:%m:%s.%i' |
5678 | 1166 |
"/ self printOn:aStream format:'%(mon)/%(Day)/%(year) %h:%m:%s.%i' |
92 | 1167 |
|
1168 |
" |
|
8246 | 1169 |
Timestamp now printOn:Transcript. Transcript cr. |
1170 |
(Timestamp fromSeconds:0) printOn:Transcript. Transcript cr. |
|
275 | 1171 |
Time now printOn:Transcript. Transcript cr. |
1172 |
Date today printOn:Transcript. Transcript cr. |
|
1501 | 1173 |
|
8246 | 1174 |
Time now asTimestamp printOn:Transcript. Transcript cr. |
1175 |
Timestamp now printOn:Transcript. Transcript cr. |
|
1501 | 1176 |
|
8246 | 1177 |
Date today asTimestamp printOn:Transcript. Transcript cr. |
1501 | 1178 |
Date today printOn:Transcript. Transcript cr. |
92 | 1179 |
" |
1501 | 1180 |
|
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
1181 |
"Modified: 1.7.1996 / 15:20:59 / cg" |
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
1182 |
! |
30 | 1183 |
|
7474 | 1184 |
printRFC1123FormatOn:aStream |
1185 |
"append the RFC1123 representation of the receiver to aStream. |
|
1186 |
This format is used in HTTP requests and looks like: |
|
7671 | 1187 |
'Fri, 04 Jul 2003 15:56:11 GMT' |
1188 |
(always GMT and all names in english)" |
|
1189 |
||
1190 |
"/ HTTP-date = rfc1123-date | rfc850-date | asctime-date |
|
1191 |
"/ |
|
1192 |
"/ rfc1123-date = wkday "," SP date1 SP time SP "GMT" |
|
1193 |
"/ rfc850-date = weekday "," SP date2 SP time SP "GMT" |
|
1194 |
"/ asctime-date = wkday SP date3 SP time SP 4DIGIT |
|
1195 |
"/ |
|
1196 |
"/ date1 = 2DIGIT SP month SP 4DIGIT |
|
1197 |
"/ ; day month year (e.g., 02 Jun 1982) |
|
1198 |
"/ date2 = 2DIGIT "-" month "-" 2DIGIT |
|
1199 |
"/ ; day-month-year (e.g., 02-Jun-82) |
|
1200 |
"/ date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) |
|
1201 |
"/ ; month day (e.g., Jun 2) |
|
1202 |
"/ |
|
1203 |
"/ time = 2DIGIT ":" 2DIGIT ":" 2DIGIT |
|
1204 |
"/ ; 00:00:00 - 23:59:59 |
|
1205 |
"/ |
|
1206 |
"/ wkday = "Mon" | "Tue" | "Wed" |
|
1207 |
"/ | "Thu" | "Fri" | "Sat" | "Sun" |
|
1208 |
"/ |
|
1209 |
"/ weekday = "Monday" | "Tuesday" | "Wednesday" |
|
1210 |
"/ | "Thursday" | "Friday" | "Saturday" | "Sunday" |
|
1211 |
"/ |
|
1212 |
"/ month = "Jan" | "Feb" | "Mar" | "Apr" |
|
1213 |
"/ | "May" | "Jun" | "Jul" | "Aug" |
|
1214 |
"/ | "Sep" | "Oct" | "Nov" | "Dec" |
|
7474 | 1215 |
|
7734 | 1216 |
|meUTC timeInfo| |
7474 | 1217 |
|
8246 | 1218 |
meUTC := self class fromSeconds:((self asSeconds) + (self utcOffset)). |
7734 | 1219 |
timeInfo := meUTC timeInfo. |
7474 | 1220 |
|
7734 | 1221 |
aStream nextPutAll:(#('Mon' 'Tue' 'Wed' 'Thu' 'Fri' 'Sat' 'Sun') at:timeInfo dayInWeek); |
7671 | 1222 |
nextPutAll:', '. |
7734 | 1223 |
timeInfo day printOn:aStream leftPaddedTo:2 with:$0. |
7671 | 1224 |
aStream space. |
7734 | 1225 |
aStream nextPutAll:(#('Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec') at:timeInfo month). |
7671 | 1226 |
|
1227 |
"/ The following line is wrong, because the names are printed in the current locale!! |
|
7734 | 1228 |
"/ timeInfo printOn:aStream format:'%(ShortDayName), %(day) %(ShortMonthName) %y %h:%m:%s GMT'. |
7474 | 1229 |
|
7677 | 1230 |
"/ the following is too slow for heavy use |
7734 | 1231 |
"/ timeInfo printOn:aStream format:' %y %h:%m:%s GMT'. |
7677 | 1232 |
|
1233 |
aStream nextPut:Character space. |
|
7734 | 1234 |
timeInfo year printOn:aStream. |
7677 | 1235 |
aStream nextPut:Character space. |
7734 | 1236 |
timeInfo hours printOn:aStream leftPaddedTo:2 with:$0. |
7677 | 1237 |
aStream nextPut:$:. |
7734 | 1238 |
timeInfo minutes printOn:aStream leftPaddedTo:2 with:$0. |
7677 | 1239 |
aStream nextPut:$:. |
7734 | 1240 |
timeInfo seconds printOn:aStream leftPaddedTo:2 with:$0. |
7677 | 1241 |
aStream nextPutAll:' GMT'. |
1242 |
||
7474 | 1243 |
" |
8414 | 1244 |
Timestamp now printRFC1123FormatOn:Transcript |
7474 | 1245 |
" |
1246 |
! |
|
1247 |
||
8479 | 1248 |
printStringIso8601Format |
1249 |
"return the Iso8601 representation of the receiver. |
|
1250 |
This format looks like: |
|
1251 |
1999-01-01T24:00:00 |
|
1252 |
or, for zero hr:min:sec, |
|
1253 |
1999-01-01 |
|
1254 |
Of course, a 24 hour clock is used." |
|
1255 |
||
1256 |
^ String streamContents:[:s | self printIso8601FormatOn:s] |
|
1257 |
||
1258 |
" |
|
1259 |
Timestamp now printStringIso8601Format |
|
1260 |
" |
|
1261 |
! |
|
1262 |
||
7474 | 1263 |
printStringRFC1123Format |
1264 |
"return the RFC1123 representation of the receiver. |
|
1265 |
This format is used in HTTP requests and looks like: |
|
7671 | 1266 |
'Fri, 04 Jul 2003 15:56:11 GMT' |
7474 | 1267 |
(always GMT)" |
1268 |
||
1269 |
^ String streamContents:[:s | self printRFC1123FormatOn:s] |
|
1270 |
||
1271 |
" |
|
8246 | 1272 |
Timestamp now printStringRFC1123Format |
7474 | 1273 |
" |
1274 |
! |
|
1275 |
||
241 | 1276 |
storeOn:aStream |
275 | 1277 |
"store the receiver in a format suitable for reconstruction of the |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1278 |
receiver via readFrom: |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1279 |
Use a OS/architecture independent format" |
275 | 1280 |
|
241 | 1281 |
aStream nextPut:$(; |
8246 | 1282 |
nextPutAll:self class name; |
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1283 |
nextPutAll:' readIso8601FormatFrom:'''. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1284 |
self printIso8601FormatOn:aStream. |
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1285 |
aStream nextPutAll:''')'. |
54 | 1286 |
|
241 | 1287 |
" |
8246 | 1288 |
Timestamp now storeString |
30 | 1289 |
|
8822
10d99a9248f2
#storeOn: stores in ISO 8601 format.
Stefan Vogel <sv@exept.de>
parents:
8797
diff
changeset
|
1290 |
Object readFrom:(Timestamp now storeString) readStream |
8246 | 1291 |
Timestamp readFrom:(Timestamp now storeString) readStream |
241 | 1292 |
" |
30 | 1293 |
! ! |
699 | 1294 |
|
8246 | 1295 |
!Timestamp methodsFor:'private'! |
699 | 1296 |
|
1501 | 1297 |
fromOSTime:anUninterpretedOSTime |
699 | 1298 |
"strictly private: set the seconds from an OS time (since whatever)" |
1299 |
||
1501 | 1300 |
osTime := anUninterpretedOSTime |
1301 |
||
1302 |
"Created: 1.7.1996 / 14:33:21 / cg" |
|
1303 |
! |
|
1304 |
||
1305 |
getMilliseconds |
|
1306 |
"strictly private: return the milliseconds (since whatever)" |
|
1307 |
||
1308 |
^ osTime |
|
1309 |
||
1310 |
"Created: 1.7.1996 / 14:33:56 / cg" |
|
699 | 1311 |
! |
1312 |
||
1313 |
getSeconds |
|
1314 |
"strictly private: return the seconds (since whatever)" |
|
1315 |
||
1501 | 1316 |
^ osTime // 1000 |
699 | 1317 |
! |
1318 |
||
1501 | 1319 |
setMilliseconds:millis |
1320 |
"strictly private: set the milliseconds (since whatever)" |
|
1321 |
||
1322 |
osTime := millis. |
|
1323 |
||
1324 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1325 |
"Created: 1.7.1996 / 14:34:24 / cg" |
|
1326 |
! |
|
1327 |
||
699 | 1328 |
setSeconds:secs |
1329 |
"strictly private: set the seconds (since whatever)" |
|
1330 |
||
1501 | 1331 |
osTime := secs * 1000. |
795 | 1332 |
|
1333 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1501 | 1334 |
"Modified: 1.7.1996 / 14:34:10 / cg" |
5853 | 1335 |
! |
1336 |
||
1337 |
utcSecondsSince1970 |
|
1338 |
"return the UTC seconds since 1970" |
|
1339 |
||
9430
919e0cb2257c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
9416
diff
changeset
|
1340 |
^ self getSeconds |
5853 | 1341 |
|
1342 |
" |
|
8246 | 1343 |
Timestamp now utcSecondsSince1970 |
5853 | 1344 |
" |
699 | 1345 |
! ! |
1346 |
||
8396
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1347 |
!Timestamp methodsFor:'visiting'! |
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1348 |
|
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1349 |
acceptVisitor:aVisitor with:aParameter |
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1350 |
|
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1351 |
^ aVisitor visitTimestamp:self with:aParameter |
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1352 |
! ! |
b13503dbc53c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8286
diff
changeset
|
1353 |
|
8246 | 1354 |
!Timestamp class methodsFor:'documentation'! |
699 | 1355 |
|
1356 |
version |
|
9619
6f1fc553757f
skip dashes and colons in readGeneralizedFrom
Claus Gittinger <cg@exept.de>
parents:
9449
diff
changeset
|
1357 |
^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.110 2006-08-22 10:30:37 cg Exp $' |
699 | 1358 |
! ! |
8246 | 1359 |
|
1360 |
Timestamp initialize! |