author | penk |
Wed, 09 Oct 2002 17:30:35 +0200 | |
changeset 6795 | 519894240d97 |
parent 6686 | ac70c231c14e |
child 6955 | adc3cc02fd7e |
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 |
|
241 | 15 |
AbstractTime subclass:#AbsoluteTime |
795 | 16 |
instanceVariableNames:'osTime' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Magnitude-General' |
|
30 | 20 |
! |
21 |
||
2311 | 22 |
!AbsoluteTime 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 |
" |
|
1669 | 40 |
This class represents absolute 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) |
|
46 |
as return from the OS. |
|
47 |
For conversion, these values are given back to the OS, which will know |
|
48 |
how to convert these times. |
|
49 |
This has the advantage, that time-stamps on files (such as last-access- |
|
50 |
time or last-modifiaction-time) can be handled transparent to other |
|
51 |
times - especially comparisons). |
|
241 | 52 |
|
1501 | 53 |
You should not interpret the osTime instance variable directly, instead |
54 |
(if at all), as the OS to convert. |
|
30 | 55 |
|
1501 | 56 |
Its implementation is not the same as in ST-80 |
1669 | 57 |
(which represents Time as seconds from 1. Jan 1901.) |
30 | 58 |
|
241 | 59 |
This class should not be confused with Time (which only represents the |
1501 | 60 |
time within one day). |
61 |
Time instances cannot be used to compare times across midnight; |
|
62 |
instances of AbsoluteTime can. |
|
241 | 63 |
|
3479 | 64 |
Notice: this class is aliased as Timestamp for ST-80 compatibility. |
65 |
||
1306 | 66 |
[author:] |
4679 | 67 |
Claus Gittinger |
1306 | 68 |
|
1282 | 69 |
[See also:] |
4679 | 70 |
Time Date |
71 |
Delay ProcessorScheduler |
|
30 | 72 |
" |
73 |
! ! |
|
74 |
||
2311 | 75 |
!AbsoluteTime class methodsFor:'instance creation'! |
30 | 76 |
|
4378 | 77 |
UTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
1501 | 78 |
"return an instance of the receiver, given individual components. |
79 |
See also `AbsoluteTime now' and other protocol inherited |
|
80 |
from my superclass." |
|
81 |
||
423 | 82 |
^ self basicNew |
4679 | 83 |
fromOSTime:(OperatingSystem |
84 |
computeOSTimeFromUTCYear:y month:m day:d |
|
85 |
hour:h minute:min second:s |
|
86 |
millisecond:millis) |
|
30 | 87 |
|
241 | 88 |
" |
4378 | 89 |
AbsoluteTime UTCYear:1970 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
90 |
AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:0 |
|
91 |
AbsoluteTime UTCYear:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
92 |
AbsoluteTime UTCYear:1999 month:7 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
93 |
AbsoluteTime UTCYear:2000 month:1 day:1 hour:1 minute:0 second:0 millisecond:0 |
|
241 | 94 |
" |
1228 | 95 |
|
4378 | 96 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
97 |
"Created: / 13.7.1999 / 12:34:37 / stefan" |
|
98 |
"Modified: / 13.7.1999 / 12:42:30 / stefan" |
|
99 |
! |
|
100 |
||
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
101 |
basicReadFrom:aStringOrStream |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
102 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
103 |
The string is interpreted as 24 hour format, as printed. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
104 |
Notice, that this is not the storeString format and |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
105 |
is different from the format expected by readFrom:. |
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
106 |
KLUDGE: |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
107 |
us and non-us format have different ordering of day and month; |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
108 |
The format read here is (non-us) dd-mm-yyyy hh:mm:ss.iii |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
109 |
or (us-format, for Travis) mm/dd/yyyy hh:mm:ss.iii. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
110 |
On error, raise an exception" |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
111 |
|
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
112 |
|str first second day month year hour min sec millis usFormat| |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
113 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
114 |
str := aStringOrStream readStream. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
115 |
|
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
116 |
first := Integer readFrom:str. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
117 |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
118 |
first > 12 ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
119 |
"/ assume iso8601 format; |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
120 |
^ self readIso8601FormatFrom:aStringOrStream yearAlreadyRead:year. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
121 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
122 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
123 |
"/ consider this a kludge |
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
124 |
usFormat := (str peek == $/ ). |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
125 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
126 |
[str peek isDigit] whileFalse:[str next]. |
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
127 |
second := Integer readFrom:str. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
128 |
|
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
129 |
usFormat ifTrue:[ |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
130 |
month := first. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
131 |
day := second. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
132 |
] ifFalse:[ |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
133 |
month := second. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
134 |
day := first. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
135 |
]. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
136 |
|
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
137 |
(day between:1 and:31) ifFalse:[ ConversionError raiseErrorString:'bad day' ]. |
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
138 |
(month between:1 and:12) ifFalse:[ ConversionError raiseErrorString:'bad month' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
139 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
140 |
[str peek isDigit] whileFalse:[str next]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
141 |
year := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
142 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
143 |
[str peek isDigit] whileFalse:[str next]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
144 |
hour := Integer readFrom:str. |
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
145 |
(hour between:0 and:24) ifFalse:[ ConversionError raiseErrorString:'bad hour' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
146 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
147 |
[str peek isDigit] whileFalse:[str next]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
148 |
min := Integer readFrom:str. |
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
149 |
(min between:0 and:59) ifFalse:[ ConversionError raiseErrorString:'bad minute' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
150 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
151 |
str atEnd ifTrue:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
152 |
sec := millis := 0. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
153 |
] ifFalse:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
154 |
[str peek isDigit] whileFalse:[str next]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
155 |
sec := Integer readFrom:str. |
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
156 |
(sec between:0 and:59) ifFalse:[ ConversionError raiseErrorString:'bad second' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
157 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
158 |
str peek = $. ifTrue:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
159 |
str next. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
160 |
millis := Integer readFrom:str. |
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
161 |
millis >= 1000 ifTrue:[ ConversionError raiseErrorString:'bad millisecond' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
162 |
] ifFalse:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
163 |
millis := 0. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
164 |
]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
165 |
]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
166 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
167 |
"special check - only 24:00:00 is allowed; |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
168 |
every time after that must wrap" |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
169 |
hour == 24 ifTrue:[ |
6686
ac70c231c14e
raise ConversionError (instead of generic error)
Claus Gittinger <cg@exept.de>
parents:
6684
diff
changeset
|
170 |
(min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ ConversionError raiseErrorString:'bad hour' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
171 |
]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
172 |
^ self year:year month:month day:day hour:hour minute:min second:sec millisecond:millis. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
173 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
174 |
" |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
175 |
AbsoluteTime basicReadFrom:'20-2-1995 13:11:06' |
5677
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
176 |
(AbsoluteTime basicReadFrom:'10-9-1995 13:11:06') month |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
177 |
(AbsoluteTime basicReadFrom:'10/9/1995 13:11:06') month |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
178 |
AbsoluteTime basicReadFrom:'20-2-1995 13:11' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
179 |
AbsoluteTime basicReadFrom:'20-2-1995 13:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
180 |
AbsoluteTime basicReadFrom:'32-2-1995 13:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
181 |
AbsoluteTime basicReadFrom:'32-foo-1995 13:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
182 |
AbsoluteTime basicReadFrom:'20-13-1995 13:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
183 |
AbsoluteTime basicReadFrom:'20-12-1995 25:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
184 |
AbsoluteTime basicReadFrom:'20-12-1995 23:61:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
185 |
AbsoluteTime basicReadFrom:'20-12-1995 23:10:66.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
186 |
AbsoluteTime basicReadFrom:'20-12-1995 23:10:00.1000' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
187 |
AbsoluteTime basicReadFrom:'20-2-1995 24:01:00.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
188 |
AbsoluteTime basicReadFrom:'20-2-1995 24:00:01.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
189 |
AbsoluteTime basicReadFrom:'foo' |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
190 |
AbsoluteTime basicReadFrom:(AbsoluteTime now printString) |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
191 |
AbsoluteTime basicReadFrom:'1995-10-20 24:00:00.000' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
192 |
AbsoluteTime basicReadFrom:'1995-10-20 12:10:00.000' |
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
193 |
" |
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
194 |
! |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
195 |
|
4378 | 196 |
day:d month:m year:y hour:h minutes:min seconds:s |
197 |
"This is obsolete. User #year:month:day:hour:minute:second:" |
|
198 |
||
199 |
^ self |
|
4679 | 200 |
year:y month:m day:d hour:h |
201 |
minute:min second:s millisecond:0 |
|
4378 | 202 |
|
203 |
" |
|
204 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
205 |
AbsoluteTime day:8 month:1 year:1995 hour:0 minute:43 second:48 |
|
206 |
" |
|
207 |
||
208 |
"Modified: / 1.7.1996 / 15:22:26 / cg" |
|
209 |
"Modified: / 13.7.1999 / 12:29:56 / stefan" |
|
210 |
! |
|
211 |
||
212 |
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis |
|
213 |
"This is obsolete. User #year:month:day:hour:minute:second:millisecond:" |
|
214 |
||
215 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
216 |
||
217 |
" |
|
218 |
AbsoluteTime day:1 month:1 year:1970 hour:1 minute:0 second:0 |
|
219 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
220 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 millisecond:100 |
|
221 |
" |
|
222 |
||
223 |
"Created: / 1.7.1996 / 14:46:09 / cg" |
|
224 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
225 |
"Modified: / 13.7.1999 / 12:30:26 / stefan" |
|
275 | 226 |
! |
227 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
228 |
decodeFromLiteralArray:anArray |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
229 |
"decode an AbsoluteTime literalArray. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
230 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
231 |
anArray may be: |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
232 |
#(AbsoluteTime '200004182000.123') |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
233 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
234 |
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
|
235 |
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
|
236 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
237 |
#(AbsoluteTime #osTime: 12345678) |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
238 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
239 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
240 |
(anArray at:2) == #osTime: ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
241 |
^ self new osTime:(anArray at:3). |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
242 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
243 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
244 |
^ self readGeneralizedFrom:(anArray at:2) onError:[self error:'literal array decoding'] |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
245 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
246 |
|
423 | 247 |
fromDate:aDate andTime:aTime |
248 |
"return an instance of the receiver, initialized from a time and a date |
|
1228 | 249 |
object. |
250 |
See also `AbsoluteTime now' and other protocol inherited |
|
251 |
from my superclass." |
|
423 | 252 |
|
253 |
^ self |
|
4679 | 254 |
year:aDate year |
255 |
month:aDate month |
|
256 |
day:aDate day |
|
257 |
hour:aTime hours |
|
258 |
minute:aTime minutes |
|
259 |
second:aTime seconds |
|
423 | 260 |
|
261 |
" |
|
1228 | 262 |
AbsoluteTime fromDate:(Date today) andTime:(Time now) |
263 |
AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) |
|
264 |
AbsoluteTime now |
|
423 | 265 |
" |
266 |
||
4378 | 267 |
"Modified: / 8.9.1995 / 15:07:30 / claus" |
268 |
"Modified: / 19.4.1996 / 15:25:46 / cg" |
|
269 |
"Modified: / 13.7.1999 / 12:30:47 / stefan" |
|
423 | 270 |
! |
271 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
272 |
newDay:dayInYear year:year |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
273 |
"return a new AbsoluteTime, given the year and the day-in-year (starting at 1). |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
274 |
Date protocol compatibility" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
275 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
276 |
^ (Date newDay:dayInYear year:year) asAbsoluteTime |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
277 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
278 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
279 |
AbsoluteTime newDay:183 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
280 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
281 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
282 |
"Modified: 2.7.1996 / 09:39:30 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
283 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
284 |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
285 |
readFrom:aStringOrStream onError:exceptionBlock |
275 | 286 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
287 |
The string is interpreted as 24 hour format, as printed. |
|
288 |
Notice, that this is not the storeString format and |
|
4898 | 289 |
is different from the format expected by readFrom:. |
290 |
The format read here is dd-mm-yyyy hh:mm:ss.iii" |
|
275 | 291 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
292 |
|newTime| |
275 | 293 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
294 |
ErrorSignal handle:[:ex | |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
295 |
^ super readFrom:aStringOrStream onError:exceptionBlock |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
296 |
] do:[ |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
297 |
newTime := self basicReadFrom:aStringOrStream. |
275 | 298 |
]. |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
299 |
^ newTime |
275 | 300 |
|
301 |
" |
|
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
302 |
AbsoluteTime readFrom:'20-2-1995 13:11:06' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
303 |
AbsoluteTime readFrom:'20-2-1995 13:11' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
304 |
AbsoluteTime readFrom:'20-2-2001 13:11' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
305 |
AbsoluteTime readFrom:'20-2-1995 13:11:06.100' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
306 |
AbsoluteTime readFrom:'32-2-1995 13:11:06.100' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
307 |
AbsoluteTime readFrom:'32-foo-1995 13:11:06.100' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
308 |
AbsoluteTime readFrom:'20-2-1995 24:01:00.100' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
309 |
AbsoluteTime readFrom:'20-2-1995 24:00:01.100' onError:'wrong' |
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
310 |
AbsoluteTime readFrom:'2002-08-02 24:00:01.100' onError:'wrong' |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
311 |
AbsoluteTime readFrom:'foo' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
312 |
AbsoluteTime readFrom:(AbsoluteTime now storeString) onError:'wrong' |
275 | 313 |
" |
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
314 |
|
4378 | 315 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
316 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
|
2311 | 317 |
! |
318 |
||
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
319 |
readGeneralizedFrom:aStringOrStream onError:exceptionBlock |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
320 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
321 |
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
|
322 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
323 |
Notice, that this is not the storeString format and |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
324 |
is different from the format expected by readFrom:. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
325 |
The format read here is yyyymmddHHMMSS.iii+uuuu, |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
326 |
which is the ASN1 GeneralizedTime format." |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
327 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
328 |
|newTime| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
329 |
|
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
330 |
^ [ |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
331 |
|str day month year hour min sec millis c| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
332 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
333 |
sec := millis := 0. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
334 |
str := aStringOrStream readStream. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
335 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
336 |
year := Integer readFrom:(str next:4). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
337 |
month := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
338 |
(month between:1 and:12) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
339 |
day := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
340 |
(day between:1 and:31) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
341 |
hour:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
342 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
343 |
min:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
344 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
345 |
str atEnd ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
346 |
sec := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
347 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
348 |
str peek == $. ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
349 |
str next. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
350 |
millis := Integer readFrom:str. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
351 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
352 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
353 |
str atEnd ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
354 |
"/ this is local time |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
355 |
newTime := self year:year month:month day:day |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
356 |
hour:hour minute:min second:sec millisecond:millis. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
357 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
358 |
c := str next. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
359 |
c ~~ $Z ifTrue:[ |tzh tzmin| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
360 |
tzh := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
361 |
tzmin := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
362 |
c == $+ ifTrue:[ |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
363 |
"/ add hours and minutes |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
364 |
hour := hour + tzh. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
365 |
min := min + tzmin. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
366 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
367 |
c ~~ $- ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
368 |
self error:'bad time offset'. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
369 |
]. |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
370 |
"/ subtract hours and minutes |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
371 |
hour := hour - tzh. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
372 |
min := min - tzmin. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
373 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
374 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
375 |
"/ this is UTC time |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
376 |
newTime := self UTCYear:year month:month day:day |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
377 |
hour:hour minute:min second:sec millisecond:millis. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
378 |
]. |
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
379 |
newTime |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6047
diff
changeset
|
380 |
] on:Error do:exceptionBlock. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
381 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
382 |
" |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
383 |
|s| |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
384 |
s := '' writeStream. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
385 |
AbsoluteTime now printGeneralizedOn:s. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
386 |
AbsoluteTime readGeneralizedFrom:s contents onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
387 |
|
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
388 |
AbsoluteTime readGeneralizedFrom:'20001018000000+0200' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
389 |
AbsoluteTime readGeneralizedFrom:'20001018000000+0300' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
390 |
|
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
391 |
AbsoluteTime readGeneralizedFrom:'20000202000000+0100' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
392 |
AbsoluteTime readGeneralizedFrom:'20000202000000+0200' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
393 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
394 |
AbsoluteTime readGeneralizedFrom:'19950220131106' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
395 |
AbsoluteTime readGeneralizedFrom:'199502201311' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
396 |
AbsoluteTime readGeneralizedFrom:'19950220131106.100' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
397 |
AbsoluteTime readGeneralizedFrom:'19950232131106.100' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
398 |
AbsoluteTime readGeneralizedFrom:'19950fo2131106.100' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
399 |
AbsoluteTime readGeneralizedFrom:'foo' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
400 |
" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
401 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
402 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
403 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
404 |
! |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
405 |
|
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
406 |
readIso8601FormatFrom:aStringOrStream |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
407 |
"return a new AbsoluteTime, reading an iso8601 UTC representation from aStream. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
Of course, a 24 hour clock is used. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
413 |
On error, raise an exception. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
414 |
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
|
415 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
416 |
^ self |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
417 |
readIso8601FormatFrom:aStringOrStream yearAlreadyRead:nil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
418 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
419 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
420 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
421 |
AbsoluteTime readIso8601FormatFrom:'1995-02T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
422 |
AbsoluteTime readIso8601FormatFrom:'1995T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
423 |
AbsoluteTime readIso8601FormatFrom:'1995T13:11' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
424 |
AbsoluteTime readIso8601FormatFrom:'1995T13' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
425 |
AbsoluteTime readIso8601FormatFrom:'1995' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
426 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
427 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
428 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13:11' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
429 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
430 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
431 |
24 is allowed with ISO, and is 00:00 of the next day: |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
432 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 24:00:00' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
433 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
434 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
435 |
! |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
436 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
437 |
readIso8601FormatFrom:aStringOrStream yearAlreadyRead:yearOrNil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
438 |
"common helper for read methods. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
439 |
Return a new AbsoluteTime, reading an iso8601 UTC representation from aStream. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
Of course, a 24 hour clock is used. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
445 |
On error, raise an exception. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
446 |
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
|
447 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
448 |
|str day month year hour min sec millis fraction tz| |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
449 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
450 |
str := aStringOrStream readStream. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
451 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
452 |
month := day := 1. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
453 |
hour := min := sec := millis := 0. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
454 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
455 |
yearOrNil notNil ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
456 |
year := yearOrNil |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
457 |
] ifFalse:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
458 |
year := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
459 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
460 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
461 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
462 |
str peek == $- ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
463 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
464 |
"/ month follows. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
465 |
month := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
466 |
(month between:1 and:12) ifFalse:[ ConversionError raiseErrorString:'bad month' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
467 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
468 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
469 |
str peek == $- ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
470 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
471 |
"/ day follows. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
472 |
day := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
473 |
(day between:1 and:31) ifFalse:[ ConversionError raiseErrorString:'bad day' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
474 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
475 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
476 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
477 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
478 |
str atEnd ifFalse:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
479 |
"time follows" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
480 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
481 |
str peek == $T ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
482 |
"we treat the T as optional here" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
483 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
484 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
485 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
486 |
hour := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
487 |
(hour between:0 and:24) ifFalse:[ ConversionError raiseErrorString:'bad hour' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
488 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
489 |
str peek == $: ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
490 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
491 |
"/ minutes follow. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
492 |
min := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
493 |
(min between:0 and:59) ifFalse:[ ConversionError raiseErrorString:'bad minute' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
494 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
495 |
str peek == $: ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
496 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
497 |
"/ seconds follow. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
498 |
sec := Integer readFrom:str. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
499 |
(sec between:0 and:59) ifFalse:[ ConversionError raiseErrorString:'bad seconds' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
500 |
str skipSeparators. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
501 |
str peek == $. ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
502 |
str next. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
503 |
"/ millis follow. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
504 |
fraction := Number readMantissaFrom:str radix:10. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
505 |
millis := 1000 * fraction rounded. "/ mhmh - should it be truncated ? |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
506 |
] |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
507 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
508 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
509 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
510 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
511 |
"special check - only 24:00:00 is allowed; |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
512 |
every time after that must wrap" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
513 |
hour == 24 ifTrue:[ |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
514 |
(min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ Error raiseErrorString:'bad hour' ]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
515 |
]. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
516 |
^ self |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
517 |
year:year month:month day:day |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
518 |
hour:hour minute:min second:sec millisecond:millis. |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
519 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
520 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
521 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
522 |
AbsoluteTime readIso8601FormatFrom:'1995-02T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
523 |
AbsoluteTime readIso8601FormatFrom:'1995T13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
524 |
AbsoluteTime readIso8601FormatFrom:'1995T13:11' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
525 |
AbsoluteTime readIso8601FormatFrom:'1995T13' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
526 |
AbsoluteTime readIso8601FormatFrom:'1995' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
527 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
528 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13:11:06' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
529 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13:11' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
530 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 13' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
531 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
532 |
24 is allowed with ISO, and is 00:00 of the next day: |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
533 |
AbsoluteTime readIso8601FormatFrom:'1995-02-20 24:00:00' |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
534 |
|
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
535 |
" |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
536 |
! |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
537 |
|
2311 | 538 |
secondsSince1970:sec |
539 |
"set time from elapsed seconds since 1-1-1970, 0:0:0. |
|
540 |
This is the format used in the UNIX world" |
|
541 |
||
4378 | 542 |
^ self year:1970 month:1 day:1 hour:0 minute:0 second:sec. |
543 |
||
544 |
" |
|
4679 | 545 |
AbsoluteTime secondsSince1970:0 |
546 |
AbsoluteTime secondsSince1970:3600 |
|
4378 | 547 |
" |
548 |
||
549 |
"Created: / 21.10.1996 / 17:48:30 / stefan" |
|
550 |
"Modified: / 13.7.1999 / 12:31:22 / stefan" |
|
551 |
! |
|
552 |
||
553 |
year:y month:m day:d hour:h minute:min second:s |
|
554 |
"return an instance of the receiver, given individual components. |
|
555 |
See also `AbsoluteTime now' and other protocol inherited |
|
556 |
from my superclass." |
|
557 |
||
558 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:0 |
|
2311 | 559 |
|
560 |
" |
|
4378 | 561 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 second:0 |
562 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
563 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
564 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minutes:0 second:0 |
|
2311 | 565 |
" |
566 |
||
4378 | 567 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
568 |
"Created: / 13.7.1999 / 12:06:39 / stefan" |
|
569 |
"Modified: / 13.7.1999 / 12:27:47 / stefan" |
|
570 |
! |
|
571 |
||
572 |
year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
573 |
"return an instance of the receiver, given individual components. |
|
574 |
See also `AbsoluteTime now' and other protocol inherited |
|
575 |
from my superclass." |
|
576 |
||
577 |
^ self basicNew |
|
4679 | 578 |
fromOSTime:(OperatingSystem |
579 |
computeOSTimeFromYear:y month:m day:d |
|
580 |
hour:h minute:min seconds:s millis:millis) |
|
4378 | 581 |
|
582 |
" |
|
583 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 seconds:0 |
|
584 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
585 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
586 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minute:0 second:0 |
|
587 |
" |
|
588 |
||
589 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
590 |
"Created: / 13.7.1999 / 12:28:44 / stefan" |
|
591 |
"Modified: / 13.7.1999 / 12:37:57 / stefan" |
|
241 | 592 |
! ! |
30 | 593 |
|
594 |
!AbsoluteTime methodsFor:'accessing'! |
|
595 |
||
596 |
day |
|
92 | 597 |
"return the day-in-month of the receiver (1..31). |
275 | 598 |
For compatibility, use instances of Date for this." |
30 | 599 |
|
5858 | 600 |
|v d| |
241 | 601 |
|
5858 | 602 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
603 |
d := v at:3. |
|
604 |
"/ OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
|
605 |
"/ d := day |
|
606 |
"/ ]. |
|
241 | 607 |
^ d |
54 | 608 |
|
92 | 609 |
" |
241 | 610 |
AbsoluteTime now day |
92 | 611 |
" |
1501 | 612 |
|
613 |
"Modified: 1.7.1996 / 15:23:02 / cg" |
|
614 |
! |
|
615 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
616 |
dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
617 |
"return the week-day of the receiver - 1 for monday, 7 for sunday" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
618 |
|
3120 | 619 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:11 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
620 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
621 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
622 |
AbsoluteTime now dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
623 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
624 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
625 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
626 |
"Created: 2.7.1996 / 09:35:48 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
627 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
628 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
629 |
dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
630 |
"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
|
631 |
|
3120 | 632 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:10 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
633 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
634 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
635 |
AbsoluteTime now dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
636 |
AbsoluteTime newDay:184 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
637 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
638 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
639 |
"Modified: 2.7.1996 / 10:21:02 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
640 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
641 |
|
1501 | 642 |
hour |
643 |
"return the hour (0..23). |
|
644 |
ST-80 Timestamp compatibility (I'd prefer the name #hours, for Time compatibility)." |
|
645 |
||
646 |
^ self hours |
|
647 |
||
648 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
649 |
"Modified: 1.7.1996 / 15:15:32 / cg" |
|
30 | 650 |
! |
651 |
||
241 | 652 |
hours |
653 |
"return the hours (0..23)" |
|
654 |
||
5858 | 655 |
|v hr| |
241 | 656 |
|
5858 | 657 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
658 |
hr := v at:4. |
|
659 |
||
660 |
"/ OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
|
661 |
"/ hr := hours |
|
662 |
"/ ]. |
|
241 | 663 |
^ hr |
54 | 664 |
|
92 | 665 |
" |
241 | 666 |
AbsoluteTime now hours |
667 |
" |
|
668 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
669 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
1501 | 670 |
! |
671 |
||
672 |
millisecond |
|
673 |
"return the millisecond (0..999). |
|
674 |
ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)." |
|
675 |
||
676 |
^ self milliseconds |
|
677 |
||
678 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
679 |
"Modified: 1.7.1996 / 15:15:24 / cg" |
|
680 |
! |
|
681 |
||
682 |
milliseconds |
|
683 |
"return the milliseconds (0..999)" |
|
684 |
||
5858 | 685 |
|v m| |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
686 |
|
5858 | 687 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
688 |
m := v at:9. |
|
689 |
"/ OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
|
690 |
"/ m := millis |
|
691 |
"/ ]. |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
692 |
^ m |
1501 | 693 |
|
694 |
" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
695 |
AbsoluteTime now milliseconds |
1501 | 696 |
" |
697 |
||
698 |
"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
|
699 |
"Modified: 2.7.1996 / 09:21:41 / cg" |
1501 | 700 |
! |
701 |
||
702 |
minute |
|
703 |
"return the minute (0..59). |
|
704 |
ST-80 Timestamp compatibility (I'd prefer the name #minutes, for Time compatibility)." |
|
705 |
||
706 |
^ self minutes |
|
707 |
||
708 |
"Created: 1.7.1996 / 15:14:29 / cg" |
|
709 |
"Modified: 1.7.1996 / 15:15:37 / cg" |
|
241 | 710 |
! |
711 |
||
712 |
minutes |
|
713 |
"return the minutes (0..59)" |
|
714 |
||
5858 | 715 |
|v m| |
241 | 716 |
|
5858 | 717 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
718 |
m := v at:5. |
|
719 |
"/ OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
|
720 |
"/ m := minutes |
|
721 |
"/ ]. |
|
241 | 722 |
^ m |
723 |
||
724 |
" |
|
725 |
AbsoluteTime now minutes |
|
92 | 726 |
" |
241 | 727 |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
728 |
"Modified: 2.7.1996 / 09:20:49 / cg" |
241 | 729 |
! |
730 |
||
699 | 731 |
month |
732 |
"return the month of the receiver (1..12). |
|
733 |
For compatibility, use instances of Date for this." |
|
734 |
||
5858 | 735 |
|v m| |
699 | 736 |
|
5858 | 737 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
738 |
m := v at:2. |
|
739 |
"/ OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day | |
|
740 |
"/ m := month |
|
741 |
"/ ]. |
|
699 | 742 |
^ m |
743 |
||
744 |
" |
|
745 |
AbsoluteTime now month |
|
746 |
" |
|
1501 | 747 |
|
748 |
"Modified: 1.7.1996 / 15:23:05 / cg" |
|
749 |
! |
|
750 |
||
4807 | 751 |
osTime:aTime |
5726 | 752 |
"set the internal representation of the time" |
753 |
||
4807 | 754 |
osTime := aTime. |
755 |
! |
|
756 |
||
1501 | 757 |
second |
758 |
"return the second (0..59). |
|
759 |
ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)." |
|
760 |
||
761 |
^ self seconds |
|
762 |
||
763 |
"Created: 1.7.1996 / 15:14:19 / cg" |
|
764 |
"Modified: 1.7.1996 / 15:15:49 / cg" |
|
699 | 765 |
! |
766 |
||
241 | 767 |
seconds |
768 |
"return the seconds (0..59)" |
|
769 |
||
5858 | 770 |
|v s| |
241 | 771 |
|
5858 | 772 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
773 |
s := v at:6. |
|
774 |
"/ OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
|
775 |
"/ s := secs |
|
776 |
"/ ]. |
|
241 | 777 |
^ s |
778 |
||
779 |
" |
|
780 |
AbsoluteTime now seconds |
|
781 |
" |
|
782 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
783 |
"Modified: 2.7.1996 / 09:20:54 / cg" |
92 | 784 |
! |
785 |
||
799 | 786 |
utcOffset |
787 |
"return the difference between UTC (Greenwich Mean Time) and the local time |
|
788 |
if daylight saving time applies to ourself, take that into account. |
|
5853 | 789 |
Add utcOffset before converting to get UTC-Time resp. UTC-Date. |
799 | 790 |
" |
791 |
||
792 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7 |
|
793 |
||
794 |
" |
|
795 |
AbsoluteTime now utcOffset |
|
796 |
(AbsoluteTime day:1 month:7 year:1995 hour:12 minutes:0 seconds:0) utcOffset |
|
797 |
" |
|
798 |
||
799 |
"Modified: 20.12.1995 / 17:28:49 / stefan" |
|
1501 | 800 |
"Modified: 1.7.1996 / 15:21:29 / cg" |
799 | 801 |
! |
802 |
||
699 | 803 |
year |
804 |
"return the year of the receiver i.e. 1992. |
|
805 |
For compatibility, use instances of Date for this." |
|
241 | 806 |
|
5858 | 807 |
|v y| |
241 | 808 |
|
5858 | 809 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
810 |
y := v at:1. |
|
811 |
"/ OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
|
812 |
"/ y := year |
|
813 |
"/ ]. |
|
699 | 814 |
^ y |
241 | 815 |
|
816 |
" |
|
699 | 817 |
AbsoluteTime now year |
241 | 818 |
" |
1501 | 819 |
|
820 |
"Modified: 1.7.1996 / 15:23:08 / cg" |
|
241 | 821 |
! ! |
822 |
||
30 | 823 |
!AbsoluteTime methodsFor:'arithmetic'! |
824 |
||
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
825 |
millisecondDeltaFrom:anAbsoluteTime |
3510 | 826 |
"return the delta in milliseconds between 2 absolute times. |
827 |
The argument is supposed to be AFTER the receiver" |
|
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
828 |
|
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
829 |
^ self getMilliseconds - (anAbsoluteTime getMilliseconds) |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
830 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
831 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
832 |
|t1 t2| |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
833 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
834 |
t1 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
835 |
Delay waitForSeconds:0.5. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
836 |
t2 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
837 |
t2 millisecondDeltaFrom:t1 |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
838 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
839 |
|
3510 | 840 |
"Modified: / 5.6.1998 / 04:21:33 / cg" |
30 | 841 |
! ! |
842 |
||
699 | 843 |
!AbsoluteTime methodsFor:'comparing'! |
844 |
||
845 |
= aTime |
|
846 |
"return true if the argument, aTime represents the same time" |
|
847 |
||
848 |
(aTime species == self species) ifFalse:[^ false]. |
|
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
849 |
^ (self getMilliseconds = aTime getMilliseconds) |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
850 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
851 |
"Modified: 3.7.1996 / 13:10:24 / cg" |
699 | 852 |
! |
853 |
||
854 |
hash |
|
855 |
"return an integer useful for hashing on times" |
|
856 |
||
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
857 |
^ osTime // 1000 |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
858 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
859 |
"Modified: 3.7.1996 / 13:10:52 / cg" |
699 | 860 |
! ! |
861 |
||
862 |
!AbsoluteTime methodsFor:'converting'! |
|
863 |
||
864 |
asAbsoluteTime |
|
865 |
"return an AbsoluteTime object from the receiver - thats the receiver." |
|
866 |
||
867 |
^ self |
|
868 |
! |
|
869 |
||
870 |
asDate |
|
871 |
"return a Date object from the receiver. |
|
872 |
The returned date will only represent the day - not the timeOfDay." |
|
873 |
||
874 |
^ Date fromOSTime:osTime |
|
875 |
||
876 |
" |
|
877 |
AbsoluteTime now |
|
878 |
AbsoluteTime now asDate |
|
879 |
(AbsoluteTime now addTime:3600) asDate |
|
880 |
(AbsoluteTime now addTime:3600) asTime |
|
881 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
882 |
(AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate |
|
883 |
" |
|
884 |
||
885 |
! |
|
886 |
||
887 |
asSeconds |
|
888 |
"return the number of seconds elapsed since whatever time the |
|
889 |
OperatingSystem bases its time upon. Since this is totally |
|
890 |
OS-dependent, do not interpret the value returned by this method. |
|
891 |
You can use it to add/subtract seconds or get time deltas, though." |
|
892 |
||
893 |
^ self getSeconds |
|
894 |
||
895 |
" |
|
896 |
AbsoluteTime now asSeconds |
|
897 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
898 |
Time hour:23 minutes:33 seconds:0 |
|
899 |
Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) |
|
900 |
" |
|
901 |
! |
|
902 |
||
903 |
asTime |
|
904 |
"return a Time object from the receiver. |
|
905 |
The returned time will only represent the timeOfDay - not the day." |
|
906 |
||
907 |
^ Time fromOSTime:osTime |
|
908 |
||
909 |
" |
|
910 |
AbsoluteTime now |
|
911 |
AbsoluteTime now asTime |
|
912 |
(AbsoluteTime now addTime:3600) asTime |
|
913 |
" |
|
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
914 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
915 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
916 |
literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
917 |
"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
|
918 |
can be reconstructed with #decodeAsLiteralArray. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
919 |
The encoding is: |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
920 |
(#AbsoluteTime YYYYMMDDhhmmss.iii) |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
921 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
922 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
923 |
|s| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
924 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
925 |
s := '' writeStream. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
926 |
self printGeneralizedOn:s isLocal:true. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
927 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
928 |
^ Array |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
929 |
with:self class name asSymbol |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
930 |
with:s contents |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
931 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
932 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
933 |
AbsoluteTime now literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
934 |
AbsoluteTime decodeFromLiteralArray:AbsoluteTime now literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
935 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
936 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
937 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
938 |
|
699 | 939 |
! ! |
940 |
||
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
941 |
!AbsoluteTime methodsFor:'encoding'! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
942 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
943 |
encodeOn:anEncoder with:aParameter |
5726 | 944 |
"encoder visitor support" |
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
945 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
946 |
anEncoder encodeAbsoluteTime:self with:aParameter |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
947 |
! ! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
948 |
|
213 | 949 |
!AbsoluteTime methodsFor:'printing & storing'! |
30 | 950 |
|
4843 | 951 |
addPrintBindingsTo:dict |
5726 | 952 |
"private print support" |
953 |
||
5839 | 954 |
self asDate addPrintBindingsTo:dict. |
6795
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
955 |
|
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
956 |
self year == Date today year ifTrue:[ |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
957 |
dict at:#yearOrTime put:(self asTime printStringFormat:'%h:%m'). |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
958 |
]. |
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
959 |
|
4843 | 960 |
super addPrintBindingsTo:dict. |
5828
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
961 |
|
6634 | 962 |
"/ |d m y s| |
963 |
"/ |
|
5828
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
964 |
"/ OperatingSystem computeDatePartsOf:osTime for:[ |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
965 |
"/ :year :month :day | d := day. m := month. y := year. |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
966 |
"/ ]. |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
967 |
"/ dict at:#day put:(d printString leftPaddedTo:2 with:$0). |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
968 |
"/ dict at:#dayInWeek put:(self dayInWeek). |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
969 |
"/ dict at:#month put:(s := m printString leftPaddedTo:2 with:$0). |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
970 |
"/ dict at:#mon put:s. "/ for backward compatibility only |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
971 |
"/ dict at:#year put:(y printString leftPaddedTo:4 with:$0). |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
972 |
"/ |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
973 |
"/ dict at:#Day put:d printString. |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
974 |
"/ dict at:#Month put:(s := m printString). |
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
975 |
"/ dict at:#Mon put:s. "/ for backward compatibility only |
4843 | 976 |
|
977 |
" |
|
5828
5b148250732f
same format-codes in printFormat as Date (and use that code)
Claus Gittinger <cg@exept.de>
parents:
5726
diff
changeset
|
978 |
AbsoluteTime now printOn:Transcript format:'%(day).%(ShortMonthName)'. Transcript cr. |
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
979 |
AbsoluteTime now printOn:Transcript format:'%(day):%(month)'. Transcript cr. |
4843 | 980 |
AbsoluteTime now printOn:Transcript format:'%(dayInWeek)'. Transcript cr. |
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
981 |
AbsoluteTime now printOn:Transcript format:'%(Day)-%(month)-%(year) %h:%m:%s.%i'. Transcript cr. |
4843 | 982 |
AbsoluteTime now printOn:Transcript. Transcript cr |
983 |
" |
|
984 |
! |
|
985 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
986 |
printGeneralizedOn:aStream |
5290 | 987 |
"append a representation of the receiver to aStream in a general format, |
988 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
|
989 |
This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33, |
|
990 |
so read this before changing the output format." |
|
991 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
992 |
^ self printGeneralizedOn:aStream isLocal:false. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
993 |
! |
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 |
printGeneralizedOn:aStream isLocal:isLocal |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
996 |
"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
|
997 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
998 |
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
|
999 |
so read this before changing the output format. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1000 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1001 |
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
|
1002 |
|
5290 | 1003 |
|t off| |
1004 |
||
1005 |
t := OperatingSystem computeTimeAndDateFrom:osTime. |
|
1006 |
||
1007 |
(t at:1) printOn:aStream leftPaddedTo:4 with:$0. |
|
1008 |
(t at:2) printOn:aStream leftPaddedTo:2 with:$0. |
|
1009 |
(t at:3) printOn:aStream leftPaddedTo:2 with:$0. |
|
1010 |
(t at:4) printOn:aStream leftPaddedTo:2 with:$0. |
|
1011 |
(t at:5) printOn:aStream leftPaddedTo:2 with:$0. |
|
1012 |
(t at:6) printOn:aStream leftPaddedTo:2 with:$0. |
|
1013 |
aStream nextPut:$.. |
|
1014 |
(t at:9) printOn:aStream leftPaddedTo:3 with:$0. |
|
1015 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1016 |
isLocal ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1017 |
"/ this should be printed as non-local-time |
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 |
off := t at:7. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1020 |
off == 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1021 |
aStream nextPut:$Z. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1022 |
] ifFalse:[ |min| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1023 |
off < 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1024 |
aStream nextPut:$+. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1025 |
off := off negated. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1026 |
] ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1027 |
aStream nextPut:$-. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1028 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1029 |
min := off // 60. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1030 |
min // 60 printOn:aStream leftPaddedTo:2 with:$0. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
1031 |
min \\ 60 printOn:aStream leftPaddedTo:2 with:$0. |
5290 | 1032 |
]. |
1033 |
]. |
|
1034 |
||
1035 |
||
1036 |
" |
|
5291 | 1037 |
AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. |
1038 |
(AbsoluteTime fromSeconds:0) printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 1039 |
Time now printOn:Transcript. Transcript cr. |
1040 |
Date today printOn:Transcript. Transcript cr. |
|
1041 |
||
5291 | 1042 |
Time now asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr. |
1043 |
AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 1044 |
|
5291 | 1045 |
Date today asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr. |
5290 | 1046 |
Date today printOn:Transcript. Transcript cr. |
1047 |
" |
|
1048 |
||
1049 |
"Modified: / 1.7.1996 / 15:20:59 / cg" |
|
1050 |
"Modified: / 17.1.2000 / 15:53:02 / stefan" |
|
1051 |
! |
|
1052 |
||
241 | 1053 |
printOn:aStream |
275 | 1054 |
"append a user readable representation of the receiver to aStream. |
1055 |
The format is compatible with readFromString:, but not with readFrom:." |
|
1056 |
||
6684
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
1057 |
"/ now, use ISO format... |
1f4d15ab7c4c
default printString is now iso format.
Claus Gittinger <cg@exept.de>
parents:
6634
diff
changeset
|
1058 |
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
|
1059 |
"/ self printOn:aStream format:'%(Day)-%(mon)-%(year) %h:%m:%s.%i' |
5678 | 1060 |
"/ self printOn:aStream format:'%(mon)/%(Day)/%(year) %h:%m:%s.%i' |
92 | 1061 |
|
1062 |
" |
|
275 | 1063 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
1064 |
(AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr. |
|
1065 |
Time now printOn:Transcript. Transcript cr. |
|
1066 |
Date today printOn:Transcript. Transcript cr. |
|
1501 | 1067 |
|
1068 |
Time now asAbsoluteTime printOn:Transcript. Transcript cr. |
|
1069 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
|
1070 |
||
1071 |
Date today asAbsoluteTime printOn:Transcript. Transcript cr. |
|
1072 |
Date today printOn:Transcript. Transcript cr. |
|
92 | 1073 |
" |
1501 | 1074 |
|
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
1075 |
"Modified: 1.7.1996 / 15:20:59 / cg" |
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
1076 |
! |
30 | 1077 |
|
241 | 1078 |
storeOn:aStream |
275 | 1079 |
"store the receiver in a format suitable for reconstruction of the |
1080 |
receiver via readFrom:" |
|
1081 |
||
241 | 1082 |
aStream nextPut:$(; |
242 | 1083 |
nextPutAll:self class name; |
275 | 1084 |
nextPutAll:' new setSeconds:'. |
1085 |
self getSeconds storeOn:aStream. |
|
241 | 1086 |
aStream nextPut:$). |
54 | 1087 |
|
241 | 1088 |
" |
275 | 1089 |
AbsoluteTime now storeString |
30 | 1090 |
|
275 | 1091 |
AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream |
241 | 1092 |
" |
30 | 1093 |
! ! |
699 | 1094 |
|
1095 |
!AbsoluteTime methodsFor:'private'! |
|
1096 |
||
1501 | 1097 |
fromOSTime:anUninterpretedOSTime |
699 | 1098 |
"strictly private: set the seconds from an OS time (since whatever)" |
1099 |
||
1501 | 1100 |
osTime := anUninterpretedOSTime |
1101 |
||
1102 |
"Created: 1.7.1996 / 14:33:21 / cg" |
|
1103 |
! |
|
1104 |
||
1105 |
getMilliseconds |
|
1106 |
"strictly private: return the milliseconds (since whatever)" |
|
1107 |
||
1108 |
^ osTime |
|
1109 |
||
1110 |
"Created: 1.7.1996 / 14:33:56 / cg" |
|
699 | 1111 |
! |
1112 |
||
1113 |
getSeconds |
|
1114 |
"strictly private: return the seconds (since whatever)" |
|
1115 |
||
1501 | 1116 |
^ osTime // 1000 |
699 | 1117 |
! |
1118 |
||
1501 | 1119 |
setMilliseconds:millis |
1120 |
"strictly private: set the milliseconds (since whatever)" |
|
1121 |
||
1122 |
osTime := millis. |
|
1123 |
||
1124 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1125 |
"Created: 1.7.1996 / 14:34:24 / cg" |
|
1126 |
! |
|
1127 |
||
699 | 1128 |
setSeconds:secs |
1129 |
"strictly private: set the seconds (since whatever)" |
|
1130 |
||
1501 | 1131 |
osTime := secs * 1000. |
795 | 1132 |
|
1133 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1501 | 1134 |
"Modified: 1.7.1996 / 14:34:10 / cg" |
5853 | 1135 |
! |
1136 |
||
1137 |
utcSecondsSince1970 |
|
1138 |
"return the UTC seconds since 1970" |
|
1139 |
||
1140 |
|localTimeSeconds| |
|
1141 |
||
1142 |
OperatingSystem isUNIXlike ifFalse:[ |
|
1143 |
self error:'unimplemented'. |
|
1144 |
]. |
|
1145 |
localTimeSeconds := self getSeconds. |
|
1146 |
^ localTimeSeconds - self utcOffset |
|
1147 |
||
1148 |
" |
|
1149 |
AbsoluteTime now utcSecondsSince1970 |
|
1150 |
" |
|
699 | 1151 |
! ! |
1152 |
||
2311 | 1153 |
!AbsoluteTime class methodsFor:'documentation'! |
699 | 1154 |
|
1155 |
version |
|
6795
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6686
diff
changeset
|
1156 |
^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.69 2002-10-09 15:30:35 penk Exp $' |
699 | 1157 |
! ! |