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