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