author | Claus Gittinger <cg@exept.de> |
Sun, 03 May 2020 13:20:12 +0200 | |
changeset 25379 | 609d492f29a7 |
parent 25315 | 8227a9ce831d |
permissions | -rw-r--r-- |
25315 | 1 |
"{ Encoding: utf8 }" |
2 |
||
240 | 3 |
" |
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
7010 | 5 |
All Rights Reserved |
240 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5548 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17400 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
240 | 18 |
Magnitude subclass:#AbstractTime |
7258 | 19 |
instanceVariableNames:'' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
7672 | 22 |
category:'Magnitude-Time' |
240 | 23 |
! |
24 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
25 |
!AbstractTime class methodsFor:'documentation'! |
240 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
7010 | 30 |
All Rights Reserved |
240 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
43 |
This is an abstract class providing common protocol for Time (time in day) |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
44 |
and Timestamp (time plus day). |
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
45 |
There are no instances of this class in the system. |
275 | 46 |
It is meant as a home for methods common to time handling classes. |
1282 | 47 |
|
1295 | 48 |
[author:] |
49 |
Claus Gittinger |
|
50 |
||
1282 | 51 |
[See also:] |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
52 |
Time Date Timestamp |
1282 | 53 |
Delay ProcessorScheduler |
240 | 54 |
" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
55 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
56 |
|
21325 | 57 |
iso8601FormatDocumentation |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
58 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
59 |
Abstract |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
60 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
61 |
This document defines a profile of ISO 8601, the International Standard for the representation of dates and times. ISO |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
62 |
8601 describes a large number of date/time formats. To reduce the scope for error and the complexity of software, it is |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
63 |
useful to restrict the supported formats to a small number. This profile defines a few date/time formats, likely to satisfy |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
64 |
most requirements. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
65 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
66 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
67 |
Formats |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
68 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
69 |
Different standards may need different levels of granularity in the date and time, so this profile defines six levels. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
70 |
Standards that reference this profile should specify one or more of these granularities. If a given standard allows more |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
71 |
than one granularity, it should specify the meaning of the dates and times with reduced precision, for example, the result |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
72 |
of comparing two dates with different precisions. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
73 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
74 |
The formats are as follows. Exactly the components shown here must be present, with exactly this punctuation. Note |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
75 |
that the 'T' appears literally in the string, to indicate the beginning of the time element, as specified in ISO 8601. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
76 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
77 |
Year: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
78 |
YYYY (eg 1997) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
79 |
Year and month: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
80 |
YYYY-MM (eg 1997-07) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
81 |
Complete date: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
82 |
YYYY-MM-DD (eg 1997-07-16) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
83 |
Complete date plus hours and minutes: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
84 |
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
85 |
Complete date plus hours, minutes and seconds: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
86 |
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
87 |
Complete date plus hours, minutes, seconds and a decimal fraction of a |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
88 |
second |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
89 |
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
90 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
91 |
where: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
92 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
93 |
YYYY = four-digit year |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
94 |
MM = two-digit month (01=January, etc.) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
95 |
DD = two-digit day of month (01 through 31) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
96 |
hh = two digits of hour (00 through 23) (am/pm NOT allowed) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
97 |
mm = two digits of minute (00 through 59) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
98 |
ss = two digits of second (00 through 59) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
99 |
s = one or more digits representing a decimal fraction of a second |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
100 |
TZD = time zone designator (Z or +hh:mm or -hh:mm) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
101 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
102 |
This profile does not specify how many digits may be used to represent the decimal fraction of a second. An adopting |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
103 |
standard that permits fractions of a second must specify both the minimum number of digits (a number greater than or |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
104 |
equal to one) and the maximum number of digits (the maximum may be stated to be 'unlimited'). |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
105 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
106 |
This profile defines two ways of handling time zone offsets: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
107 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
108 |
1.Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator ('Z'). |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
109 |
2.Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
110 |
'+hh:mm' indicates that the date/time uses a local time zone which is 'hh' hours and 'mm' minutes ahead of |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
111 |
UTC. A time zone offset of '-hh:mm' indicates that the date/time uses a local time zone which is 'hh' hours and |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
112 |
'mm' minutes behind UTC. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
113 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
114 |
A standard referencing this profile should permit one or both of these ways of handling time zone offsets. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
115 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
116 |
The ISO8601 printString are generated with: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
117 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
118 |
Year: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
119 |
YYYY (eg 1997) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
120 |
Date today printStringFormat:'%(year)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
121 |
Timestamp now printStringFormat:'%(year)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
122 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
123 |
Year and month: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
124 |
YYYY-MM (eg 1997-07) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
125 |
Date today printStringFormat:'%(year)-%(month)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
126 |
Timestamp now printStringFormat:'%(year)-%(month)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
127 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
128 |
Complete date: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
129 |
YYYY-MM-DD (eg 1997-07-16) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
130 |
Date today printStringFormat:'%(year)-%(month)-%(day)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
131 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
132 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
133 |
Complete date plus hours and minutes: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
134 |
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
135 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
136 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
137 |
Complete date plus hours, minutes and seconds: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
138 |
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
139 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
140 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
141 |
Complete date plus hours, minutes, seconds and a decimal fraction of a second |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
142 |
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
143 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
144 |
" |
21325 | 145 |
! |
146 |
||
147 |
printFormatDocumentation |
|
148 |
" |
|
149 |
bindings: |
|
150 |
%h hours, 00..23 (i.e. european) 0-padded to length 2 |
|
151 |
%u hours, 00..12 (i.e. us) 0-padded to length 2 |
|
152 |
%m minutes, 00..59 0-padded to length 2 |
|
153 |
%s seconds, 00..59 0-padded to length 2 |
|
154 |
%i milliseconds, 000..999 0-padded to length 3 |
|
155 |
%a am/pm |
|
156 |
||
157 |
Timestamp only: |
|
158 |
%(day) day, 00..31 0-padded to length 2 |
|
159 |
%(month) month, 00..12 0-padded to length 2 |
|
160 |
%(year) year, 4 digits 0-padded to length 4 |
|
161 |
||
162 |
special: |
|
163 |
%H 24-hours - unpadded |
|
164 |
%U 12-hours - unpadded |
|
165 |
%M minutes - unpadded |
|
166 |
%S seconds - unpadded |
|
167 |
%I milliseconds, unpadded |
|
168 |
%A AM/PM - uppercase |
|
169 |
||
170 |
%t seconds within hour (unpadded) |
|
171 |
%T seconds from midNight (unpadded) |
|
172 |
||
173 |
%(TZD) timeZone delta of the receiver from UTC in the format +/-hh:mm |
|
174 |
||
175 |
%(milli1) milliseconds, truncated to 1/10th of a second 0..9 |
|
176 |
%(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2 |
|
177 |
%(milli3) milliseconds, same as %i for convenience |
|
178 |
||
179 |
Timestamp only: |
|
180 |
%(Day) - day - unpadded |
|
181 |
%(Month) - month - unpadded |
|
182 |
%(yearOrTime) - year or time 5 digits as in unix-ls: |
|
183 |
year if it is not the current year; |
|
184 |
time otherwise |
|
185 |
%(weekDay) - day in week (1->monday, 2->tuesday, ... ,7->sunday) |
|
186 |
||
187 |
%(dayName) - full day name |
|
188 |
%(DayName) - full day name, first character uppercase |
|
189 |
%(DAYNAME) - full day name, all uppercase |
|
190 |
||
191 |
%(monthName) - full month name |
|
192 |
%(MonthName) - full month name, first character uppercase |
|
193 |
%(MONTHNAME) - full month name, all uppercase |
|
194 |
||
195 |
%(shortDayName) - short (abbreviated) day name |
|
196 |
%(ShortDayName) - short (abbreviated) day name, first character uppercase |
|
197 |
%(SHORTDAYNAME) - short (abbreviated) day name, all uppercase |
|
198 |
||
199 |
%(shortMonthName) - short (abbreviated) month name |
|
200 |
%(ShortMonthName) - short (abbreviated) month name, first character uppercase |
|
201 |
%(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase |
|
202 |
||
203 |
%(nth) - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
204 |
%(weekDayNth) - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
205 |
%(weekNth) - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
206 |
||
207 |
%(yearRoman) - year, in roman letters |
|
208 |
%(monthRoman) - month, in roman letters |
|
209 |
||
210 |
||
211 |
The ISO8601 printString are documented in iso8601FormatDocumentation: |
|
212 |
" |
|
240 | 213 |
! ! |
214 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
215 |
!AbstractTime class methodsFor:'instance creation'! |
240 | 216 |
|
699 | 217 |
dateAndTimeNow |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
218 |
"return an array filled with the current date and time. |
16982 | 219 |
As these provide no timezone info, this should be only used for user interface purposes. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
220 |
See also: Date today / Time now / Timestamp now." |
240 | 221 |
|
699 | 222 |
^ Array with:(Date today) with:(Time now) |
240 | 223 |
|
224 |
" |
|
16982 | 225 |
Time dateAndTimeNow |
226 |
Date dateAndTimeNow |
|
240 | 227 |
" |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
228 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
229 |
"Modified: 19.4.1996 / 15:23:37 / cg" |
275 | 230 |
! |
240 | 231 |
|
9432 | 232 |
epoch |
233 |
"answer the time when we start counting" |
|
234 |
||
235 |
^ self new setSeconds:0 |
|
236 |
||
237 |
" |
|
16982 | 238 |
Timestamp epoch |
239 |
Time epoch |
|
9432 | 240 |
" |
241 |
! |
|
242 |
||
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
243 |
now |
19654 | 244 |
"return an instance of myself representing this moment with at least second precision. |
16982 | 245 |
Timestamps will redefine this to always return millisecond precision." |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
246 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
247 |
^ self basicNew fromOSTime:(OperatingSystem getOSTime) |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
248 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
249 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
250 |
Timestamp now |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
251 |
Time now |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
252 |
" |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
253 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
254 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
13233 | 255 |
! |
256 |
||
22626 | 257 |
nowWithMicroseconds |
258 |
"return an instance of myself representing this moment with at least microsecond precision." |
|
259 |
||
260 |
|osTime millis micros| |
|
261 |
||
262 |
osTime := OperatingSystem getOSTimeWithMicros. |
|
263 |
millis := osTime at:1. |
|
264 |
micros := osTime at:2. |
|
22836 | 265 |
^ self basicNew fromOSTimeWithMilliseconds:millis additionalPicoseconds:(micros*(1000*1000)). |
22626 | 266 |
|
267 |
" |
|
268 |
Timestamp now |
|
269 |
Time now |
|
270 |
Timestamp nowWithMilliseconds |
|
22836 | 271 |
Timestamp nowWithMicroseconds |
22626 | 272 |
" |
273 |
||
274 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
275 |
! |
|
276 |
||
16941 | 277 |
nowWithMilliseconds |
22626 | 278 |
"return an instance of myself representing this moment with at least millisecond precision." |
16941 | 279 |
|
280 |
^ self basicNew fromOSTimeWithMilliseconds:(OperatingSystem getOSTime) |
|
281 |
||
282 |
" |
|
22626 | 283 |
Time now |
284 |
Time nowWithMilliseconds |
|
285 |
||
16941 | 286 |
Timestamp now |
22626 | 287 |
Timestamp nowWithMilliseconds |
288 |
Timestamp nowWithMicroseconds |
|
16941 | 289 |
" |
290 |
||
291 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
292 |
! |
|
293 |
||
13233 | 294 |
utcNow |
295 |
"return an instance of myself representing this momentin the UTC timezone." |
|
296 |
||
297 |
^ self subclassResponsibility |
|
298 |
||
299 |
" |
|
300 |
Timestamp utcNow |
|
301 |
Timestamp utcNow |
|
302 |
||
303 |
Time now |
|
304 |
Time utcNow |
|
305 |
" |
|
306 |
||
307 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
308 |
! ! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
309 |
|
7294 | 310 |
!AbstractTime class methodsFor:'Compatibility-Squeak'! |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
311 |
|
9432 | 312 |
dateAndTimeFromSeconds:secondCount |
313 |
"set date and time from seconds since 1901-01-01 00:00 UTC" |
|
314 |
||
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
315 |
|timestamp| |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
316 |
|
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
317 |
" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
318 |
secondsBetween1901and1970 := |
9432 | 319 |
(Timestamp epoch asDate subtractDate:(Date day:1 month:1 year:1901)) |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
320 |
* (24 * 60 * 60) |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
321 |
" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
322 |
|
9432 | 323 |
"stc cannot make large integers" |
9449
6ba774be6aa1
stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents:
9432
diff
changeset
|
324 |
timestamp := Timestamp fromSeconds:secondCount - 2177452800. |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
325 |
^ Array |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
326 |
with: (timestamp asDate) |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
327 |
with: (timestamp asTime) |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
328 |
|
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
329 |
" |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
330 |
Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
331 |
Time dateAndTimeFromSeconds: (Time totalSeconds) |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
332 |
Date dateAndTimeFromSeconds: (Time totalSeconds) |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
333 |
" |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
334 |
! |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
335 |
|
11528 | 336 |
milliseconds:msTime1 since:msTime2 |
337 |
"return the number of milliseconds between two |
|
338 |
millisecond time values, compensating for roll-over. |
|
339 |
The same as millisecondsBetween:and: for Squeak compatibility." |
|
340 |
||
341 |
^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2 |
|
342 |
! |
|
343 |
||
9926 | 344 |
millisecondsSince: lastTime |
345 |
"Answer the elapsed time since last recorded in milliseconds. |
|
346 |
Compensate for rollover." |
|
347 |
||
348 |
^self milliseconds: self millisecondClockValue since: lastTime |
|
349 |
! |
|
350 |
||
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
351 |
primSecondsClock |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
352 |
"returns the number of seconds since 1.1.1901 UTC" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
353 |
|
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
354 |
^ Timestamp now utcSecondsSince1901 |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
355 |
|
20200 | 356 |
" |
357 |
Timestamp primSecondsClock |
|
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
358 |
" |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
359 |
! ! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
360 |
|
7294 | 361 |
!AbstractTime class methodsFor:'Compatibility-VW'! |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
362 |
|
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
363 |
totalSeconds |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
364 |
"returns the number of seconds since 1.1.1901 UTC" |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
365 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
366 |
^ Timestamp now utcSecondsSince1901 |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
367 |
! ! |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
368 |
|
11130 | 369 |
!AbstractTime class methodsFor:'error handling'! |
370 |
||
371 |
conversionErrorSignal |
|
372 |
"return the signal used for conversion error handling" |
|
373 |
||
374 |
^ TimeConversionError |
|
375 |
! ! |
|
376 |
||
13701 | 377 |
!AbstractTime class methodsFor:'format strings'! |
378 |
||
379 |
defaultFormatString |
|
380 |
^ '%h:%m:%s' |
|
381 |
! ! |
|
382 |
||
18454 | 383 |
|
7258 | 384 |
!AbstractTime class methodsFor:'private-instance creation'! |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
385 |
|
275 | 386 |
fromOSTime:osTime |
387 |
"return a time, representing the time given by the operatingSystem time. |
|
388 |
Not meant for public use." |
|
389 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
390 |
^ self basicNew fromOSTime:osTime. |
418 | 391 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
392 |
"Modified: 1.7.1996 / 15:09:54 / cg" |
240 | 393 |
! |
394 |
||
699 | 395 |
fromSeconds:seconds |
396 |
"return an instance that is constructed from seconds. |
|
397 |
This method is only allowed for second values as returned by |
|
20200 | 398 |
getSeconds, possibly adding/subtracting to that. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
399 |
Never depend on any specific interpretation of the seconds, |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
400 |
since it depends on how the OperatingSystem counts time |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
401 |
(some start at 1900, others with 1970 ...)" |
240 | 402 |
|
699 | 403 |
^ self basicNew setSeconds:seconds |
240 | 404 |
|
405 |
" |
|
699 | 406 |
Time fromSeconds:0 should return midnight |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
407 |
Timestamp fromSeconds:0 on UNIX: returns 1st. Jan 1970 |
20789 | 408 |
on others: don't know |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
409 |
(Timestamp day:1 month:1 year:1970 hour:1 minutes:0 seconds:0) |
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
410 |
getSeconds on UNIX: returns 0 |
20200 | 411 |
on others: don't know |
699 | 412 |
" |
413 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
414 |
"Modified: 1.7.1996 / 13:39:30 / cg" |
240 | 415 |
! ! |
416 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
417 |
!AbstractTime class methodsFor:'queries'! |
275 | 418 |
|
18918 | 419 |
isAbstract |
420 |
^ self == AbstractTime |
|
421 |
! |
|
422 |
||
15684 | 423 |
microsecondClockValue |
424 |
"return microseconds seconds of now" |
|
425 |
||
426 |
^ OperatingSystem getMicrosecondTime |
|
427 |
||
428 |
" |
|
429 |
Time microsecondClockValue |
|
430 |
" |
|
431 |
||
432 |
" |
|
433 |
|t1 t2 overhead| |
|
434 |
||
435 |
t1 := Time microsecondClockValue. |
|
436 |
t2 := Time microsecondClockValue. |
|
437 |
overhead := t2 - t1. |
|
438 |
||
439 |
t1 := Time microsecondClockValue. |
|
440 |
100 factorial. |
|
441 |
t2 := Time microsecondClockValue. |
|
442 |
t2 - t1 - overhead |
|
443 |
" |
|
444 |
! |
|
445 |
||
699 | 446 |
millisecondClockValue |
447 |
"return the millisecond clock - since this one overruns |
|
448 |
regularly, use the value only for short timing deltas. |
|
5730 | 449 |
Also remember that it wraps when comparing these values." |
275 | 450 |
|
699 | 451 |
^ OperatingSystem getMillisecondTime. |
452 |
||
453 |
" |
|
454 |
Time millisecondClockValue |
|
455 |
" |
|
275 | 456 |
! |
457 |
||
699 | 458 |
secondClock |
459 |
"return seconds of now - for GNU-ST compatibility" |
|
460 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
461 |
^ OperatingSystem getOSTime // 1000 |
699 | 462 |
|
463 |
" |
|
464 |
AbstractTime secondClock |
|
465 |
" |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
466 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
467 |
"Modified: 1.7.1996 / 15:20:14 / cg" |
699 | 468 |
! ! |
469 |
||
18454 | 470 |
!AbstractTime class methodsFor:'reading'! |
471 |
||
472 |
readFrom:aStringOrStream format:formatString |
|
473 |
"see format description in readFrom:format:language:onError:" |
|
474 |
||
475 |
^ self |
|
476 |
readFrom:aStringOrStream format:formatString language:nil |
|
477 |
onError:[ |
|
19894 | 478 |
self conversionErrorSignal raiseErrorString:' - Timestamp format error' |
18454 | 479 |
]. |
480 |
! |
|
481 |
||
19894 | 482 |
readFrom:aStringOrStream format:formatString language:languageString onError:exceptionalValue |
24423 | 483 |
"see format description in readFrom:format:language:onError:" |
484 |
||
19894 | 485 |
^ self subclassResponsibility |
486 |
! |
|
487 |
||
18454 | 488 |
readFrom:aStringOrStream format:formatString onError:exceptionalValue |
489 |
"see format description in readFrom:format:language:onError:" |
|
490 |
||
491 |
^ self readFrom:aStringOrStream format:formatString language:nil onError:exceptionalValue |
|
492 |
! ! |
|
493 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
494 |
!AbstractTime class methodsFor:'timing evaluations'! |
275 | 495 |
|
12831 | 496 |
microsecondsToRun:aBlock |
16673 | 497 |
"evaluate the argument, aBlock; return the number of microseconds it took" |
12831 | 498 |
|
499 |
|startTime endTime| |
|
500 |
||
501 |
startTime := OperatingSystem getMicrosecondTime. |
|
502 |
aBlock value. |
|
503 |
endTime := OperatingSystem getMicrosecondTime. |
|
504 |
^ endTime - startTime |
|
505 |
||
506 |
" |
|
507 |
Time microsecondsToRun:[1000 factorial] |
|
508 |
" |
|
16673 | 509 |
|
510 |
"Modified (comment): / 01-07-2014 / 15:57:13 / az" |
|
12831 | 511 |
! |
512 |
||
699 | 513 |
millisecondsToRun:aBlock |
514 |
"evaluate the argument, aBlock; return the number of milliseconds it took" |
|
515 |
||
516 |
|startTime endTime| |
|
517 |
||
1476 | 518 |
startTime := OperatingSystem getMillisecondTime. |
699 | 519 |
aBlock value. |
1476 | 520 |
endTime := OperatingSystem getMillisecondTime. |
8586
a38e882affa5
take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents:
8450
diff
changeset
|
521 |
^ self milliseconds:endTime since:startTime |
699 | 522 |
|
523 |
" |
|
8586
a38e882affa5
take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents:
8450
diff
changeset
|
524 |
Time millisecondsToRun:[1000 factorial] |
699 | 525 |
" |
1476 | 526 |
|
527 |
"Modified: 17.6.1996 / 16:57:37 / cg" |
|
275 | 528 |
! |
529 |
||
699 | 530 |
secondsToRun:aBlock |
531 |
"evaluate the argument, aBlock; return the number of seconds it took" |
|
532 |
||
533 |
|startTime endTime| |
|
360 | 534 |
|
699 | 535 |
startTime := self secondClock. |
536 |
aBlock value. |
|
537 |
endTime := self secondClock. |
|
538 |
^ endTime - startTime |
|
275 | 539 |
|
699 | 540 |
" |
541 |
Time secondsToRun:[1000 factorial] |
|
542 |
" |
|
275 | 543 |
! ! |
544 |
||
7261 | 545 |
!AbstractTime methodsFor:'Compatibility-ANSI'! |
6419 | 546 |
|
547 |
hour12 |
|
548 |
"return the hour (1..12)." |
|
549 |
||
550 |
^ self hours - 1 \\ 12 + 1. |
|
551 |
||
552 |
" |
|
553 |
Time now hour12 |
|
554 |
Time now hour24 |
|
555 |
(Time hours:0 minutes:0 seconds:0) hour24 |
|
556 |
(Time hours:0 minutes:0 seconds:0) hour12 |
|
557 |
(Time hours:1 minutes:0 seconds:0) hour24 |
|
558 |
(Time hours:1 minutes:0 seconds:0) hour12 |
|
559 |
(Time hours:12 minutes:0 seconds:0) hour24 |
|
560 |
(Time hours:12 minutes:0 seconds:0) hour12 |
|
561 |
(Time hours:13 minutes:0 seconds:0) hour24 |
|
562 |
(Time hours:13 minutes:0 seconds:0) hour12 |
|
563 |
(Time hours:23 minutes:0 seconds:0) hour24 |
|
564 |
(Time hours:23 minutes:0 seconds:0) hour12 |
|
565 |
(Time hours:24 minutes:0 seconds:0) hour24 |
|
566 |
(Time hours:24 minutes:0 seconds:0) hour12 |
|
567 |
" |
|
568 |
! |
|
569 |
||
570 |
hour24 |
|
571 |
"return the hour (0..23)." |
|
572 |
||
573 |
^ self hours |
|
574 |
||
575 |
" |
|
576 |
Time now hour12 |
|
577 |
Time now hour24 |
|
578 |
(Time hours:0 minutes:0 seconds:0) hour24 |
|
579 |
(Time hours:0 minutes:0 seconds:0) hour12 |
|
580 |
(Time hours:1 minutes:0 seconds:0) hour24 |
|
581 |
(Time hours:1 minutes:0 seconds:0) hour12 |
|
582 |
(Time hours:12 minutes:0 seconds:0) hour24 |
|
583 |
(Time hours:12 minutes:0 seconds:0) hour12 |
|
584 |
(Time hours:13 minutes:0 seconds:0) hour24 |
|
585 |
(Time hours:13 minutes:0 seconds:0) hour12 |
|
586 |
(Time hours:23 minutes:0 seconds:0) hour24 |
|
587 |
(Time hours:23 minutes:0 seconds:0) hour12 |
|
588 |
(Time hours:24 minutes:0 seconds:0) hour24 |
|
589 |
(Time hours:24 minutes:0 seconds:0) hour12 |
|
590 |
" |
|
591 |
! |
|
592 |
||
593 |
meridianAbbreviation |
|
594 |
"am/pm" |
|
595 |
||
596 |
self hours // 12 == 0 ifTrue:[ |
|
597 |
^ 'am'. |
|
598 |
] ifFalse:[ |
|
8200 | 599 |
(self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[ |
600 |
^ 'noon' |
|
601 |
]. |
|
6419 | 602 |
^ 'pm'. |
603 |
]. |
|
604 |
||
605 |
" |
|
606 |
Time now meridianAbbreviation |
|
607 |
(Time hours:0 minutes:0 seconds:0) meridianAbbreviation |
|
608 |
(Time hours:11 minutes:59 seconds:59) meridianAbbreviation |
|
609 |
(Time hours:12 minutes:0 seconds:0) meridianAbbreviation |
|
610 |
(Time hours:12 minutes:0 seconds:1) meridianAbbreviation |
|
611 |
" |
|
612 |
! ! |
|
613 |
||
23235 | 614 |
!AbstractTime methodsFor:'Compatibility-ST80'! |
615 |
||
616 |
hour |
|
617 |
"return the hour (0..23). |
|
618 |
ST-80 Timestamp compatibility |
|
619 |
(I'd prefer the name #hours, for Time compatibility)." |
|
620 |
||
621 |
^ self hours |
|
622 |
||
623 |
"Created: 1.7.1996 / 15:14:50 / cg" |
|
624 |
"Modified: 1.7.1996 / 15:15:32 / cg" |
|
625 |
! |
|
626 |
||
627 |
minute |
|
628 |
"return the minute (0..59). |
|
629 |
ST-80 Timestamp compatibility |
|
630 |
(I'd prefer the name #minutes, for Time compatibility)." |
|
631 |
||
632 |
^ self minutes |
|
633 |
||
634 |
"Created: 1.7.1996 / 15:14:29 / cg" |
|
635 |
"Modified: 1.7.1996 / 15:15:37 / cg" |
|
636 |
! |
|
637 |
||
638 |
second |
|
639 |
"return the second (0..59). |
|
640 |
ST-80 Timestamp compatibility |
|
641 |
(I'd prefer the name #seconds, for Time compatibility)." |
|
642 |
||
643 |
^ self seconds |
|
644 |
||
645 |
"Created: 1.7.1996 / 15:14:19 / cg" |
|
646 |
"Modified: 1.7.1996 / 15:15:49 / cg" |
|
647 |
! ! |
|
648 |
||
24423 | 649 |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
650 |
!AbstractTime methodsFor:'abstract'! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
651 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
652 |
hours |
8200 | 653 |
"return the hour of time (0..23)" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
654 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
655 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
656 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
657 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
658 |
Timestamp now hours |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
659 |
Time now hours |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
660 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
661 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
662 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
663 |
milliseconds |
8200 | 664 |
"return the milliseconds since the start of the second (0..999)" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
665 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
666 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
667 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
668 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
669 |
Timestamp now milliseconds |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
670 |
Time now milliseconds |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
671 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
672 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
673 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
674 |
minutes |
8200 | 675 |
"return the minutes since the start of the hour (0..59)" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
676 |
|
7672 | 677 |
^ self subclassResponsibility. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
678 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
679 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
680 |
Timestamp now minutes |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
681 |
Time now minutes |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
682 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
683 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
684 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
685 |
seconds |
8200 | 686 |
"return the seconds since the start of the minute (0..59)" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
687 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
688 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
689 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
690 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
691 |
Timestamp now seconds. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
692 |
Time now seconds |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
693 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
694 |
! ! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
695 |
|
275 | 696 |
!AbstractTime methodsFor:'accessing'! |
697 |
||
698 |
hourInDay |
|
699 |
"return the hours (0..23)" |
|
700 |
||
701 |
^ self hours |
|
702 |
||
703 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
704 |
Timestamp now hourInDay |
275 | 705 |
Time now hourInDay |
706 |
" |
|
707 |
! |
|
708 |
||
22626 | 709 |
microseconds |
710 |
"return the microseconds within the current second (0..999999)" |
|
711 |
||
22836 | 712 |
^ (self milliseconds * 1000) + (self additionalPicoseconds // (1000*1000)). |
22626 | 713 |
|
714 |
" |
|
715 |
Timestamp now microseconds |
|
716 |
Timestamp nowWithMicroseconds microseconds |
|
717 |
" |
|
718 |
! |
|
719 |
||
275 | 720 |
minuteInDay |
721 |
"return the minutes (0..59)" |
|
722 |
||
723 |
^ self minutes. |
|
724 |
||
725 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
726 |
Timestamp now minuteInDay |
275 | 727 |
Time now minuteInDay |
728 |
" |
|
729 |
! |
|
730 |
||
22845 | 731 |
nanoseconds |
732 |
"return the nanoseconds within the current second (0..999999)" |
|
733 |
||
734 |
^ (self milliseconds * 1000000) + (self additionalPicoseconds // (1000)). |
|
735 |
||
736 |
" |
|
737 |
Timestamp now nanoseconds |
|
738 |
Timestamp nowWithMicroseconds nanoseconds |
|
739 |
" |
|
740 |
! |
|
741 |
||
22626 | 742 |
picoseconds |
22836 | 743 |
"return the picoseconds within the current second (0..999999999). |
744 |
notice: that is NOT the total number of picoseconds, |
|
745 |
but the fractional part (within the second) only. |
|
746 |
Use this only for printing. |
|
747 |
Here, fall back and generate something based on the milliseconds" |
|
22626 | 748 |
|
22845 | 749 |
^ (self milliseconds * 1000 * 1000 * 1000) + (self additionalPicoseconds). |
22626 | 750 |
|
751 |
" |
|
752 |
Timestamp now picoseconds |
|
22836 | 753 |
Timestamp nowWithMicroseconds picoseconds |
22845 | 754 |
|
755 |
(TimeDuration fromPicoseconds:100) picoseconds |
|
756 |
(TimeDuration fromPicoseconds:100000) picoseconds |
|
757 |
(TimeDuration fromPicoseconds:100000) nanoseconds |
|
758 |
(TimeDuration fromPicoseconds:100000000) picoseconds |
|
759 |
(TimeDuration fromPicoseconds:100000000) nanoseconds |
|
760 |
(TimeDuration fromPicoseconds:100000000) microseconds |
|
761 |
(TimeDuration fromPicoseconds:100000000000) picoseconds |
|
762 |
(TimeDuration fromPicoseconds:100000000000) nanoseconds |
|
763 |
(TimeDuration fromPicoseconds:100000000000) microseconds |
|
764 |
(TimeDuration fromPicoseconds:100000000000) milliseconds |
|
22626 | 765 |
" |
766 |
! |
|
767 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
768 |
secondInDay |
275 | 769 |
"return the seconds (0..59)" |
770 |
||
771 |
^ self seconds |
|
772 |
||
773 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
774 |
Timestamp now secondInDay |
275 | 775 |
Time now seconds |
776 |
" |
|
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
777 |
|
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
778 |
"Created: 22.10.1996 / 09:27:47 / stefan" |
5548 | 779 |
! |
780 |
||
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
781 |
timeZoneDeltaInMinutes |
9432 | 782 |
"answer the number of minutes between local time and utc time. |
783 |
Delta is positive if local time is ahead of utc, negative if behind utc." |
|
784 |
||
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
785 |
^ 0 |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
786 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
787 |
|
5968 | 788 |
timeZoneName |
16982 | 789 |
^ 'UTC' |
790 |
! |
|
791 |
||
792 |
utcOffset |
|
793 |
^ 0 |
|
275 | 794 |
! ! |
795 |
||
796 |
!AbstractTime methodsFor:'arithmetic'! |
|
797 |
||
10679 | 798 |
+ aNumberOrTimeDuration |
22845 | 799 |
"Add aNumber (numberOfSeconds) or, if it's a timeDuration, add it's value" |
8200 | 800 |
|
10679 | 801 |
^ aNumberOrTimeDuration sumFromTimestamp:self. |
802 |
||
8200 | 803 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
804 |
Timestamp now to:(Timestamp now + 30) by:2 do:[:time| |
8200 | 805 |
Transcript showCR:time. |
806 |
]. |
|
22845 | 807 |
Timestamp now to:(Timestamp now + 30) by:2 seconds do:[:time| |
808 |
Transcript showCR:time. |
|
809 |
]. |
|
810 |
(Timestamp now + 30 seconds) to:(Timestamp now) by:-2 seconds do:[:time| |
|
811 |
Transcript showCR:time. |
|
812 |
]. |
|
813 |
(Timestamp now + 30 seconds) to:(Timestamp now) by:-2 do:[:time| |
|
814 |
Transcript showCR:time. |
|
815 |
]. |
|
8200 | 816 |
|
10679 | 817 |
(Timestamp now + 20) - Timestamp now |
818 |
(Timestamp now + 0.5) - Timestamp now |
|
819 |
(Timestamp now + (TimeDuration fromString:'1m 10s')) - Timestamp now |
|
11771 | 820 |
(Timestamp now + (10 seconds)) - Timestamp now |
8200 | 821 |
" |
21427 | 822 |
|
823 |
"Modified (comment): / 13-02-2017 / 19:55:04 / cg" |
|
8200 | 824 |
! |
825 |
||
22845 | 826 |
- aTimeOrTimeDurationOrNumberOfSeconds |
8244 | 827 |
"return the delta in seconds between 2 times or subtract a number of seconds." |
275 | 828 |
|
24117 | 829 |
"/ Q: for Time - x hours |
830 |
"/ should we convert to timestamp i.e. caring for time-wrapping at midnight? |
|
831 |
"/ no - for compatibility, we'll get the time-within-the day again |
|
832 |
"/ if you need the real timestamp, a for it explicitly |
|
833 |
||
22845 | 834 |
^ aTimeOrTimeDurationOrNumberOfSeconds differenceFromTimestamp:self. |
275 | 835 |
|
836 |
" |
|
22845 | 837 |
Timestamp now - 3600. -> 2018-05-09 15:37:57.485 |
838 |
Timestamp now - 3600 seconds. -> 2018-05-09 15:38:04.665 |
|
839 |
(Timestamp now addSeconds:10) - Timestamp now -> 10s |
|
840 |
||
841 |
Time now - 3600. -> 03:38:23 PM |
|
842 |
Time now - 3600 seconds. -> 03:38:35 PM |
|
843 |
(Time now addSeconds:10) - Time now -> 10s |
|
24117 | 844 |
Time now - 1 hours. -> 11:04:02 |
845 |
Time now - 24 hours. -> 11:04:02 |
|
22845 | 846 |
|
847 |
(TimeDuration fromString:'1.5hr') - 3600. -> 30m |
|
848 |
(TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr') -> 30m |
|
8200 | 849 |
|
275 | 850 |
|t1 t2| |
851 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
852 |
t1 := Timestamp now. |
16407 | 853 |
Delay waitFor:10 seconds. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
854 |
t2 := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
855 |
Transcript showCR:('seconds passed: ' , (t2 - t1) printString). |
275 | 856 |
" |
24117 | 857 |
|
858 |
"Modified (comment): / 08-05-2019 / 12:49:59 / Claus Gittinger" |
|
275 | 859 |
! |
860 |
||
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
861 |
addDays:numberOfDays |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
862 |
"return a new instance of myself, numberOfDays afterwards." |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
863 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
864 |
^ self addSeconds:(numberOfDays * (60 * 60 * 24)) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
865 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
866 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
867 |
|t| |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
868 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
869 |
t := Timestamp now. |
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
870 |
Transcript showCR:t. |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
871 |
Transcript showCR:(t addDays:7) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
872 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
873 |
! |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
874 |
|
699 | 875 |
addHours:numberOfHours |
876 |
"return a new instance of myself, numberOfHours afterwards." |
|
275 | 877 |
|
699 | 878 |
^ self addSeconds:(numberOfHours * (60 * 60)) |
275 | 879 |
|
880 |
" |
|
881 |
|t| |
|
882 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
883 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
884 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
885 |
Transcript showCR:(t addHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
886 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
887 |
|
275 | 888 |
" |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
889 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
890 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
891 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
892 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
893 |
Transcript showCR:(t addHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
894 |
" |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
895 |
! |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
896 |
|
22945 | 897 |
addMicroseconds:numberOfMicroSeconds |
898 |
"return a new instance of myself, numberOfMicroSeconds afterwards." |
|
899 |
||
900 |
^ self speciesNew |
|
901 |
setMilliseconds:(self getMilliseconds + (numberOfMicroSeconds // 1000)) |
|
902 |
additionalPicoseconds:(self additionalPicoseconds |
|
22988 | 903 |
+ ((numberOfMicroSeconds \\ 1000)*1000000) truncated) |
22945 | 904 |
|
905 |
" |
|
906 |
|t1 t2| |
|
907 |
||
908 |
t1 := Timestamp now. |
|
909 |
Transcript showCR:t1. |
|
910 |
t2 := t1 addMicroseconds:1000. |
|
911 |
Transcript showCR:t2. |
|
912 |
t2 := t1 addMicroseconds:1010. |
|
913 |
Transcript showCR:t2. |
|
914 |
Transcript showCR:(t2 - t1). |
|
915 |
self halt. |
|
916 |
Transcript showCR:(t2 - t1) asMicroseconds. |
|
917 |
" |
|
918 |
||
919 |
" |
|
920 |
|t| |
|
921 |
||
922 |
t := Time now. |
|
923 |
Transcript showCR:t. |
|
924 |
Transcript showCR:(t addMilliseconds:1000). |
|
925 |
" |
|
22988 | 926 |
|
927 |
"Modified: / 22-05-2018 / 16:52:37 / Stefan Vogel" |
|
22945 | 928 |
! |
929 |
||
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
930 |
addMilliseconds:numberOfMilliSeconds |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
931 |
"return a new instance of myself, numberOfMilliSeconds afterwards." |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
932 |
|
17015 | 933 |
^ self speciesNew |
22988 | 934 |
setMilliseconds:(self getMilliseconds + (numberOfMilliSeconds // 1 "this is inlined #truncated")) |
22884 | 935 |
additionalPicoseconds:(self additionalPicoseconds |
22988 | 936 |
+ ((numberOfMilliSeconds \\ 1)*1000000000) truncated) |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
937 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
938 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
939 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
940 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
941 |
t := Timestamp now. |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
942 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
943 |
Transcript showCR:(t addMilliseconds:100). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
944 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
945 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
946 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
947 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
948 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
949 |
t := Time now. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
950 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
951 |
Transcript showCR:(t addMilliseconds:1000). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
952 |
" |
22988 | 953 |
|
954 |
"Modified: / 22-05-2018 / 17:03:20 / Stefan Vogel" |
|
275 | 955 |
! |
956 |
||
957 |
addMinutes:numberOfMinutes |
|
958 |
"return a new instance of myself, numberOfMinutes afterwards." |
|
959 |
||
960 |
^ self addSeconds:(numberOfMinutes * 60) |
|
961 |
||
962 |
" |
|
963 |
|t| |
|
964 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
965 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
966 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
967 |
Transcript showCR:(t addMinutes:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
968 |
" |
275 | 969 |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
970 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
971 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
972 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
973 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
974 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
975 |
Transcript showCR:(t addMinutes:60). |
275 | 976 |
" |
977 |
! |
|
978 |
||
699 | 979 |
addSeconds:numberOfSeconds |
980 |
"return a new instance of myself, numberOfSeconds afterwards." |
|
981 |
||
22884 | 982 |
^ self addMilliseconds:(numberOfSeconds * 1000) |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
983 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
984 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
985 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
986 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
987 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
988 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
989 |
Transcript showCR:(t addSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
990 |
" |
699 | 991 |
|
992 |
" |
|
993 |
|t| |
|
994 |
||
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
995 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
996 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
997 |
Transcript showCR:(t addSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
998 |
" |
699 | 999 |
! |
1000 |
||
1001 |
addTime:timeAmount |
|
1002 |
"return a new instance of myself, timeAmount seconds afterwards. |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1003 |
Provided for ST-80 compatibility. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1004 |
WARNING: |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1005 |
AddTime is a bad name - it does not add a time, but expects |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1006 |
a numberOfSeconds as argument. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1007 |
Use any of addSeconds/addHours etc. to make things clear" |
699 | 1008 |
|
6888
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1009 |
timeAmount isNumber ifFalse:[ |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1010 |
^ self addSeconds:(timeAmount asSeconds). |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1011 |
]. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1012 |
^ self addSeconds:timeAmount |
699 | 1013 |
! |
1014 |
||
16475 | 1015 |
deltaFrom:aTimeOrInteger |
1016 |
"return the delta as a timeDuration between 2 timeStamps. |
|
1017 |
The argument is supposed to be BEFORE the receiver, |
|
1018 |
computes self - aTimestamp" |
|
1019 |
||
1020 |
^ aTimeOrInteger differenceFromTimestamp:self |
|
1021 |
||
1022 |
" |
|
1023 |
Time now deltaFrom:10 minutes. |
|
1024 |
Time now deltaFrom:3600. |
|
1025 |
Time now deltaFrom:3600 seconds. |
|
1026 |
||
1027 |
Timestamp now deltaFrom:10 minutes. |
|
1028 |
Timestamp now deltaFrom:3600. |
|
1029 |
Timestamp now deltaFrom:3600 seconds. |
|
1030 |
" |
|
1031 |
||
1032 |
" |
|
1033 |
|t1 t2| |
|
1034 |
||
1035 |
t1 := Timestamp now. |
|
1036 |
Delay waitForSeconds:0.5. |
|
1037 |
t2 := Timestamp now. |
|
1038 |
t2 deltaFrom:t1 |
|
1039 |
" |
|
1040 |
||
1041 |
"Created: / 04-10-2007 / 13:34:28 / cg" |
|
1042 |
"Modified: / 10-07-2010 / 09:37:01 / cg" |
|
1043 |
! |
|
1044 |
||
16505 | 1045 |
roundTo:aTimeDuration |
21335 | 1046 |
"round the receiver to the next multiple of a TimeDuration" |
1047 |
||
16505 | 1048 |
^ self class new setMilliseconds:(self getMilliseconds roundTo:aTimeDuration getMilliseconds) |
1049 |
||
1050 |
" |
|
1051 |
(TimeDuration fromMilliseconds:25234) roundTo:2 seconds |
|
1052 |
Time now roundTo:10 minutes |
|
1053 |
Timestamp now roundTo:10 minutes |
|
1054 |
" |
|
1055 |
! |
|
1056 |
||
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1057 |
subtractDays:numberOfDays |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1058 |
"return a new instance of myself, numberOfDays before." |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1059 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1060 |
^ self subtractSeconds:(numberOfDays * (60 * 60 * 24)) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1061 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1062 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1063 |
|t| |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1064 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1065 |
t := Timestamp now. |
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1066 |
Transcript showCR:t. |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1067 |
Transcript showCR:(t subtractDays:50) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1068 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1069 |
! |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
1070 |
|
699 | 1071 |
subtractHours:numberOfHours |
1072 |
"return a new instance of myself, numberOfHours before." |
|
1073 |
||
1074 |
^ self subtractSeconds:(numberOfHours * (60 * 60)) |
|
275 | 1075 |
|
1076 |
" |
|
1077 |
|t| |
|
1078 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1079 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1080 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1081 |
Transcript showCR:(t subtractHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1082 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1083 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1084 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1085 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1086 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1087 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1088 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1089 |
Transcript showCR:(t subtractHours:12). |
275 | 1090 |
" |
1091 |
! |
|
1092 |
||
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1093 |
subtractMilliseconds:numberOfMilliSeconds |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1094 |
"return a new instance of myself, numberOfMilliSeconds before." |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1095 |
|
22884 | 1096 |
^ self addMilliseconds:numberOfMilliSeconds negated |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1097 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1098 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1099 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1100 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1101 |
t := Timestamp now. |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1102 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1103 |
Transcript showCR:(t subtractMilliseconds:100). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1104 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1105 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1106 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1107 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1108 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1109 |
t := Time now. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1110 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1111 |
Transcript showCR:(t subtractMilliseconds:1000). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1112 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1113 |
! |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
1114 |
|
275 | 1115 |
subtractMinutes:numberOfMinutes |
1116 |
"return a new instance of myself, numberOfMinutes before." |
|
1117 |
||
1118 |
^ self subtractSeconds:(numberOfMinutes * 60) |
|
1119 |
||
1120 |
" |
|
1121 |
|t| |
|
1122 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1123 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1124 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1125 |
Transcript showCR:(t subtractMinutes:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1126 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1127 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1128 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1129 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1130 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1131 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1132 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1133 |
Transcript showCR:(t subtractMinutes:60). |
275 | 1134 |
" |
1135 |
! |
|
1136 |
||
699 | 1137 |
subtractSeconds:numberOfSeconds |
1138 |
"return a new instance of myself, numberOfSeconds before." |
|
275 | 1139 |
|
22884 | 1140 |
^ self addMilliseconds:(numberOfSeconds * -1000) |
275 | 1141 |
|
1142 |
" |
|
1143 |
|t| |
|
1144 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1145 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1146 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1147 |
Transcript showCR:(t subtractSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1148 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1149 |
|
275 | 1150 |
" |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1151 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1152 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1153 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1154 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1155 |
Transcript showCR:(t subtractSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1156 |
" |
275 | 1157 |
! |
1158 |
||
1159 |
subtractTime:timeAmount |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1160 |
"return a new instance of myself, timeAmount seconds before myself. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1161 |
Provided for ST-80 compatibility. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1162 |
WARNING: |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1163 |
SubtractTime is a bad name - it does not add a time, but expects |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1164 |
a numberOfSeconds as argument. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1165 |
Use any of addSeconds/addHours etc. to make things clear" |
275 | 1166 |
|
6888
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1167 |
timeAmount isNumber ifFalse:[ |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1168 |
^ self subtractSeconds:(timeAmount asSeconds). |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
1169 |
]. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1170 |
^ self subtractSeconds:timeAmount |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
1171 |
|
16505 | 1172 |
! |
1173 |
||
1174 |
truncateTo:aTimeDuration |
|
21335 | 1175 |
"truncate the receiver to the next multiple of a TimeDuration" |
1176 |
||
16505 | 1177 |
^ self class new setMilliseconds:(self getMilliseconds truncateTo:aTimeDuration getMilliseconds) |
1178 |
||
1179 |
" |
|
1180 |
(TimeDuration fromMilliseconds:25234) truncateTo:2 seconds |
|
1181 |
Time now truncateTo:10 minutes |
|
1182 |
Timestamp now truncateTo:10 minutes |
|
1183 |
" |
|
275 | 1184 |
! ! |
1185 |
||
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1186 |
!AbstractTime methodsFor:'comparing'! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1187 |
|
22884 | 1188 |
< aTimeOrTimeDurationOrNumberOfSeconds |
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1189 |
"return true if the receiver is before the argument" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1190 |
|
22884 | 1191 |
|myMilliseconds otherMilliseconds myPicos otherPicos| |
1192 |
||
1193 |
myMilliseconds := self getMilliseconds. |
|
1194 |
myPicos := self additionalPicoseconds. |
|
1195 |
||
1196 |
aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
1197 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
1198 |
otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger. "integer seconds" |
|
1199 |
otherPicos := 0. |
|
1200 |
] ifFalse:[ |
|
1201 |
otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds. |
|
1202 |
otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds. |
|
1203 |
]. |
|
1204 |
^ (myMilliseconds < otherMilliseconds) |
|
1205 |
or:[ myMilliseconds = otherMilliseconds and:[myPicos < otherPicos ]]. |
|
1206 |
||
1207 |
" |
|
1208 |
(Timestamp now + 10) - Timestamp now < 10 |
|
1209 |
(Timestamp now + 10) - Timestamp now < 11 |
|
1210 |
" |
|
1211 |
! |
|
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1212 |
|
22884 | 1213 |
<= aTimeOrTimeDurationOrNumberOfSeconds |
1214 |
"return true if the receiver is before or the same time as the argument" |
|
1215 |
||
1216 |
|myMilliseconds otherMilliseconds myPicos otherPicos| |
|
1217 |
||
1218 |
myMilliseconds := self getMilliseconds. |
|
1219 |
myPicos := self additionalPicoseconds. |
|
1220 |
||
1221 |
aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
1222 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
1223 |
otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger. "integer seconds" |
|
1224 |
otherPicos := 0. |
|
1225 |
] ifFalse:[ |
|
1226 |
otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds. |
|
1227 |
otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds. |
|
1228 |
]. |
|
1229 |
^ (myMilliseconds < otherMilliseconds) |
|
1230 |
or:[ myMilliseconds = otherMilliseconds and:[myPicos <= otherPicos ]]. |
|
1231 |
||
1232 |
" |
|
1233 |
(Timestamp now + 10) - Timestamp now <= 10 |
|
1234 |
(Timestamp now + 10) - Timestamp now <= 11 |
|
1235 |
(Timestamp now + 10) - Timestamp now <= 9 |
|
1236 |
" |
|
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1237 |
! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1238 |
|
22884 | 1239 |
= aTimeOrTimeDurationOrNumberOfSeconds |
1240 |
"return true if the receiver is before or the same time as the argument" |
|
1241 |
||
1242 |
|myMilliseconds otherMilliseconds myPicos otherPicos| |
|
1243 |
||
1244 |
myMilliseconds := self getMilliseconds. |
|
1245 |
myPicos := self additionalPicoseconds. |
|
1246 |
||
1247 |
aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
1248 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
1249 |
otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger. "integer seconds" |
|
1250 |
otherPicos := 0. |
|
1251 |
] ifFalse:[ |
|
22913 | 1252 |
self speciesForCompare = aTimeOrTimeDurationOrNumberOfSeconds speciesForCompare ifFalse:[ |
1253 |
^ false |
|
1254 |
]. |
|
22884 | 1255 |
otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds. |
1256 |
otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds. |
|
1257 |
]. |
|
1258 |
^ (myMilliseconds = otherMilliseconds) and:[myPicos = otherPicos ]. |
|
1259 |
||
1260 |
" |
|
1261 |
(Timestamp now + 10) - Timestamp now = 10 |
|
1262 |
(Timestamp now + 10) - Timestamp now = 9 |
|
1263 |
||
22913 | 1264 |
(Timestamp now) = (Timestamp now + 10 - 10) |
1265 |
(Timestamp now) = (UtcTimestamp now) |
|
1266 |
||
22884 | 1267 |
(Time now + 10 seconds) - Time now = 10 |
1268 |
(Time now + 10) - Time now = 10 |
|
1269 |
||
1270 |
(Time now + 10 seconds) > Time now |
|
1271 |
(Time now + 10) > Time now |
|
1272 |
||
1273 |
(Time now + 10 milliSeconds) > Time now |
|
1274 |
(Time now + 0 milliseconds) > Time now |
|
1275 |
" |
|
1276 |
! |
|
1277 |
||
1278 |
> aTimeOrTimeDurationOrNumberOfSeconds |
|
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1279 |
"return true if the receiver is after the argument" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1280 |
|
22884 | 1281 |
|myMilliseconds otherMilliseconds myPicos otherPicos| |
1282 |
||
1283 |
myMilliseconds := self getMilliseconds. |
|
1284 |
myPicos := self additionalPicoseconds. |
|
1285 |
||
1286 |
aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
1287 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
1288 |
otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger. "integer seconds" |
|
1289 |
otherPicos := 0. |
|
1290 |
] ifFalse:[ |
|
1291 |
otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds. |
|
1292 |
otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds. |
|
1293 |
]. |
|
1294 |
^ (myMilliseconds > otherMilliseconds) |
|
1295 |
or:[ myMilliseconds = otherMilliseconds and:[myPicos > otherPicos ]]. |
|
1296 |
||
1297 |
" |
|
1298 |
(Timestamp now + 10) - Timestamp now > 10 |
|
1299 |
(Timestamp now + 10) - Timestamp now > 9 |
|
1300 |
" |
|
1301 |
! |
|
1302 |
||
1303 |
>= aTimeOrTimeDurationOrNumberOfSeconds |
|
1304 |
"return true if the receiver is after the argument or the same" |
|
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1305 |
|
22884 | 1306 |
|myMilliseconds otherMilliseconds myPicos otherPicos| |
1307 |
||
1308 |
myMilliseconds := self getMilliseconds. |
|
1309 |
myPicos := self additionalPicoseconds. |
|
1310 |
||
1311 |
aTimeOrTimeDurationOrNumberOfSeconds isNumber ifTrue:[ |
|
1312 |
"backward compatibility for old code, which expects (time1 - time2) to return seconds" |
|
1313 |
otherMilliseconds := (aTimeOrTimeDurationOrNumberOfSeconds * 1000) asInteger. "integer seconds" |
|
1314 |
otherPicos := 0. |
|
1315 |
] ifFalse:[ |
|
1316 |
otherMilliseconds := aTimeOrTimeDurationOrNumberOfSeconds getMilliseconds. |
|
1317 |
otherPicos := aTimeOrTimeDurationOrNumberOfSeconds additionalPicoseconds. |
|
1318 |
]. |
|
1319 |
^ (myMilliseconds > otherMilliseconds) |
|
1320 |
or:[ myMilliseconds = otherMilliseconds and:[myPicos >= otherPicos ]]. |
|
1321 |
||
1322 |
" |
|
1323 |
(Timestamp now + 10) - Timestamp now >= 11 |
|
1324 |
(Timestamp now + 10) - Timestamp now >= 10 |
|
1325 |
(Timestamp now + 10) - Timestamp now >= 9 |
|
1326 |
" |
|
1327 |
! |
|
1328 |
||
1329 |
hash |
|
1330 |
^ self getMilliseconds |
|
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1331 |
! ! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
1332 |
|
8200 | 1333 |
!AbstractTime methodsFor:'converting'! |
1334 |
||
1335 |
asAbsoluteTime |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1336 |
"deprecated, use #asTimestamp" |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1337 |
<resource:#obsolete> |
8200 | 1338 |
|
12002 | 1339 |
self obsoleteMethodWarning:'use #asTimestamp'. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1340 |
^ self asTimestamp |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1341 |
! |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1342 |
|
13233 | 1343 |
asLocalTimestamp |
1344 |
"represent myself as a timestamp in the local timezone" |
|
1345 |
||
1346 |
^ self subclassResponsibility |
|
1347 |
! |
|
1348 |
||
17140 | 1349 |
asMilliseconds |
22836 | 1350 |
"return the number of milliseconds elapsed since some starttime, |
1351 |
which is subclass specific (i.e. Time: since midnight; Timestamp: since the epoch). |
|
1352 |
Use this only to compute relative millisecond deltas." |
|
17140 | 1353 |
|
1354 |
^ self getMilliseconds |
|
1355 |
||
1356 |
" |
|
1357 |
Time now asMilliseconds |
|
1358 |
Timestamp now asMilliseconds |
|
1359 |
(TimeDuration days:1) asMilliseconds |
|
1360 |
(TimeDuration hours:1) asMilliseconds |
|
1361 |
" |
|
1362 |
||
1363 |
"Created: / 05-09-2011 / 10:40:15 / cg" |
|
1364 |
! |
|
1365 |
||
1366 |
asSeconds |
|
19398 | 1367 |
"get the seconds since some point of time in the past. |
1368 |
For Time instances, this is the number of seconds elapsed since midnight; |
|
22283 | 1369 |
For TimeDurations, that is the duration in seconds (truncated); |
19398 | 1370 |
For TimeStamps, that is the number of seconds since the epoch" |
17140 | 1371 |
|
1372 |
^ self getSeconds |
|
1373 |
||
1374 |
" |
|
1375 |
Timestamp now asSeconds |
|
1376 |
Time now asSeconds |
|
1377 |
(TimeDuration days:1) asSeconds |
|
1378 |
" |
|
22283 | 1379 |
|
1380 |
"Modified (comment): / 21-09-2017 / 18:49:31 / cg" |
|
17140 | 1381 |
! |
1382 |
||
23235 | 1383 |
asTZTimestamp |
1384 |
"raise an error: must be redefined in concrete subclass(es)" |
|
1385 |
||
1386 |
^ self subclassResponsibility |
|
1387 |
! |
|
1388 |
||
22036 | 1389 |
asTime |
1390 |
"return a Time object from the receiver." |
|
1391 |
||
1392 |
^ Time hours:(self hours) minutes:(self minutes) seconds:(self seconds) milliseconds:(self milliseconds) |
|
1393 |
||
1394 |
" |
|
1395 |
(1 seconds + 0.01 seconds) asTime |
|
1396 |
" |
|
1397 |
||
1398 |
"Created: / 17-07-2017 / 13:57:54 / cg" |
|
1399 |
! |
|
1400 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1401 |
asTimestamp |
13233 | 1402 |
"represent myself as a Timestamp" |
1403 |
||
1404 |
^ self subclassResponsibility |
|
1405 |
! |
|
1406 |
||
1407 |
asUtcTimestamp |
|
1408 |
"represent myself as a timestamp in the local timezone" |
|
1409 |
||
8200 | 1410 |
^ self subclassResponsibility |
1411 |
! ! |
|
1412 |
||
22632 | 1413 |
!AbstractTime methodsFor:'double dispatching'! |
1414 |
||
1415 |
differenceFromTimestamp:aTimestamp |
|
22945 | 1416 |
"return the time difference as a timeDuration instance" |
22632 | 1417 |
|
23235 | 1418 |
^ self subclassResponsibility. |
1419 |
||
1420 |
"Modified: / 27-07-2018 / 11:30:27 / Stefan Vogel" |
|
22632 | 1421 |
! ! |
1422 |
||
22913 | 1423 |
|
24423 | 1424 |
|
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1425 |
!AbstractTime methodsFor:'printing & storing'! |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1426 |
|
16829 | 1427 |
addBasicPrintBindingsTo:aDictionary language:languageOrNil |
1428 |
"private print support: add bindings for printing to aDictionary. |
|
1429 |
languageOrNil can be #en, #fr, #de or nil for the current language. |
|
1430 |
Here only basic bindings are added - no timezone am am/pm stuff, |
|
1431 |
which doesn't make sense for TimeDuration. |
|
1432 |
||
1433 |
bindings: |
|
1434 |
%h hours, 00..23 (i.e. european) 0-padded to length 2 |
|
1435 |
%m minutes, 00..59 0-padded to length 2 |
|
1436 |
%s seconds, 00..59 0-padded to length 2 |
|
1437 |
%i milliseconds, 000..999 0-padded to length 3 |
|
22626 | 1438 |
%j microseconds, 000000..999999 0-padded to length 6 |
16829 | 1439 |
|
1440 |
Timestamp only: |
|
1441 |
%(day) day, 00..31 0-padded to length 2 |
|
1442 |
%(month) month, 00..12 0-padded to length 2 |
|
1443 |
%(year) year, 4 digits 0-padded to length 4 |
|
1444 |
||
1445 |
special: |
|
1446 |
%H 24-hours - unpadded |
|
1447 |
%M minutes - unpadded |
|
1448 |
%S seconds - unpadded |
|
1449 |
%I milliseconds, unpadded |
|
22626 | 1450 |
%J microseconds, unpadded |
1451 |
%F subsecond fraction, unpadded with as many post-digits as appropriate |
|
1452 |
(i.e. for .1 , .01 , .001 etc.) |
|
16829 | 1453 |
|
1454 |
%t seconds within hour (unpadded) |
|
1455 |
%T seconds from midNight (unpadded) |
|
1456 |
||
22626 | 1457 |
%(milli) milliseconds unpadded - alias for %I for convenience |
20200 | 1458 |
%(milli1) milliseconds, truncated to 1/10th of a second 0..9 |
1459 |
%(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2 |
|
22845 | 1460 |
%(milli3) milliseconds, padded to 3 (same as %i for convenience) |
22995 | 1461 |
%(milliF1) milliseconds + 1 digits of micros |
1462 |
%(milliF2) milliseconds + 2 digits of micros |
|
1463 |
%(milliF3) milliseconds + 3 digits of micros |
|
1464 |
%(milliF4) milliseconds + 4 digits of micros |
|
16829 | 1465 |
|
22626 | 1466 |
%(micro) microseconds unpadded - alias for %J for convenience |
22845 | 1467 |
%(micro6) microseconds, padded to 6 (same as %j for convenience) |
1468 |
||
1469 |
%(nano) nanoseconds unpadded |
|
1470 |
%(nano9) nanoseconds, padded to 9 |
|
22626 | 1471 |
|
22845 | 1472 |
%(pico) picoseconds unpadded |
1473 |
%(pico12) picoseconds, padded to 12 |
|
1474 |
||
1475 |
%(fract) fraction part - as many as needed alias for %F for convenience |
|
22626 | 1476 |
|
16829 | 1477 |
Timestamp only: |
20200 | 1478 |
%(Day) - day - unpadded |
1479 |
%(Month) - month - unpadded |
|
16829 | 1480 |
%(yearOrTime) - year or time 5 digits as in unix-ls: |
1481 |
year if it is not the current year; |
|
1482 |
time otherwise |
|
1483 |
%(weekDay) - day in week (1->monday, 2->tuesday, ... ,7->sunday) |
|
1484 |
||
20200 | 1485 |
%(dayName) - full day name |
1486 |
%(DayName) - full day name, first character uppercase |
|
1487 |
%(DAYNAME) - full day name, all uppercase |
|
16829 | 1488 |
|
20200 | 1489 |
%(monthName) - full month name |
1490 |
%(MonthName) - full month name, first character uppercase |
|
1491 |
%(MONTHNAME) - full month name, all uppercase |
|
16829 | 1492 |
|
20200 | 1493 |
%(shortDayName) - short (abbreviated) day name |
1494 |
%(ShortDayName) - short (abbreviated) day name, first character uppercase |
|
1495 |
%(SHORTDAYNAME) - short (abbreviated) day name, all uppercase |
|
16829 | 1496 |
|
20200 | 1497 |
%(shortMonthName) - short (abbreviated) month name |
1498 |
%(ShortMonthName) - short (abbreviated) month name, first character uppercase |
|
1499 |
%(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase |
|
16829 | 1500 |
|
20200 | 1501 |
%(nth) - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
1502 |
%(weekDayNth) - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
16829 | 1503 |
%(weekNth) - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
1504 |
||
1505 |
||
1506 |
The ISO8601 printString are generated with: |
|
1507 |
||
1508 |
Year: |
|
1509 |
YYYY (eg 1997) |
|
1510 |
Date today printStringFormat:'%(year)' |
|
20200 | 1511 |
Timestamp now printStringFormat:'%(year)' |
16829 | 1512 |
|
1513 |
Year and month: |
|
1514 |
YYYY-MM (eg 1997-07) |
|
20200 | 1515 |
Date today printStringFormat:'%(year)-%(month)' |
1516 |
Timestamp now printStringFormat:'%(year)-%(month)' |
|
16829 | 1517 |
|
1518 |
Complete date: |
|
1519 |
YYYY-MM-DD (eg 1997-07-16) |
|
20200 | 1520 |
Date today printStringFormat:'%(year)-%(month)-%(day)' |
1521 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)' |
|
16829 | 1522 |
|
1523 |
Complete date plus hours and minutes: |
|
1524 |
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) |
|
20200 | 1525 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)' |
16829 | 1526 |
|
1527 |
Complete date plus hours, minutes and seconds: |
|
1528 |
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) |
|
20200 | 1529 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)' |
16829 | 1530 |
|
1531 |
Complete date plus hours, minutes, seconds and a decimal fraction of a second |
|
1532 |
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) |
|
20200 | 1533 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)' |
16829 | 1534 |
|
1535 |
" |
|
1536 |
||
22845 | 1537 |
|time hours minutes seconds millis micros nanos picos |
22626 | 1538 |
millisZ3 picosZ9 fract012 fract s t| |
16829 | 1539 |
|
23020 | 1540 |
aDictionary at:#'iso8601' put:[ self printStringIso8601 ]. |
1541 |
aDictionary at:#'iso8601_compact' put:[ self printStringIso8601Compressed ]. |
|
1542 |
||
16926 | 1543 |
time := self asTime. |
1544 |
hours := time hours. |
|
1545 |
minutes := time minutes. |
|
1546 |
seconds := time seconds. |
|
16829 | 1547 |
millis := self milliseconds. |
22626 | 1548 |
micros := self microseconds. |
22845 | 1549 |
nanos := self nanoseconds. |
22626 | 1550 |
picos := self picoseconds. |
16829 | 1551 |
|
1552 |
aDictionary at:$H put:(s := hours printString). |
|
1553 |
aDictionary at:$h put:(s leftPaddedTo:2 with:$0). |
|
1554 |
||
1555 |
aDictionary at:$M put:(s := minutes printString). |
|
1556 |
aDictionary at:$m put:(s leftPaddedTo:2 with:$0). |
|
1557 |
||
1558 |
aDictionary at:$S put:(s := seconds printString). |
|
1559 |
aDictionary at:$s put:(s leftPaddedTo:2 with:$0). |
|
1560 |
||
1561 |
aDictionary at:$I put:(s := millis printString). |
|
22626 | 1562 |
aDictionary at:#milli put:s. |
1563 |
aDictionary at:$i put:(millisZ3 := s leftPaddedTo:3 with:$0). |
|
1564 |
aDictionary at:#milli3 put:millisZ3. |
|
16829 | 1565 |
|
1566 |
aDictionary at:#milli1 put:((millis // 100) printString). |
|
1567 |
aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0). |
|
22995 | 1568 |
aDictionary at:#milliF1 put:((micros asFixedPoint:1) / 1000). |
1569 |
aDictionary at:#milliF2 put:((micros asFixedPoint:2) / 1000). |
|
1570 |
aDictionary at:#milliF3 put:((micros asFixedPoint:3) / 1000). |
|
23602 | 1571 |
aDictionary at:#milliF4 put:((nanos asFixedPoint:4) / 1000000). |
16829 | 1572 |
|
22626 | 1573 |
aDictionary at:$J put:(s := micros printString). |
1574 |
aDictionary at:#micro put:s. |
|
1575 |
aDictionary at:$j put:(t := s leftPaddedTo:6 with:$0). |
|
1576 |
aDictionary at:#micro6 put:t. |
|
22995 | 1577 |
aDictionary at:#microF1 put:((nanos asFixedPoint:1) / 1000). |
1578 |
aDictionary at:#microF2 put:((nanos asFixedPoint:2) / 1000). |
|
1579 |
aDictionary at:#microF3 put:((nanos asFixedPoint:3) / 1000). |
|
23602 | 1580 |
aDictionary at:#microF4 put:((picos asFixedPoint:4) / 1000000). |
22626 | 1581 |
|
22845 | 1582 |
aDictionary at:#nano put:(s := nanos printString). |
1583 |
aDictionary at:#nano9 put:(s leftPaddedTo:9 with:$0). |
|
1584 |
||
1585 |
aDictionary at:#pico put:(s := picos printString). |
|
1586 |
aDictionary at:#pico12 put:(s leftPaddedTo:12 with:$0). |
|
1587 |
||
22626 | 1588 |
picosZ9 := self picoseconds printString leftPaddedTo:9 with:$0. |
1589 |
fract012 := millisZ3,picosZ9. |
|
1590 |
fract := fract012 copyTo:(fract012 findLast:[:ch | ch ~~ $0] ifNone:12). |
|
1591 |
aDictionary at:$F put:fract. |
|
1592 |
aDictionary at:#fract put:fract. |
|
1593 |
||
16829 | 1594 |
aDictionary at:$t put:(seconds * minutes) printString. |
1595 |
aDictionary at:$T put:(seconds * minutes * hours) printString. |
|
1596 |
||
1597 |
" |
|
1598 |
|dict| |
|
1599 |
dict := Dictionary new. |
|
1600 |
Timestamp now addBasicPrintBindingsTo:dict language:#en. |
|
1601 |
dict inspect |
|
1602 |
" |
|
22626 | 1603 |
" |
1604 |
Timestamp now printStringFormat:'%(milli)' -- millis only |
|
1605 |
Timestamp now printStringFormat:'%(milli3)' -- millis padded |
|
1606 |
Timestamp now printStringFormat:'%(micro6)' -- micros padded |
|
1607 |
Timestamp now printStringFormat:'%(fract)' -- fraction part - as needed |
|
1608 |
Timestamp nowWithMicroseconds printStringFormat:'%(fract)' -- fraction part - as needed |
|
22995 | 1609 |
|
1610 |
(TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF1)ms' |
|
1611 |
(TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF2)ms' |
|
1612 |
(TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF3)ms' |
|
1613 |
(TimeDuration fromMicroseconds:30) printStringFormat:'%(milliF4)ms' |
|
23602 | 1614 |
(TimeDuration fromMicroseconds:3) printStringFormat:'%(milliF4)ms' |
1615 |
(TimeDuration fromNanoseconds:300) printStringFormat:'%(milliF4)us' |
|
22995 | 1616 |
|
1617 |
(TimeDuration fromNanoseconds:30) printStringFormat:'%(microF1)us' |
|
1618 |
(TimeDuration fromNanoseconds:30) printStringFormat:'%(microF2)us' |
|
1619 |
(TimeDuration fromNanoseconds:30) printStringFormat:'%(microF3)us' |
|
1620 |
(TimeDuration fromNanoseconds:30) printStringFormat:'%(microF4)us' |
|
23602 | 1621 |
(TimeDuration fromNanoseconds:3) printStringFormat:'%(microF4)us' |
1622 |
(TimeDuration fromPicoseconds:300) printStringFormat:'%(microF4)us' |
|
22626 | 1623 |
" |
22995 | 1624 |
|
23602 | 1625 |
"Modified (comment): / 14-01-2019 / 18:21:38 / Claus Gittinger" |
16829 | 1626 |
! |
1627 |
||
4844 | 1628 |
addPrintBindingsTo:aDictionary |
16829 | 1629 |
<resource: #obsolete> |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1630 |
|
16829 | 1631 |
self obsoleteMethodWarning:'use #addPrintBindingsTo:language:'. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1632 |
self addPrintBindingsTo:aDictionary language:nil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1633 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1634 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1635 |
addPrintBindingsTo:aDictionary language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
1636 |
"private print support: add bindings for printing to aDictionary. |
13175 | 1637 |
languageOrNil can be #en, #fr, #de or nil for the current language. |
1638 |
||
11772 | 1639 |
bindings: |
1640 |
%h hours, 00..23 (i.e. european) 0-padded to length 2 |
|
1641 |
%u hours, 00..12 (i.e. us) 0-padded to length 2 |
|
1642 |
%m minutes, 00..59 0-padded to length 2 |
|
1643 |
%s seconds, 00..59 0-padded to length 2 |
|
1644 |
%i milliseconds, 000..999 0-padded to length 3 |
|
1645 |
%a am/pm |
|
1646 |
||
1647 |
Timestamp only: |
|
1648 |
%(day) day, 00..31 0-padded to length 2 |
|
1649 |
%(month) month, 00..12 0-padded to length 2 |
|
1650 |
%(year) year, 4 digits 0-padded to length 4 |
|
1651 |
||
1652 |
special: |
|
1653 |
%H 24-hours - unpadded |
|
1654 |
%U 12-hours - unpadded |
|
1655 |
%M minutes - unpadded |
|
1656 |
%S seconds - unpadded |
|
1657 |
%I milliseconds, unpadded |
|
1658 |
%A AM/PM - uppercase |
|
1659 |
||
1660 |
%t seconds within hour (unpadded) |
|
1661 |
%T seconds from midNight (unpadded) |
|
1662 |
||
20200 | 1663 |
%(TZD) timeZone delta of the receiver from UTC in the format +/-hh:mm |
25315 | 1664 |
%(TZD822) timeZone delta of the receiver from UTC in the(RFC822-)format +/-hhmm |
11772 | 1665 |
|
20200 | 1666 |
%(milli1) milliseconds, truncated to 1/10th of a second 0..9 |
1667 |
%(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2 |
|
14493
0a3c9081d40a
changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents:
13701
diff
changeset
|
1668 |
%(milli3) milliseconds, same as %i for convenience |
11772 | 1669 |
|
1670 |
Timestamp only: |
|
20200 | 1671 |
%(Day) - day - unpadded |
1672 |
%(Month) - month - unpadded |
|
13175 | 1673 |
%(yearOrTime) - year or time 5 digits as in unix-ls: |
1674 |
year if it is not the current year; |
|
1675 |
time otherwise |
|
1676 |
%(weekDay) - day in week (1->monday, 2->tuesday, ... ,7->sunday) |
|
1677 |
||
20200 | 1678 |
%(dayName) - full day name |
1679 |
%(DayName) - full day name, first character uppercase |
|
1680 |
%(DAYNAME) - full day name, all uppercase |
|
13175 | 1681 |
|
20200 | 1682 |
%(monthName) - full month name |
1683 |
%(MonthName) - full month name, first character uppercase |
|
1684 |
%(MONTHNAME) - full month name, all uppercase |
|
13175 | 1685 |
|
20200 | 1686 |
%(shortDayName) - short (abbreviated) day name |
1687 |
%(ShortDayName) - short (abbreviated) day name, first character uppercase |
|
1688 |
%(SHORTDAYNAME) - short (abbreviated) day name, all uppercase |
|
13175 | 1689 |
|
20200 | 1690 |
%(shortMonthName) - short (abbreviated) month name |
1691 |
%(ShortMonthName) - short (abbreviated) month name, first character uppercase |
|
1692 |
%(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase |
|
13175 | 1693 |
|
20200 | 1694 |
%(nth) - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
1695 |
%(weekDayNth) - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
13175 | 1696 |
%(weekNth) - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
11772 | 1697 |
|
20200 | 1698 |
%(yearRoman) - year, in roman letters |
1699 |
%(monthRoman) - month, in roman letters |
|
17195 | 1700 |
|
11772 | 1701 |
|
1702 |
The ISO8601 printString are generated with: |
|
1703 |
||
1704 |
Year: |
|
1705 |
YYYY (eg 1997) |
|
1706 |
Date today printStringFormat:'%(year)' |
|
20200 | 1707 |
Timestamp now printStringFormat:'%(year)' |
11772 | 1708 |
|
1709 |
Year and month: |
|
1710 |
YYYY-MM (eg 1997-07) |
|
20200 | 1711 |
Date today printStringFormat:'%(year)-%(month)' |
1712 |
Timestamp now printStringFormat:'%(year)-%(month)' |
|
11772 | 1713 |
|
1714 |
Complete date: |
|
1715 |
YYYY-MM-DD (eg 1997-07-16) |
|
20200 | 1716 |
Date today printStringFormat:'%(year)-%(month)-%(day)' |
1717 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)' |
|
11772 | 1718 |
|
1719 |
Complete date plus hours and minutes: |
|
1720 |
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) |
|
20200 | 1721 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)' |
11772 | 1722 |
|
1723 |
Complete date plus hours, minutes and seconds: |
|
1724 |
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) |
|
20200 | 1725 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)' |
11772 | 1726 |
|
1727 |
Complete date plus hours, minutes, seconds and a decimal fraction of a second |
|
1728 |
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) |
|
20200 | 1729 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)' |
11772 | 1730 |
|
1731 |
" |
|
4844 | 1732 |
|
25315 | 1733 |
|usHours ampm s zone tzDelta s0 s1 s2 s822| |
4844 | 1734 |
|
16829 | 1735 |
self addBasicPrintBindingsTo:aDictionary language:languageOrNil. |
5968 | 1736 |
zone := self timeZoneName. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
1737 |
tzDelta := self timeZoneDeltaInMinutes. |
4844 | 1738 |
|
6419 | 1739 |
ampm := self meridianAbbreviation. |
16829 | 1740 |
usHours := self hour12 printString. |
1741 |
aDictionary at:$U put:usHours. |
|
1742 |
aDictionary at:$u put:(usHours leftPaddedTo:2 with:$0). |
|
14493
0a3c9081d40a
changed: #addPrintBindingsTo:language:
Claus Gittinger <cg@exept.de>
parents:
13701
diff
changeset
|
1743 |
|
12662 | 1744 |
aDictionary at:$a put:ampm. |
1745 |
aDictionary at:$A put:ampm asUppercase. |
|
1746 |
aDictionary at:$z put:zone. |
|
1747 |
aDictionary at:$Z put:zone asUppercase. |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
1748 |
|
9432 | 1749 |
tzDelta == 0 ifTrue:[ |
1750 |
s := 'Z'. |
|
25315 | 1751 |
s822 := '+0000' |
9432 | 1752 |
] ifFalse:[ |
25315 | 1753 |
s0 := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ]. |
9432 | 1754 |
tzDelta := tzDelta abs. |
25315 | 1755 |
|
1756 |
s1 := ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0). |
|
1757 |
s2 := ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0). |
|
1758 |
s := s0, s1, ':', s2. |
|
1759 |
s822 := s0, s1, s2. |
|
9432 | 1760 |
]. |
25315 | 1761 |
aDictionary at:#TZD822 put:s822. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
1762 |
aDictionary at:#TZD put:s |
13082 | 1763 |
|
1764 |
||
1765 |
" |
|
1766 |
|dict| |
|
1767 |
dict := Dictionary new. |
|
1768 |
Timestamp now addPrintBindingsTo:dict language:#en. |
|
1769 |
dict inspect |
|
1770 |
" |
|
25315 | 1771 |
|
1772 |
"Modified (format): / 03-03-2020 / 17:49:57 / Stefan Vogel" |
|
4844 | 1773 |
! |
1774 |
||
23020 | 1775 |
printIso8601CompressedOn:aStream |
1776 |
self subclassResponsibility |
|
1777 |
||
1778 |
" |
|
1779 |
Timestamp now printStringIso8601 -> '2018-05-09T12:15:53.279' |
|
1780 |
Time now printStringIso8601 -> 'T16:27:08' |
|
1781 |
Date today printStringIso8601 -> '2018-05-09' |
|
1782 |
||
1783 |
Timestamp now printStringIso8601Compressed -> '20180525T120822.699' |
|
1784 |
Time now printStringIso8601Compressed -> 'T120837' |
|
1785 |
Date today printStringIso8601Compressed -> '20180525' |
|
1786 |
" |
|
1787 |
||
1788 |
"Created: / 25-05-2018 / 12:08:07 / Claus Gittinger" |
|
1789 |
! |
|
1790 |
||
22826 | 1791 |
printIso8601FormatOn:aStream |
1792 |
self subclassResponsibility |
|
1793 |
||
1794 |
" |
|
22838 | 1795 |
Timestamp now printStringIso8601 -> '2018-05-09T12:15:53.279+02' |
1796 |
Time now printStringIso8601 -> 'T16:27:08' |
|
1797 |
Date today printStringIso8601 -> '2018-05-09' |
|
22826 | 1798 |
" |
1799 |
! |
|
1800 |
||
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1801 |
printOn:aStream format:aFormatString |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1802 |
"print using a format string; |
13175 | 1803 |
See #addPrintBindingsTo:language: for allowed format strings" |
7327 | 1804 |
|
13175 | 1805 |
self printOn:aStream format:aFormatString language:nil. |
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1806 |
|
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1807 |
" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1808 |
Timestamp now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1809 |
Time now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1810 |
Time now printOn:Transcript format:'%H:%m:%s' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1811 |
Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1812 |
Time now printOn:Transcript format:'%h:%m' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1813 |
Time now printOn:Transcript format:'%H:%m %A' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1814 |
Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1815 |
" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1816 |
|
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1817 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1818 |
! |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1819 |
|
13082 | 1820 |
printOn:aStream format:aFormatString language:languageString |
1821 |
"print using a format string; |
|
13175 | 1822 |
See #addPrintBindingsTo:language: for allowed format strings" |
13082 | 1823 |
|
1824 |
|dict| |
|
1825 |
||
23602 | 1826 |
"/ is this a good idea? |
1827 |
"/ aFormatString = '%h:%m:%s' ifTrue:[ |
|
1828 |
"/ "/ this is so common... |
|
1829 |
"/ aStream nextPutAll:(self hours printStringLeftPaddedTo:2 with:$0). |
|
1830 |
"/ aStream nextPutAll:':'. |
|
1831 |
"/ aStream nextPutAll:(self minutes printStringLeftPaddedTo:2 with:$0). |
|
1832 |
"/ aStream nextPutAll:':'. |
|
1833 |
"/ aStream nextPutAll:(self seconds printStringLeftPaddedTo:2 with:$0). |
|
1834 |
"/ ^ self |
|
1835 |
"/ ]. |
|
1836 |
||
13082 | 1837 |
dict := IdentityDictionary new. |
1838 |
self addPrintBindingsTo:dict language:languageString. |
|
1839 |
||
1840 |
aFormatString expandPlaceholdersWith:dict on:aStream |
|
1841 |
||
1842 |
" |
|
1843 |
Timestamp now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
|
1844 |
Time now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
|
1845 |
Time now printOn:Transcript format:'%H:%m:%s' . Transcript cr. |
|
1846 |
Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr. |
|
1847 |
Time now printOn:Transcript format:'%h:%m' . Transcript cr. |
|
1848 |
Time now printOn:Transcript format:'%H:%m %A' . Transcript cr. |
|
1849 |
Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr. |
|
1850 |
" |
|
1851 |
||
23602 | 1852 |
"Modified: / 22-02-1996 / 16:58:30 / cg" |
1853 |
"Modified: / 14-01-2019 / 18:22:12 / Claus Gittinger" |
|
13082 | 1854 |
! |
1855 |
||
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1856 |
printStringFormat:aFormatString |
13175 | 1857 |
"print using a format string. |
1858 |
See #addPrintBindingsTo:language: for allowed format strings" |
|
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1859 |
|
13175 | 1860 |
^ self printStringFormat:aFormatString language:nil. |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1861 |
|
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1862 |
" |
17400 | 1863 |
Timestamp now printStringFormat:'%U:%m:%s %a' |
1864 |
Timestamp now printStringFormat:'%u:%m:%s %a' |
|
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1865 |
Time now printStringFormat:'%U:%m:%s %a' |
17400 | 1866 |
Time now printStringFormat:'%u:%m:%s %a' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1867 |
|
4844 | 1868 |
Time now printStringFormat:'%h:%m:%s' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1869 |
Time now printStringFormat:'%H:%m:%s' |
4844 | 1870 |
Time now printStringFormat:'%H:%m:%s.%i' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1871 |
Timestamp now printStringFormat:'%H:%m:%s.%i' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1872 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli1)' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1873 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli2)' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1874 |
Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1875 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1876 |
Time now printStringFormat:'%u:%m:%s %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1877 |
Time now printStringFormat:'%h:%m' |
4844 | 1878 |
Time now printStringFormat:'%h:%m' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1879 |
Time now printStringFormat:'%H:%m %A' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1880 |
Time now printStringFormat:'%m minutes after %U %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1881 |
Time now printStringFormat:'%t seconds after %U %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1882 |
Time now printStringFormat:'%T seconds from midNight' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1883 |
" |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1884 |
|
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1885 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
13082 | 1886 |
! |
1887 |
||
1888 |
printStringFormat:aFormatString language:languageString |
|
13175 | 1889 |
"print using a format string. |
1890 |
See #addPrintBindingsTo:language: for allowed format strings" |
|
13082 | 1891 |
|
1892 |
|s| |
|
1893 |
||
16829 | 1894 |
s := CharacterWriteStream on:(String new:20). |
13082 | 1895 |
self printOn:s format:aFormatString language:languageString. |
1896 |
^ s contents. |
|
1897 |
||
1898 |
" |
|
1899 |
Timestamp now printStringFormat:'%U:%m:%s %a |
|
1900 |
Time now printStringFormat:'%U:%m:%s %a' |
|
1901 |
||
1902 |
Time now printStringFormat:'%h:%m:%s' |
|
1903 |
Time now printStringFormat:'%H:%m:%s' |
|
1904 |
Time now printStringFormat:'%H:%m:%s.%i' |
|
1905 |
Timestamp now printStringFormat:'%H:%m:%s.%i' |
|
1906 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli1)' |
|
1907 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli2)' |
|
1908 |
Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s' |
|
13175 | 1909 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#en |
1910 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#de |
|
1911 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#fr |
|
13082 | 1912 |
Time now printStringFormat:'%u:%m:%s %a' |
1913 |
Time now printStringFormat:'%h:%m' |
|
1914 |
Time now printStringFormat:'%h:%m' |
|
1915 |
Time now printStringFormat:'%H:%m %A' |
|
1916 |
Time now printStringFormat:'%m minutes after %U %a' |
|
1917 |
Time now printStringFormat:'%t seconds after %U %a' |
|
1918 |
Time now printStringFormat:'%T seconds from midNight' |
|
1919 |
" |
|
1920 |
||
1921 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
|
22826 | 1922 |
! |
1923 |
||
22836 | 1924 |
printStringIso8601 |
22826 | 1925 |
"return the Iso8601 representation of the receiver with local timezon information. |
1926 |
This format looks like: |
|
22836 | 1927 |
1999-01-01T24:00:00 |
22826 | 1928 |
or, for zero hr:min:sec, |
22836 | 1929 |
1999-01-01 |
22826 | 1930 |
Of course, a 24 hour clock is used." |
1931 |
||
1932 |
^ String streamContents:[:s | self printIso8601FormatOn:s] |
|
1933 |
||
1934 |
" |
|
23020 | 1935 |
Timestamp now printStringIso8601 |
22826 | 1936 |
" |
23020 | 1937 |
|
1938 |
"Modified (comment): / 25-05-2018 / 11:58:37 / Claus Gittinger" |
|
1939 |
! |
|
1940 |
||
1941 |
printStringIso8601Compressed |
|
1942 |
"return the Iso8601 representation of the receiver with local timezon information. |
|
1943 |
This format looks like: |
|
1944 |
1999-01-01T24:00:00 |
|
1945 |
or, for zero hr:min:sec, |
|
1946 |
1999-01-01 |
|
1947 |
Of course, a 24 hour clock is used." |
|
1948 |
||
1949 |
^ String streamContents:[:s | self printIso8601CompressedOn:s] |
|
1950 |
||
1951 |
" |
|
1952 |
Timestamp now printStringIso8601Compressed |
|
1953 |
" |
|
1954 |
||
1955 |
"Created: / 25-05-2018 / 11:58:29 / Claus Gittinger" |
|
22836 | 1956 |
! |
1957 |
||
1958 |
printStringIso8601Format |
|
22925 | 1959 |
"would like to make it obsolete, but it is:" |
1960 |
<resource: #EXPECCO_API> |
|
1961 |
"<resource: #obsolete>" |
|
22836 | 1962 |
|
1963 |
"return the Iso8601 representation of the receiver with local timezon information. |
|
1964 |
This format looks like: |
|
1965 |
1999-01-01T24:00:00 |
|
1966 |
or, for zero hr:min:sec, |
|
1967 |
1999-01-01 |
|
1968 |
Of course, a 24 hour clock is used." |
|
1969 |
||
22925 | 1970 |
"/ self obsoleteMethodWarning:'use printStringIso8601'. |
22836 | 1971 |
^ self printStringIso8601 |
1972 |
||
1973 |
" |
|
1974 |
Timestamp now printStringIso8601Format |
|
1975 |
" |
|
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1976 |
! ! |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1977 |
|
699 | 1978 |
!AbstractTime methodsFor:'private'! |
240 | 1979 |
|
22836 | 1980 |
additionalPicoseconds |
1981 |
"return the additional picoseconds within the current second (0..999999999). |
|
1982 |
Here, assume that we have none" |
|
1983 |
||
1984 |
^ 0. |
|
1985 |
||
1986 |
" |
|
1987 |
Timestamp now picoseconds |
|
1988 |
" |
|
1989 |
! |
|
1990 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1991 |
fromOSTime:osTime |
699 | 1992 |
"set my time, from operatingSystems time parts" |
240 | 1993 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1994 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1995 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1996 |
"Modified: 1.7.1996 / 15:09:44 / cg" |
240 | 1997 |
! |
1998 |
||
22618 | 1999 |
fromOSTimeWithMilliseconds:anUninterpretedOSTime |
2000 |
"strictly private: set the milliseconds from an OS time (since the epoch)" |
|
2001 |
||
2002 |
self subclassResponsibility |
|
2003 |
! |
|
2004 |
||
22945 | 2005 |
getMicroseconds |
2006 |
"get the milliseconds since some point of time in the past. |
|
2007 |
Since I am abstract (not knowing how the time is actually |
|
2008 |
represented), this must be done by a concrete class. |
|
2009 |
Also be aware that the returned value is concrete-class specific; |
|
2010 |
Time returns the micros since midnight, Timestamp since the epoch. |
|
2011 |
Use this only to compute relative time deltas. |
|
2012 |
Here is a fallback, which only returns milliseocnd precision values" |
|
2013 |
||
2014 |
^ self getMilliseconds * 1000 |
|
2015 |
! |
|
2016 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2017 |
getMilliseconds |
8200 | 2018 |
"get the milliseconds since some point of time in the past. |
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2019 |
Since I am abstract (not knowing how the time is actually |
22836 | 2020 |
represented), this must be done by a concrete class. |
2021 |
Also be aware that the returned value is concrete-class specific; |
|
2022 |
Time returns the millis since midnight, Timestamp since the epoch. |
|
2023 |
Use this only to compute relative time deltas." |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2024 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2025 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2026 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2027 |
"Created: 1.7.1996 / 14:16:49 / cg" |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2028 |
! |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2029 |
|
699 | 2030 |
getSeconds |
22283 | 2031 |
"get the (truncated) seconds since some point of time in the past. |
699 | 2032 |
Since I am abstract (not knowing how the time is actually |
2033 |
represented), this must be done by a concrete class." |
|
240 | 2034 |
|
699 | 2035 |
^ self subclassResponsibility |
22283 | 2036 |
|
2037 |
"Modified (comment): / 21-09-2017 / 18:50:30 / cg" |
|
699 | 2038 |
! |
2039 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2040 |
setMilliseconds:millis |
8200 | 2041 |
"set the milliseconds since some point of time in the past. |
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2042 |
Since I am abstract (not knowing how the time is actually |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2043 |
represented), this must be done by a concrete class." |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2044 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2045 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2046 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2047 |
"Created: 1.7.1996 / 14:17:00 / cg" |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2048 |
! |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2049 |
|
23235 | 2050 |
setMilliseconds:arg1 additionalPicoseconds:arg2 |
2051 |
"raise an error: must be redefined in concrete subclass(es)" |
|
2052 |
||
2053 |
^ self subclassResponsibility |
|
2054 |
! |
|
2055 |
||
699 | 2056 |
setSeconds:secs |
8200 | 2057 |
"set the seconds since some point of time in the past. |
699 | 2058 |
Since I am abstract (not knowing how the time is actually |
2059 |
represented), this must be done by a concrete class." |
|
2060 |
||
2061 |
^ self subclassResponsibility |
|
17015 | 2062 |
! |
2063 |
||
2064 |
speciesNew |
|
2065 |
^ self species basicNew |
|
240 | 2066 |
! ! |
2067 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
2068 |
!AbstractTime class methodsFor:'documentation'! |
240 | 2069 |
|
699 | 2070 |
version |
18918 | 2071 |
^ '$Header$' |
12660 | 2072 |
! |
2073 |
||
2074 |
version_CVS |
|
18918 | 2075 |
^ '$Header$' |
240 | 2076 |
! ! |
15684 | 2077 |