author | Claus Gittinger <cg@exept.de> |
Mon, 08 Jan 2001 17:36:43 +0100 | |
changeset 5777 | 69a22679b0af |
parent 5726 | be29c70156c1 |
child 5828 | 5b148250732f |
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 |
|
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
118 |
usFormat := (str peek == $/ ). |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
119 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
120 |
[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
|
121 |
second := Integer readFrom:str. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
122 |
|
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
123 |
usFormat ifTrue:[ |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
124 |
month := first. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
125 |
day := second. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
126 |
] ifFalse:[ |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
127 |
month := second. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
128 |
day := first. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
129 |
]. |
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
130 |
|
52bd6bf1775f
us/non-us format reading ($/ as separator: us-format)
Claus Gittinger <cg@exept.de>
parents:
5656
diff
changeset
|
131 |
(day between:1 and:31) ifFalse:[ Error raiseErrorString:'bad day' ]. |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
132 |
(month between:1 and:12) ifFalse:[ Error raiseErrorString:'bad month' ]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
133 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
134 |
[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
|
135 |
year := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
136 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
137 |
[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
|
138 |
hour := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
139 |
(hour between:0 and:24) ifFalse:[ Error raiseErrorString:'bad hour' ]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
140 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
141 |
[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
|
142 |
min := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
143 |
(min between:0 and:59) ifFalse:[ Error raiseErrorString:'bad minute' ]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
144 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
145 |
str atEnd ifTrue:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
146 |
sec := millis := 0. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
147 |
] ifFalse:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
148 |
[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
|
149 |
sec := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
150 |
(sec between:0 and:59) ifFalse:[ Error raiseErrorString:'bad second' ]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
151 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
152 |
str peek = $. ifTrue:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
153 |
str next. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
154 |
millis := Integer readFrom:str. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
155 |
millis >= 1000 ifTrue:[ Error raiseErrorString:'bad millisecond' ]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
156 |
] ifFalse:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
157 |
millis := 0. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
158 |
]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
159 |
]. |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
160 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
161 |
"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
|
162 |
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
|
163 |
hour == 24 ifTrue:[ |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
164 |
(min ~~ 0 or:[sec ~~ 0 or:[millis ~~ 0]]) ifTrue:[ Error raiseErrorString:'bad hour' ]. |
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 |
^ 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
|
167 |
|
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
168 |
" |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
169 |
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
|
170 |
(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
|
171 |
(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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
AbsoluteTime basicReadFrom:'foo' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
184 |
AbsoluteTime basicReadFrom:(AbsoluteTime now storeString) |
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
185 |
" |
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
186 |
! |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
187 |
|
4378 | 188 |
day:d month:m year:y hour:h minutes:min seconds:s |
189 |
"This is obsolete. User #year:month:day:hour:minute:second:" |
|
190 |
||
191 |
^ self |
|
4679 | 192 |
year:y month:m day:d hour:h |
193 |
minute:min second:s millisecond:0 |
|
4378 | 194 |
|
195 |
" |
|
196 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
197 |
AbsoluteTime day:8 month:1 year:1995 hour:0 minute:43 second:48 |
|
198 |
" |
|
199 |
||
200 |
"Modified: / 1.7.1996 / 15:22:26 / cg" |
|
201 |
"Modified: / 13.7.1999 / 12:29:56 / stefan" |
|
202 |
! |
|
203 |
||
204 |
day:d month:m year:y hour:h minutes:min seconds:s milliseconds:millis |
|
205 |
"This is obsolete. User #year:month:day:hour:minute:second:millisecond:" |
|
206 |
||
207 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
208 |
||
209 |
" |
|
210 |
AbsoluteTime day:1 month:1 year:1970 hour:1 minute:0 second:0 |
|
211 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 |
|
212 |
AbsoluteTime day:2 month:1 year:1991 hour:12 minute:30 second:0 millisecond:100 |
|
213 |
" |
|
214 |
||
215 |
"Created: / 1.7.1996 / 14:46:09 / cg" |
|
216 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
217 |
"Modified: / 13.7.1999 / 12:30:26 / stefan" |
|
275 | 218 |
! |
219 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
220 |
decodeFromLiteralArray:anArray |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
221 |
"decode an AbsoluteTime literalArray. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
222 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
223 |
anArray may be: |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
224 |
#(AbsoluteTime '200004182000.123') |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
225 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
226 |
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
|
227 |
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
|
228 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
229 |
#(AbsoluteTime #osTime: 12345678) |
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 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
232 |
(anArray at:2) == #osTime: ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
233 |
^ self new osTime:(anArray at:3). |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
234 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
235 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
236 |
^ 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
|
237 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
238 |
|
423 | 239 |
fromDate:aDate andTime:aTime |
240 |
"return an instance of the receiver, initialized from a time and a date |
|
1228 | 241 |
object. |
242 |
See also `AbsoluteTime now' and other protocol inherited |
|
243 |
from my superclass." |
|
423 | 244 |
|
245 |
^ self |
|
4679 | 246 |
year:aDate year |
247 |
month:aDate month |
|
248 |
day:aDate day |
|
249 |
hour:aTime hours |
|
250 |
minute:aTime minutes |
|
251 |
second:aTime seconds |
|
423 | 252 |
|
253 |
" |
|
1228 | 254 |
AbsoluteTime fromDate:(Date today) andTime:(Time now) |
255 |
AbsoluteTime fromDate:(Date today plusDays:1) andTime:(Time now) |
|
256 |
AbsoluteTime now |
|
423 | 257 |
" |
258 |
||
4378 | 259 |
"Modified: / 8.9.1995 / 15:07:30 / claus" |
260 |
"Modified: / 19.4.1996 / 15:25:46 / cg" |
|
261 |
"Modified: / 13.7.1999 / 12:30:47 / stefan" |
|
423 | 262 |
! |
263 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
264 |
newDay:dayInYear year:year |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
265 |
"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
|
266 |
Date protocol compatibility" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
267 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
268 |
^ (Date newDay:dayInYear year:year) asAbsoluteTime |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
269 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
270 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
271 |
AbsoluteTime newDay:183 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
272 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
273 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
274 |
"Modified: 2.7.1996 / 09:39:30 / cg" |
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 |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
277 |
readFrom:aStringOrStream onError:exceptionBlock |
275 | 278 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
279 |
The string is interpreted as 24 hour format, as printed. |
|
280 |
Notice, that this is not the storeString format and |
|
4898 | 281 |
is different from the format expected by readFrom:. |
282 |
The format read here is dd-mm-yyyy hh:mm:ss.iii" |
|
275 | 283 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
284 |
|newTime| |
275 | 285 |
|
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
286 |
ErrorSignal handle:[:ex | |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
287 |
^ 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
|
288 |
] do:[ |
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
289 |
newTime := self basicReadFrom:aStringOrStream. |
275 | 290 |
]. |
3995
777470826394
no need for another error-handler blcok in #readFrom:onError:
Claus Gittinger <cg@exept.de>
parents:
3510
diff
changeset
|
291 |
^ newTime |
275 | 292 |
|
293 |
" |
|
5376
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
294 |
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
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
AbsoluteTime readFrom:'20-2-1995 24:00:01.100' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
302 |
AbsoluteTime readFrom:'foo' onError:'wrong' |
c2ef7d5e25ca
oops - was not able to reread my own storeString.
Claus Gittinger <cg@exept.de>
parents:
5292
diff
changeset
|
303 |
AbsoluteTime readFrom:(AbsoluteTime now storeString) onError:'wrong' |
275 | 304 |
" |
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
305 |
|
4378 | 306 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
307 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
|
2311 | 308 |
! |
309 |
||
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
310 |
readGeneralizedFrom:aStringOrStream onError:exceptionBlock |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
311 |
"return a new AbsoluteTime, reading a printed representation from aStream. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
312 |
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
|
313 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
314 |
Notice, that this is not the storeString format and |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
315 |
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
|
316 |
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
|
317 |
which is the ASN1 GeneralizedTime format." |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
318 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
319 |
|newTime| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
320 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
321 |
ErrorSignal handle:[:ex | |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
322 |
^ exceptionBlock value |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
323 |
] do:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
324 |
|str day month year hour min sec millis c| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
325 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
326 |
sec := millis := 0. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
327 |
str := aStringOrStream readStream. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
328 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
329 |
year := Integer readFrom:(str next:4). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
330 |
month := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
331 |
(month between:1 and:12) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
332 |
day := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
333 |
(day between:1 and:31) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
334 |
hour:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
335 |
(hour between:0 and:24) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
336 |
min:= Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
337 |
(min between:0 and:59) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
338 |
str atEnd ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
339 |
sec := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
340 |
(sec between:0 and:59) ifFalse:[^ exceptionBlock value]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
341 |
str peek == $. ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
342 |
str next. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
343 |
millis := Integer readFrom:str. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
344 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
345 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
346 |
str atEnd ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
347 |
"/ this is local time |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
348 |
newTime := self year:year month:month day:day |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
349 |
hour:hour minute:min second:sec millisecond:millis. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
350 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
351 |
c := str next. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
352 |
c ~~ $Z ifTrue:[ |tzh tzmin| |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
353 |
tzh := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
354 |
tzmin := Integer readFrom:(str next:2). |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
355 |
c == $+ ifTrue:[ |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
356 |
"/ add hours and minutes |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
357 |
hour := hour + tzh. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
358 |
min := min + tzmin. |
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
359 |
] ifFalse:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
360 |
c ~~ $- ifTrue:[ |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
361 |
self error:'bad time offset'. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
362 |
]. |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
363 |
"/ subtract 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 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
367 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
368 |
"/ this is UTC time |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
369 |
newTime := self UTCYear:year month:month day:day |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
370 |
hour:hour minute:min second:sec millisecond:millis. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
371 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
372 |
]. |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
373 |
^ newTime |
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 |
" |
5656
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
376 |
|s| |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
377 |
s := '' writeStream. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
378 |
AbsoluteTime now printGeneralizedOn:s. |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
379 |
AbsoluteTime readGeneralizedFrom:s contents onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
380 |
|
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
381 |
AbsoluteTime readGeneralizedFrom:'20001018000000+0200' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
382 |
AbsoluteTime readGeneralizedFrom:'20001018000000+0300' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
383 |
|
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
384 |
AbsoluteTime readGeneralizedFrom:'20000202000000+0100' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
385 |
AbsoluteTime readGeneralizedFrom:'20000202000000+0200' onError:[] |
dbc52ea02716
Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents:
5572
diff
changeset
|
386 |
|
5292
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
387 |
AbsoluteTime readGeneralizedFrom:'19950220131106' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
388 |
AbsoluteTime readGeneralizedFrom:'199502201311' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
389 |
AbsoluteTime readGeneralizedFrom:'19950220131106.100' onError:[] |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
390 |
AbsoluteTime readGeneralizedFrom:'19950232131106.100' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
391 |
AbsoluteTime readGeneralizedFrom:'19950fo2131106.100' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
392 |
AbsoluteTime readGeneralizedFrom:'foo' onError:'wrong' |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
393 |
" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
394 |
|
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
395 |
"Modified: / 8.10.1996 / 19:25:59 / cg" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
396 |
"Modified: / 13.7.1999 / 12:31:14 / stefan" |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
397 |
! |
a3936f79327b
Fix #readGeneralizedFrom:onError:
Stefan Vogel <sv@exept.de>
parents:
5291
diff
changeset
|
398 |
|
2311 | 399 |
secondsSince1970:sec |
400 |
"set time from elapsed seconds since 1-1-1970, 0:0:0. |
|
401 |
This is the format used in the UNIX world" |
|
402 |
||
4378 | 403 |
^ self year:1970 month:1 day:1 hour:0 minute:0 second:sec. |
404 |
||
405 |
" |
|
4679 | 406 |
AbsoluteTime secondsSince1970:0 |
407 |
AbsoluteTime secondsSince1970:3600 |
|
4378 | 408 |
" |
409 |
||
410 |
"Created: / 21.10.1996 / 17:48:30 / stefan" |
|
411 |
"Modified: / 13.7.1999 / 12:31:22 / stefan" |
|
412 |
! |
|
413 |
||
414 |
year:y month:m day:d hour:h minute:min second:s |
|
415 |
"return an instance of the receiver, given individual components. |
|
416 |
See also `AbsoluteTime now' and other protocol inherited |
|
417 |
from my superclass." |
|
418 |
||
419 |
^ self year:y month:m day:d hour:h minute:min second:s millisecond:0 |
|
2311 | 420 |
|
421 |
" |
|
4378 | 422 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 second:0 |
423 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
424 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
425 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minutes:0 second:0 |
|
2311 | 426 |
" |
427 |
||
4378 | 428 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
429 |
"Created: / 13.7.1999 / 12:06:39 / stefan" |
|
430 |
"Modified: / 13.7.1999 / 12:27:47 / stefan" |
|
431 |
! |
|
432 |
||
433 |
year:y month:m day:d hour:h minute:min second:s millisecond:millis |
|
434 |
"return an instance of the receiver, given individual components. |
|
435 |
See also `AbsoluteTime now' and other protocol inherited |
|
436 |
from my superclass." |
|
437 |
||
438 |
^ self basicNew |
|
4679 | 439 |
fromOSTime:(OperatingSystem |
440 |
computeOSTimeFromYear:y month:m day:d |
|
441 |
hour:h minute:min seconds:s millis:millis) |
|
4378 | 442 |
|
443 |
" |
|
444 |
AbsoluteTime year:1970 month:1 day:1 hour:1 minute:0 seconds:0 |
|
445 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 |
|
446 |
AbsoluteTime year:1991 month:1 day:2 hour:12 minute:30 second:0 millisecond:100 |
|
447 |
AbsoluteTime year:2000 month:1 day:1 hour:1 minute:0 second:0 |
|
448 |
" |
|
449 |
||
450 |
"Modified: / 1.7.1996 / 15:22:07 / cg" |
|
451 |
"Created: / 13.7.1999 / 12:28:44 / stefan" |
|
452 |
"Modified: / 13.7.1999 / 12:37:57 / stefan" |
|
241 | 453 |
! ! |
30 | 454 |
|
455 |
!AbsoluteTime methodsFor:'accessing'! |
|
456 |
||
457 |
day |
|
92 | 458 |
"return the day-in-month of the receiver (1..31). |
275 | 459 |
For compatibility, use instances of Date for this." |
30 | 460 |
|
241 | 461 |
|d| |
462 |
||
275 | 463 |
OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
3120 | 464 |
d := day |
241 | 465 |
]. |
466 |
^ d |
|
54 | 467 |
|
92 | 468 |
" |
241 | 469 |
AbsoluteTime now day |
92 | 470 |
" |
1501 | 471 |
|
472 |
"Modified: 1.7.1996 / 15:23:02 / cg" |
|
473 |
! |
|
474 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
475 |
dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
476 |
"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
|
477 |
|
3120 | 478 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:11 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
479 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
480 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
481 |
AbsoluteTime now dayInWeek |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
482 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
483 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
484 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
485 |
"Created: 2.7.1996 / 09:35:48 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
486 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
487 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
488 |
dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
489 |
"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
|
490 |
|
3120 | 491 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:10 |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
492 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
493 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
494 |
AbsoluteTime now dayInYear |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
495 |
AbsoluteTime newDay:184 year:1996 |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
496 |
" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
497 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
498 |
"Modified: 2.7.1996 / 10:21:02 / cg" |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
499 |
! |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
500 |
|
1501 | 501 |
hour |
502 |
"return the hour (0..23). |
|
503 |
ST-80 Timestamp compatibility (I'd prefer the name #hours, for Time compatibility)." |
|
504 |
||
505 |
^ self hours |
|
506 |
||
507 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
508 |
"Modified: 1.7.1996 / 15:15:32 / cg" |
|
30 | 509 |
! |
510 |
||
241 | 511 |
hours |
512 |
"return the hours (0..23)" |
|
513 |
||
514 |
|hr| |
|
515 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
516 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 517 |
hr := hours |
241 | 518 |
]. |
519 |
^ hr |
|
54 | 520 |
|
92 | 521 |
" |
241 | 522 |
AbsoluteTime now hours |
523 |
" |
|
524 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
525 |
"Modified: 2.7.1996 / 09:20:32 / cg" |
1501 | 526 |
! |
527 |
||
528 |
millisecond |
|
529 |
"return the millisecond (0..999). |
|
530 |
ST-80 Timestamp compatibility (I'd prefer the name #milliseconds)." |
|
531 |
||
532 |
^ self milliseconds |
|
533 |
||
534 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
535 |
"Modified: 1.7.1996 / 15:15:24 / cg" |
|
536 |
! |
|
537 |
||
538 |
milliseconds |
|
539 |
"return the milliseconds (0..999)" |
|
540 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
541 |
|m| |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
542 |
|
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
543 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 544 |
m := millis |
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
545 |
]. |
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
546 |
^ m |
1501 | 547 |
|
548 |
" |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
549 |
AbsoluteTime now milliseconds |
1501 | 550 |
" |
551 |
||
552 |
"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
|
553 |
"Modified: 2.7.1996 / 09:21:41 / cg" |
1501 | 554 |
! |
555 |
||
556 |
minute |
|
557 |
"return the minute (0..59). |
|
558 |
ST-80 Timestamp compatibility (I'd prefer the name #minutes, for Time compatibility)." |
|
559 |
||
560 |
^ self minutes |
|
561 |
||
562 |
"Created: 1.7.1996 / 15:14:29 / cg" |
|
563 |
"Modified: 1.7.1996 / 15:15:37 / cg" |
|
241 | 564 |
! |
565 |
||
566 |
minutes |
|
567 |
"return the minutes (0..59)" |
|
568 |
||
569 |
|m| |
|
570 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
571 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 572 |
m := minutes |
241 | 573 |
]. |
574 |
^ m |
|
575 |
||
576 |
" |
|
577 |
AbsoluteTime now minutes |
|
92 | 578 |
" |
241 | 579 |
|
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
580 |
"Modified: 2.7.1996 / 09:20:49 / cg" |
241 | 581 |
! |
582 |
||
699 | 583 |
month |
584 |
"return the month of the receiver (1..12). |
|
585 |
For compatibility, use instances of Date for this." |
|
586 |
||
587 |
|m| |
|
588 |
||
589 |
OperatingSystem computeDatePartsOf:osTime for:[ :year :month :day | |
|
3120 | 590 |
m := month |
699 | 591 |
]. |
592 |
^ m |
|
593 |
||
594 |
" |
|
595 |
AbsoluteTime now month |
|
596 |
" |
|
1501 | 597 |
|
598 |
"Modified: 1.7.1996 / 15:23:05 / cg" |
|
599 |
! |
|
600 |
||
4807 | 601 |
osTime:aTime |
5726 | 602 |
"set the internal representation of the time" |
603 |
||
4807 | 604 |
osTime := aTime. |
605 |
! |
|
606 |
||
1501 | 607 |
second |
608 |
"return the second (0..59). |
|
609 |
ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)." |
|
610 |
||
611 |
^ self seconds |
|
612 |
||
613 |
"Created: 1.7.1996 / 15:14:19 / cg" |
|
614 |
"Modified: 1.7.1996 / 15:15:49 / cg" |
|
699 | 615 |
! |
616 |
||
241 | 617 |
seconds |
618 |
"return the seconds (0..59)" |
|
619 |
||
620 |
|s| |
|
621 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
622 |
OperatingSystem computeTimePartsOf:osTime for:[:hours :minutes :secs :millis | |
3120 | 623 |
s := secs |
241 | 624 |
]. |
625 |
^ s |
|
626 |
||
627 |
" |
|
628 |
AbsoluteTime now seconds |
|
629 |
" |
|
630 |
||
1513
a4b4c4ce039c
added dayInYear & dayInWeek for Date compatibility
Claus Gittinger <cg@exept.de>
parents:
1501
diff
changeset
|
631 |
"Modified: 2.7.1996 / 09:20:54 / cg" |
92 | 632 |
! |
633 |
||
799 | 634 |
utcOffset |
635 |
"return the difference between UTC (Greenwich Mean Time) and the local time |
|
636 |
if daylight saving time applies to ourself, take that into account. |
|
637 |
Add utcOffset bevor converting to get UTC-Time resp. UTC-Date. |
|
638 |
" |
|
639 |
||
640 |
^ (OperatingSystem computeTimeAndDateFrom:osTime) at:7 |
|
641 |
||
642 |
" |
|
643 |
AbsoluteTime now utcOffset |
|
644 |
(AbsoluteTime day:1 month:7 year:1995 hour:12 minutes:0 seconds:0) utcOffset |
|
645 |
" |
|
646 |
||
647 |
"Modified: 20.12.1995 / 17:28:49 / stefan" |
|
1501 | 648 |
"Modified: 1.7.1996 / 15:21:29 / cg" |
799 | 649 |
! |
650 |
||
699 | 651 |
year |
652 |
"return the year of the receiver i.e. 1992. |
|
653 |
For compatibility, use instances of Date for this." |
|
241 | 654 |
|
699 | 655 |
|y| |
241 | 656 |
|
699 | 657 |
OperatingSystem computeDatePartsOf:osTime for:[:year :month :day | |
3120 | 658 |
y := year |
699 | 659 |
]. |
660 |
^ y |
|
241 | 661 |
|
662 |
" |
|
699 | 663 |
AbsoluteTime now year |
241 | 664 |
" |
1501 | 665 |
|
666 |
"Modified: 1.7.1996 / 15:23:08 / cg" |
|
241 | 667 |
! ! |
668 |
||
30 | 669 |
!AbsoluteTime methodsFor:'arithmetic'! |
670 |
||
242 | 671 |
addDays:numberOfDays |
672 |
"return a new instance of myself, numberOfDays afterwards." |
|
673 |
||
674 |
^ self addSeconds:(numberOfDays * (60 * 60 * 24)) |
|
675 |
||
676 |
" |
|
677 |
|t| |
|
678 |
||
679 |
t := AbsoluteTime now. |
|
680 |
t printNL. |
|
681 |
(t addDays:7) printNL |
|
682 |
" |
|
683 |
! |
|
684 |
||
3122 | 685 |
addMilliseconds:nMillis |
686 |
"return a new absoluteTime instance, nMillis milliseconds after myself" |
|
687 |
||
688 |
^ (self class basicNew) setMilliseconds:(self getMilliseconds + nMillis) |
|
689 |
||
690 |
" |
|
691 |
|t1 t2| |
|
692 |
||
693 |
t1 := AbsoluteTime now. |
|
694 |
t2 := t1 addMilliseconds:10. |
|
695 |
Transcript showCR:t1. |
|
696 |
Transcript showCR:t2. |
|
697 |
" |
|
698 |
||
699 |
"Modified: / 2.12.1997 / 17:10:39 / cg" |
|
700 |
! |
|
701 |
||
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
702 |
millisecondDeltaFrom:anAbsoluteTime |
3510 | 703 |
"return the delta in milliseconds between 2 absolute times. |
704 |
The argument is supposed to be AFTER the receiver" |
|
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
705 |
|
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
706 |
^ self getMilliseconds - (anAbsoluteTime getMilliseconds) |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
707 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
708 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
709 |
|t1 t2| |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
710 |
|
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
711 |
t1 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
712 |
Delay waitForSeconds:0.5. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
713 |
t2 := AbsoluteTime now. |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
714 |
t2 millisecondDeltaFrom:t1 |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
715 |
" |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
716 |
|
3510 | 717 |
"Modified: / 5.6.1998 / 04:21:33 / cg" |
2623
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
718 |
! |
593ab389efd1
added #millisecondDeltaFrom:
Claus Gittinger <cg@exept.de>
parents:
2311
diff
changeset
|
719 |
|
242 | 720 |
subtractDays:numberOfDays |
721 |
"return a new instance of myself, numberOfDays before." |
|
722 |
||
723 |
^ self subtractSeconds:(numberOfDays * (60 * 60 * 24)) |
|
724 |
||
725 |
" |
|
726 |
|t| |
|
727 |
||
728 |
t := AbsoluteTime now. |
|
729 |
t printNL. |
|
730 |
(t subtractDays:50) printNL |
|
731 |
" |
|
30 | 732 |
! ! |
733 |
||
699 | 734 |
!AbsoluteTime methodsFor:'comparing'! |
735 |
||
736 |
= aTime |
|
737 |
"return true if the argument, aTime represents the same time" |
|
738 |
||
739 |
(aTime species == self species) ifFalse:[^ false]. |
|
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
740 |
^ (self getMilliseconds = aTime getMilliseconds) |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
741 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
742 |
"Modified: 3.7.1996 / 13:10:24 / cg" |
699 | 743 |
! |
744 |
||
745 |
hash |
|
746 |
"return an integer useful for hashing on times" |
|
747 |
||
1520
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
748 |
^ osTime // 1000 |
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
749 |
|
da08f8e49e87
fixed comparing absoluteTimes
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
750 |
"Modified: 3.7.1996 / 13:10:52 / cg" |
699 | 751 |
! ! |
752 |
||
753 |
!AbsoluteTime methodsFor:'converting'! |
|
754 |
||
755 |
asAbsoluteTime |
|
756 |
"return an AbsoluteTime object from the receiver - thats the receiver." |
|
757 |
||
758 |
^ self |
|
759 |
! |
|
760 |
||
761 |
asDate |
|
762 |
"return a Date object from the receiver. |
|
763 |
The returned date will only represent the day - not the timeOfDay." |
|
764 |
||
765 |
^ Date fromOSTime:osTime |
|
766 |
||
767 |
" |
|
768 |
AbsoluteTime now |
|
769 |
AbsoluteTime now asDate |
|
770 |
(AbsoluteTime now addTime:3600) asDate |
|
771 |
(AbsoluteTime now addTime:3600) asTime |
|
772 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
773 |
(AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600)) asDate |
|
774 |
" |
|
775 |
||
776 |
! |
|
777 |
||
778 |
asSeconds |
|
779 |
"return the number of seconds elapsed since whatever time the |
|
780 |
OperatingSystem bases its time upon. Since this is totally |
|
781 |
OS-dependent, do not interpret the value returned by this method. |
|
782 |
You can use it to add/subtract seconds or get time deltas, though." |
|
783 |
||
784 |
^ self getSeconds |
|
785 |
||
786 |
" |
|
787 |
AbsoluteTime now asSeconds |
|
788 |
AbsoluteTime fromSeconds:(AbsoluteTime now asSeconds + 3600) |
|
789 |
Time hour:23 minutes:33 seconds:0 |
|
790 |
Time fromSeconds:((Time hour:23 minutes:33 seconds:0) asSeconds + 3600) |
|
791 |
" |
|
792 |
! |
|
793 |
||
794 |
asTime |
|
795 |
"return a Time object from the receiver. |
|
796 |
The returned time will only represent the timeOfDay - not the day." |
|
797 |
||
798 |
^ Time fromOSTime:osTime |
|
799 |
||
800 |
" |
|
801 |
AbsoluteTime now |
|
802 |
AbsoluteTime now asTime |
|
803 |
(AbsoluteTime now addTime:3600) asTime |
|
804 |
" |
|
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
805 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
806 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
807 |
literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
808 |
"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
|
809 |
can be reconstructed with #decodeAsLiteralArray. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
810 |
The encoding is: |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
811 |
(#AbsoluteTime YYYYMMDDhhmmss.iii) |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
812 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
813 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
814 |
|s| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
815 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
816 |
s := '' writeStream. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
817 |
self printGeneralizedOn:s isLocal:true. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
818 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
819 |
^ Array |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
820 |
with:self class name asSymbol |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
821 |
with:s contents |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
822 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
823 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
824 |
AbsoluteTime now literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
825 |
AbsoluteTime decodeFromLiteralArray:AbsoluteTime now literalArrayEncoding |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
826 |
" |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
827 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
828 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
829 |
|
699 | 830 |
! ! |
831 |
||
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
832 |
!AbsoluteTime methodsFor:'encoding'! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
833 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
834 |
encodeOn:anEncoder with:aParameter |
5726 | 835 |
"encoder visitor support" |
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
836 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
837 |
anEncoder encodeAbsoluteTime:self with:aParameter |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
838 |
! ! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5390
diff
changeset
|
839 |
|
213 | 840 |
!AbsoluteTime methodsFor:'printing & storing'! |
30 | 841 |
|
4843 | 842 |
addPrintBindingsTo:dict |
5726 | 843 |
"private print support" |
844 |
||
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
845 |
|d m y s| |
4843 | 846 |
|
847 |
OperatingSystem computeDatePartsOf:osTime for:[ |
|
848 |
:year :month :day | d := day. m := month. y := year. |
|
849 |
]. |
|
850 |
super addPrintBindingsTo:dict. |
|
851 |
dict at:#day put:(d printString leftPaddedTo:2 with:$0). |
|
852 |
dict at:#dayInWeek put:(self dayInWeek). |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
853 |
dict at:#month put:(s := m printString leftPaddedTo:2 with:$0). |
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
854 |
dict at:#mon put:s. "/ for backward compatibility only |
4843 | 855 |
dict at:#year put:(y printString leftPaddedTo:4 with:$0). |
856 |
||
857 |
dict at:#Day put:d printString. |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
858 |
dict at:#Month put:(s := m printString). |
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
859 |
dict at:#Mon put:s. "/ for backward compatibility only |
4843 | 860 |
|
861 |
" |
|
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
862 |
AbsoluteTime now printOn:Transcript format:'%(day):%(month)'. Transcript cr. |
4843 | 863 |
AbsoluteTime now printOn:Transcript format:'%(dayInWeek)'. Transcript cr. |
4930
edb87412f76d
month vs. mon in formatString
Claus Gittinger <cg@exept.de>
parents:
4906
diff
changeset
|
864 |
AbsoluteTime now printOn:Transcript format:'%(Day)-%(month)-%(year) %h:%m:%s.%i'. Transcript cr. |
4843 | 865 |
AbsoluteTime now printOn:Transcript. Transcript cr |
866 |
" |
|
867 |
! |
|
868 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
869 |
printGeneralizedOn:aStream |
5290 | 870 |
"append a representation of the receiver to aStream in a general format, |
871 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
|
872 |
This format is used for the ASN.1 GeneralizedTime as defined in X.208 Sec. 33, |
|
873 |
so read this before changing the output format." |
|
874 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
875 |
^ self printGeneralizedOn:aStream isLocal:false. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
876 |
! |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
877 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
878 |
printGeneralizedOn:aStream isLocal:isLocal |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
879 |
"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
|
880 |
top-down, without separtors: 'yyyymmddHHMMSS.mmm+0100' |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
881 |
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
|
882 |
so read this before changing the output format. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
883 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
884 |
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
|
885 |
|
5290 | 886 |
|t off| |
887 |
||
888 |
t := OperatingSystem computeTimeAndDateFrom:osTime. |
|
889 |
||
890 |
(t at:1) printOn:aStream leftPaddedTo:4 with:$0. |
|
891 |
(t at:2) printOn:aStream leftPaddedTo:2 with:$0. |
|
892 |
(t at:3) printOn:aStream leftPaddedTo:2 with:$0. |
|
893 |
(t at:4) printOn:aStream leftPaddedTo:2 with:$0. |
|
894 |
(t at:5) printOn:aStream leftPaddedTo:2 with:$0. |
|
895 |
(t at:6) printOn:aStream leftPaddedTo:2 with:$0. |
|
896 |
aStream nextPut:$.. |
|
897 |
(t at:9) printOn:aStream leftPaddedTo:3 with:$0. |
|
898 |
||
5379
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
899 |
isLocal ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
900 |
"/ this should be printed as non-local-time |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
901 |
|
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
902 |
off := t at:7. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
903 |
off == 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
904 |
aStream nextPut:$Z. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
905 |
] ifFalse:[ |min| |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
906 |
off < 0 ifTrue:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
907 |
aStream nextPut:$+. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
908 |
off := off negated. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
909 |
] ifFalse:[ |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
910 |
aStream nextPut:$-. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
911 |
]. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
912 |
min := off // 60. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
913 |
min // 60 printOn:aStream leftPaddedTo:2 with:$0. |
2cf681402817
Make literal array encoding architecture independent.
Stefan Vogel <sv@exept.de>
parents:
5376
diff
changeset
|
914 |
min \\ 60 printOn:aStream leftPaddedTo:2 with:$0. |
5290 | 915 |
]. |
916 |
]. |
|
917 |
||
918 |
||
919 |
" |
|
5291 | 920 |
AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. |
921 |
(AbsoluteTime fromSeconds:0) printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 922 |
Time now printOn:Transcript. Transcript cr. |
923 |
Date today printOn:Transcript. Transcript cr. |
|
924 |
||
5291 | 925 |
Time now asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr. |
926 |
AbsoluteTime now printGeneralizedOn:Transcript. Transcript cr. |
|
5290 | 927 |
|
5291 | 928 |
Date today asAbsoluteTime printGeneralizedOn:Transcript. Transcript cr. |
5290 | 929 |
Date today printOn:Transcript. Transcript cr. |
930 |
" |
|
931 |
||
932 |
"Modified: / 1.7.1996 / 15:20:59 / cg" |
|
933 |
"Modified: / 17.1.2000 / 15:53:02 / stefan" |
|
934 |
! |
|
935 |
||
241 | 936 |
printOn:aStream |
275 | 937 |
"append a user readable representation of the receiver to aStream. |
938 |
The format is compatible with readFromString:, but not with readFrom:." |
|
939 |
||
4843 | 940 |
self printOn:aStream format:'%(Day)-%(mon)-%(year) %h:%m:%s.%i' |
5678 | 941 |
"/ self printOn:aStream format:'%(mon)/%(Day)/%(year) %h:%m:%s.%i' |
92 | 942 |
|
943 |
" |
|
275 | 944 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
945 |
(AbsoluteTime fromSeconds:0) printOn:Transcript. Transcript cr. |
|
946 |
Time now printOn:Transcript. Transcript cr. |
|
947 |
Date today printOn:Transcript. Transcript cr. |
|
1501 | 948 |
|
949 |
Time now asAbsoluteTime printOn:Transcript. Transcript cr. |
|
950 |
AbsoluteTime now printOn:Transcript. Transcript cr. |
|
951 |
||
952 |
Date today asAbsoluteTime printOn:Transcript. Transcript cr. |
|
953 |
Date today printOn:Transcript. Transcript cr. |
|
92 | 954 |
" |
1501 | 955 |
|
5719
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
956 |
"Modified: 1.7.1996 / 15:20:59 / cg" |
cf09067dbd1d
can do millisecondDelta easier
Claus Gittinger <cg@exept.de>
parents:
5678
diff
changeset
|
957 |
! |
30 | 958 |
|
241 | 959 |
storeOn:aStream |
275 | 960 |
"store the receiver in a format suitable for reconstruction of the |
961 |
receiver via readFrom:" |
|
962 |
||
241 | 963 |
aStream nextPut:$(; |
242 | 964 |
nextPutAll:self class name; |
275 | 965 |
nextPutAll:' new setSeconds:'. |
966 |
self getSeconds storeOn:aStream. |
|
241 | 967 |
aStream nextPut:$). |
54 | 968 |
|
241 | 969 |
" |
275 | 970 |
AbsoluteTime now storeString |
30 | 971 |
|
275 | 972 |
AbsoluteTime readFrom:(AbsoluteTime now storeString) readStream |
241 | 973 |
" |
30 | 974 |
! ! |
699 | 975 |
|
976 |
!AbsoluteTime methodsFor:'private'! |
|
977 |
||
1501 | 978 |
fromOSTime:anUninterpretedOSTime |
699 | 979 |
"strictly private: set the seconds from an OS time (since whatever)" |
980 |
||
1501 | 981 |
osTime := anUninterpretedOSTime |
982 |
||
983 |
"Created: 1.7.1996 / 14:33:21 / cg" |
|
984 |
! |
|
985 |
||
986 |
getMilliseconds |
|
987 |
"strictly private: return the milliseconds (since whatever)" |
|
988 |
||
989 |
^ osTime |
|
990 |
||
991 |
"Created: 1.7.1996 / 14:33:56 / cg" |
|
699 | 992 |
! |
993 |
||
994 |
getSeconds |
|
995 |
"strictly private: return the seconds (since whatever)" |
|
996 |
||
1501 | 997 |
^ osTime // 1000 |
998 |
||
999 |
"Modified: 1.7.1996 / 14:33:44 / cg" |
|
699 | 1000 |
! |
1001 |
||
1501 | 1002 |
setMilliseconds:millis |
1003 |
"strictly private: set the milliseconds (since whatever)" |
|
1004 |
||
1005 |
osTime := millis. |
|
1006 |
||
1007 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1008 |
"Created: 1.7.1996 / 14:34:24 / cg" |
|
1009 |
! |
|
1010 |
||
699 | 1011 |
setSeconds:secs |
1012 |
"strictly private: set the seconds (since whatever)" |
|
1013 |
||
1501 | 1014 |
osTime := secs * 1000. |
795 | 1015 |
|
1016 |
"Modified: 20.12.1995 / 11:46:36 / stefan" |
|
1501 | 1017 |
"Modified: 1.7.1996 / 14:34:10 / cg" |
699 | 1018 |
! ! |
1019 |
||
2311 | 1020 |
!AbsoluteTime class methodsFor:'documentation'! |
699 | 1021 |
|
1022 |
version |
|
5726 | 1023 |
^ '$Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.59 2000-11-22 13:01:03 cg Exp $' |
699 | 1024 |
! ! |