author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 18 Jul 2011 16:22:09 +0100 | |
branch | jv |
changeset 17846 | 24edc476ac18 |
parent 17845 | 7e0cfaac936d |
child 17862 | 8a8ae3107950 |
permissions | -rw-r--r-- |
240 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
7010 | 3 |
All Rights Reserved |
240 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5548 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
240 | 14 |
Magnitude subclass:#AbstractTime |
7258 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
7672 | 18 |
category:'Magnitude-Time' |
240 | 19 |
! |
20 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
21 |
!AbstractTime class methodsFor:'documentation'! |
240 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
7010 | 26 |
All Rights Reserved |
240 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
There are no instances of this class in the system. |
275 | 42 |
It is meant as a home for methods common to time handling classes. |
1282 | 43 |
|
1295 | 44 |
[author:] |
45 |
Claus Gittinger |
|
46 |
||
1282 | 47 |
[See also:] |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
48 |
Time Date Timestamp |
1282 | 49 |
Delay ProcessorScheduler |
240 | 50 |
" |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
51 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
52 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
53 |
iso8601Format |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
54 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
55 |
Abstract |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
56 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
most requirements. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
61 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
62 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
63 |
Formats |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
64 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
of comparing two dates with different precisions. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
69 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
70 |
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
|
71 |
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
|
72 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
73 |
Year: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
74 |
YYYY (eg 1997) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
75 |
Year and month: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
76 |
YYYY-MM (eg 1997-07) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
77 |
Complete date: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
78 |
YYYY-MM-DD (eg 1997-07-16) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
79 |
Complete date plus hours and minutes: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
80 |
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
|
81 |
Complete date plus hours, minutes and seconds: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
second |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
85 |
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
|
86 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
87 |
where: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
88 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
89 |
YYYY = four-digit year |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
90 |
MM = two-digit month (01=January, etc.) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
102 |
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
|
103 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
'+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
|
107 |
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
|
108 |
'mm' minutes behind UTC. |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
109 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
110 |
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
|
111 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
112 |
The ISO8601 printString are generated with: |
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 |
Year: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
115 |
YYYY (eg 1997) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
116 |
Date today printStringFormat:'%(year)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
117 |
Timestamp now printStringFormat:'%(year)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
118 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
119 |
Year and month: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
120 |
YYYY-MM (eg 1997-07) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
121 |
Date today printStringFormat:'%(year)-%(month)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
122 |
Timestamp now printStringFormat:'%(year)-%(month)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
123 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
124 |
Complete date: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
125 |
YYYY-MM-DD (eg 1997-07-16) |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
126 |
Date today printStringFormat:'%(year)-%(month)-%(day)' |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
127 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)' |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
128 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
129 |
Complete date plus hours and minutes: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
130 |
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
|
131 |
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
|
132 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
133 |
Complete date plus hours, minutes and seconds: |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
" |
240 | 141 |
! ! |
142 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
143 |
!AbstractTime class methodsFor:'instance creation'! |
240 | 144 |
|
699 | 145 |
dateAndTimeNow |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
146 |
"return an array filled with the current date and time. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
147 |
See also: Date today / Time now / Timestamp now." |
240 | 148 |
|
699 | 149 |
^ Array with:(Date today) with:(Time now) |
240 | 150 |
|
151 |
" |
|
699 | 152 |
Time dateAndTimeNow |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
153 |
Date dateAndTimeNow |
240 | 154 |
" |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
155 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
156 |
"Modified: 19.4.1996 / 15:23:37 / cg" |
275 | 157 |
! |
240 | 158 |
|
9432 | 159 |
epoch |
160 |
"answer the time when we start counting" |
|
161 |
||
162 |
^ self new setSeconds:0 |
|
163 |
||
164 |
" |
|
165 |
Timestamp epoch |
|
166 |
Time epoch |
|
167 |
" |
|
168 |
! |
|
169 |
||
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
170 |
now |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
171 |
"return an instance of myself representing this moment." |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
172 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
173 |
^ self basicNew fromOSTime:(OperatingSystem getOSTime) |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
174 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
175 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
176 |
Timestamp now |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
177 |
Time now |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
178 |
" |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
179 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
180 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
17815 | 181 |
! |
182 |
||
183 |
utcNow |
|
184 |
"return an instance of myself representing this momentin the UTC timezone." |
|
185 |
||
186 |
^ self subclassResponsibility |
|
187 |
||
188 |
" |
|
189 |
Timestamp utcNow |
|
190 |
Timestamp utcNow |
|
191 |
||
192 |
Time now |
|
193 |
Time utcNow |
|
194 |
" |
|
195 |
||
196 |
"Modified: 1.7.1996 / 15:20:10 / cg" |
|
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
197 |
! ! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
198 |
|
7294 | 199 |
!AbstractTime class methodsFor:'Compatibility-Squeak'! |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
200 |
|
9432 | 201 |
dateAndTimeFromSeconds:secondCount |
202 |
"set date and time from seconds since 1901-01-01 00:00 UTC" |
|
203 |
||
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
204 |
|timestamp| |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
205 |
|
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
206 |
" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
207 |
secondsBetween1901and1970 := |
9432 | 208 |
(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
|
209 |
* (24 * 60 * 60) |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
210 |
" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
211 |
|
9432 | 212 |
"stc cannot make large integers" |
9449
6ba774be6aa1
stc can compile large integers!
Stefan Vogel <sv@exept.de>
parents:
9432
diff
changeset
|
213 |
timestamp := Timestamp fromSeconds:secondCount - 2177452800. |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
214 |
^ Array |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
215 |
with: (timestamp asDate) |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
216 |
with: (timestamp asTime) |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
217 |
|
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
218 |
" |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
219 |
Timestamp dateAndTimeFromSeconds: (Time primSecondsClock) |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
220 |
Time dateAndTimeFromSeconds: (Time totalSeconds) |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
221 |
Date dateAndTimeFromSeconds: (Time totalSeconds) |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
222 |
" |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
223 |
! |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
224 |
|
11528 | 225 |
milliseconds:msTime1 since:msTime2 |
226 |
"return the number of milliseconds between two |
|
227 |
millisecond time values, compensating for roll-over. |
|
228 |
The same as millisecondsBetween:and: for Squeak compatibility." |
|
229 |
||
230 |
^ OperatingSystem millisecondTimeDeltaBetween:msTime1 and:msTime2 |
|
231 |
! |
|
232 |
||
9926 | 233 |
millisecondsSince: lastTime |
234 |
"Answer the elapsed time since last recorded in milliseconds. |
|
235 |
Compensate for rollover." |
|
236 |
||
237 |
^self milliseconds: self millisecondClockValue since: lastTime |
|
238 |
! |
|
239 |
||
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
240 |
primSecondsClock |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
241 |
"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
|
242 |
|
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
243 |
^ Timestamp now utcSecondsSince1901 |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
244 |
|
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
245 |
" |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
246 |
Timestamp primSecondsClock |
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
247 |
" |
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 |
|
7294 | 250 |
!AbstractTime class methodsFor:'Compatibility-VW'! |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
251 |
|
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
252 |
totalSeconds |
9429
173bcd493d7c
Fix for utc botch when retrieving seconds since 1901
Stefan Vogel <sv@exept.de>
parents:
8586
diff
changeset
|
253 |
"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
|
254 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
255 |
^ Timestamp now utcSecondsSince1901 |
7007
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
256 |
! ! |
9af8cc2f82a4
totalSeconds returns the number of seconds since 1.1.1901 now
penk
parents:
6888
diff
changeset
|
257 |
|
11130 | 258 |
!AbstractTime class methodsFor:'error handling'! |
259 |
||
260 |
conversionErrorSignal |
|
261 |
"return the signal used for conversion error handling" |
|
262 |
||
263 |
^ TimeConversionError |
|
264 |
! ! |
|
265 |
||
7258 | 266 |
!AbstractTime class methodsFor:'private-instance creation'! |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
267 |
|
275 | 268 |
fromOSTime:osTime |
269 |
"return a time, representing the time given by the operatingSystem time. |
|
270 |
Not meant for public use." |
|
271 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
272 |
^ self basicNew fromOSTime:osTime. |
418 | 273 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
274 |
"Modified: 1.7.1996 / 15:09:54 / cg" |
240 | 275 |
! |
276 |
||
699 | 277 |
fromSeconds:seconds |
278 |
"return an instance that is constructed from seconds. |
|
279 |
This method is only allowed for second values as returned by |
|
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
280 |
getSeconds, possibly adding/subtracting to that. |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
281 |
Never depend on any specific interpretation of the seconds, |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
282 |
since it depends on how the OperatingSystem counts time |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
283 |
(some start at 1900, others with 1970 ...)" |
240 | 284 |
|
699 | 285 |
^ self basicNew setSeconds:seconds |
240 | 286 |
|
287 |
" |
|
699 | 288 |
Time fromSeconds:0 should return midnight |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
289 |
Timestamp fromSeconds:0 on UNIX: returns 1st. Jan 1970 |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
699
diff
changeset
|
290 |
on others: dont know |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
291 |
(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
|
292 |
getSeconds on UNIX: returns 0 |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
293 |
on others: dont know |
699 | 294 |
" |
295 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
296 |
"Modified: 1.7.1996 / 13:39:30 / cg" |
240 | 297 |
! ! |
298 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
299 |
!AbstractTime class methodsFor:'queries'! |
275 | 300 |
|
699 | 301 |
millisecondClockValue |
302 |
"return the millisecond clock - since this one overruns |
|
303 |
regularly, use the value only for short timing deltas. |
|
5730 | 304 |
Also remember that it wraps when comparing these values." |
275 | 305 |
|
699 | 306 |
^ OperatingSystem getMillisecondTime. |
307 |
||
308 |
" |
|
309 |
Time millisecondClockValue |
|
310 |
" |
|
275 | 311 |
! |
312 |
||
699 | 313 |
secondClock |
314 |
"return seconds of now - for GNU-ST compatibility" |
|
315 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
316 |
^ OperatingSystem getOSTime // 1000 |
699 | 317 |
|
318 |
" |
|
319 |
AbstractTime secondClock |
|
320 |
" |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
321 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
322 |
"Modified: 1.7.1996 / 15:20:14 / cg" |
699 | 323 |
! ! |
324 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
325 |
!AbstractTime class methodsFor:'timing evaluations'! |
275 | 326 |
|
17757 | 327 |
microsecondsToRun:aBlock |
328 |
"evaluate the argument, aBlock; return the number of milliseconds it took" |
|
329 |
||
330 |
|startTime endTime| |
|
331 |
||
332 |
startTime := OperatingSystem getMicrosecondTime. |
|
333 |
aBlock value. |
|
334 |
endTime := OperatingSystem getMicrosecondTime. |
|
335 |
^ endTime - startTime |
|
336 |
||
337 |
" |
|
338 |
Time microsecondsToRun:[1000 factorial] |
|
339 |
" |
|
340 |
! |
|
341 |
||
699 | 342 |
millisecondsToRun:aBlock |
343 |
"evaluate the argument, aBlock; return the number of milliseconds it took" |
|
344 |
||
345 |
|startTime endTime| |
|
346 |
||
1476 | 347 |
startTime := OperatingSystem getMillisecondTime. |
699 | 348 |
aBlock value. |
1476 | 349 |
endTime := OperatingSystem getMillisecondTime. |
8586
a38e882affa5
take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents:
8450
diff
changeset
|
350 |
^ self milliseconds:endTime since:startTime |
699 | 351 |
|
352 |
" |
|
8586
a38e882affa5
take care of time-wrap in #millisecondsToRun:
Stefan Vogel <sv@exept.de>
parents:
8450
diff
changeset
|
353 |
Time millisecondsToRun:[1000 factorial] |
699 | 354 |
" |
1476 | 355 |
|
356 |
"Modified: 17.6.1996 / 16:57:37 / cg" |
|
275 | 357 |
! |
358 |
||
699 | 359 |
secondsToRun:aBlock |
360 |
"evaluate the argument, aBlock; return the number of seconds it took" |
|
361 |
||
362 |
|startTime endTime| |
|
360 | 363 |
|
699 | 364 |
startTime := self secondClock. |
365 |
aBlock value. |
|
366 |
endTime := self secondClock. |
|
367 |
^ endTime - startTime |
|
275 | 368 |
|
699 | 369 |
" |
370 |
Time secondsToRun:[1000 factorial] |
|
371 |
" |
|
275 | 372 |
! ! |
373 |
||
7261 | 374 |
!AbstractTime methodsFor:'Compatibility-ANSI'! |
6419 | 375 |
|
376 |
hour12 |
|
377 |
"return the hour (1..12)." |
|
378 |
||
379 |
^ self hours - 1 \\ 12 + 1. |
|
380 |
||
381 |
" |
|
382 |
Time now hour12 |
|
383 |
Time now hour24 |
|
384 |
(Time hours:0 minutes:0 seconds:0) hour24 |
|
385 |
(Time hours:0 minutes:0 seconds:0) hour12 |
|
386 |
(Time hours:1 minutes:0 seconds:0) hour24 |
|
387 |
(Time hours:1 minutes:0 seconds:0) hour12 |
|
388 |
(Time hours:12 minutes:0 seconds:0) hour24 |
|
389 |
(Time hours:12 minutes:0 seconds:0) hour12 |
|
390 |
(Time hours:13 minutes:0 seconds:0) hour24 |
|
391 |
(Time hours:13 minutes:0 seconds:0) hour12 |
|
392 |
(Time hours:23 minutes:0 seconds:0) hour24 |
|
393 |
(Time hours:23 minutes:0 seconds:0) hour12 |
|
394 |
(Time hours:24 minutes:0 seconds:0) hour24 |
|
395 |
(Time hours:24 minutes:0 seconds:0) hour12 |
|
396 |
" |
|
397 |
! |
|
398 |
||
399 |
hour24 |
|
400 |
"return the hour (0..23)." |
|
401 |
||
402 |
^ self hours |
|
403 |
||
404 |
" |
|
405 |
Time now hour12 |
|
406 |
Time now hour24 |
|
407 |
(Time hours:0 minutes:0 seconds:0) hour24 |
|
408 |
(Time hours:0 minutes:0 seconds:0) hour12 |
|
409 |
(Time hours:1 minutes:0 seconds:0) hour24 |
|
410 |
(Time hours:1 minutes:0 seconds:0) hour12 |
|
411 |
(Time hours:12 minutes:0 seconds:0) hour24 |
|
412 |
(Time hours:12 minutes:0 seconds:0) hour12 |
|
413 |
(Time hours:13 minutes:0 seconds:0) hour24 |
|
414 |
(Time hours:13 minutes:0 seconds:0) hour12 |
|
415 |
(Time hours:23 minutes:0 seconds:0) hour24 |
|
416 |
(Time hours:23 minutes:0 seconds:0) hour12 |
|
417 |
(Time hours:24 minutes:0 seconds:0) hour24 |
|
418 |
(Time hours:24 minutes:0 seconds:0) hour12 |
|
419 |
" |
|
420 |
! |
|
421 |
||
422 |
meridianAbbreviation |
|
423 |
"am/pm" |
|
424 |
||
425 |
self hours // 12 == 0 ifTrue:[ |
|
426 |
^ 'am'. |
|
427 |
] ifFalse:[ |
|
8200 | 428 |
(self hours == 12 and:[self minutes == 0 and:[self seconds == 0]]) ifTrue:[ |
429 |
^ 'noon' |
|
430 |
]. |
|
6419 | 431 |
^ 'pm'. |
432 |
]. |
|
433 |
||
434 |
" |
|
435 |
Time now meridianAbbreviation |
|
436 |
(Time hours:0 minutes:0 seconds:0) meridianAbbreviation |
|
437 |
(Time hours:11 minutes:59 seconds:59) meridianAbbreviation |
|
438 |
(Time hours:12 minutes:0 seconds:0) meridianAbbreviation |
|
439 |
(Time hours:12 minutes:0 seconds:1) meridianAbbreviation |
|
440 |
" |
|
441 |
! ! |
|
442 |
||
17845 | 443 |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
444 |
!AbstractTime methodsFor:'abstract'! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
445 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
446 |
hours |
8200 | 447 |
"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
|
448 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
449 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
450 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
451 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
452 |
Timestamp now hours |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
453 |
Time now hours |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
454 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
455 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
456 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
457 |
milliseconds |
8200 | 458 |
"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
|
459 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
460 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
461 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
462 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
463 |
Timestamp now milliseconds |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
464 |
Time now milliseconds |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
465 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
466 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
467 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
468 |
minutes |
8200 | 469 |
"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
|
470 |
|
7672 | 471 |
^ self subclassResponsibility. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
472 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
473 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
474 |
Timestamp now minutes |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
475 |
Time now minutes |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
476 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
477 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
478 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
479 |
seconds |
8200 | 480 |
"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
|
481 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
482 |
^ self subclassResponsibility |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
483 |
|
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
484 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
485 |
Timestamp now seconds. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
486 |
Time now seconds |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
487 |
" |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
488 |
! ! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
489 |
|
275 | 490 |
!AbstractTime methodsFor:'accessing'! |
491 |
||
492 |
hourInDay |
|
493 |
"return the hours (0..23)" |
|
494 |
||
495 |
^ self hours |
|
496 |
||
497 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
498 |
Timestamp now hourInDay |
275 | 499 |
Time now hourInDay |
500 |
" |
|
501 |
! |
|
502 |
||
503 |
minuteInDay |
|
504 |
"return the minutes (0..59)" |
|
505 |
||
506 |
^ self minutes. |
|
507 |
||
508 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
509 |
Timestamp now minuteInDay |
275 | 510 |
Time now minuteInDay |
511 |
" |
|
512 |
! |
|
513 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
514 |
secondInDay |
275 | 515 |
"return the seconds (0..59)" |
516 |
||
517 |
^ self seconds |
|
518 |
||
519 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
520 |
Timestamp now secondInDay |
275 | 521 |
Time now seconds |
522 |
" |
|
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
523 |
|
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
524 |
"Created: 22.10.1996 / 09:27:47 / stefan" |
5548 | 525 |
! |
526 |
||
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
527 |
timeZoneDeltaInMinutes |
9432 | 528 |
"answer the number of minutes between local time and utc time. |
529 |
Delta is positive if local time is ahead of utc, negative if behind utc." |
|
530 |
||
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
531 |
^ 0 |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
532 |
! |
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
533 |
|
5968 | 534 |
timeZoneName |
10485 | 535 |
^ #utc |
275 | 536 |
! ! |
537 |
||
538 |
!AbstractTime methodsFor:'arithmetic'! |
|
539 |
||
10679 | 540 |
+ aNumberOrTimeDuration |
541 |
"Add aNumber numberOfSeconds or, if its a timeDuration, add its value" |
|
8200 | 542 |
|
10679 | 543 |
^ aNumberOrTimeDuration sumFromTimestamp:self. |
544 |
||
545 |
"/ ^ self species basicNew |
|
546 |
"/ setMilliseconds:(self getMilliseconds + (aNumberOrTimeDuration * 1000) asInteger) |
|
8200 | 547 |
|
548 |
" |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
549 |
Timestamp now to:(Timestamp now + 30) by:2 do:[:time| |
8200 | 550 |
Transcript showCR:time. |
551 |
]. |
|
552 |
||
10679 | 553 |
(Timestamp now + 20) - Timestamp now |
554 |
(Timestamp now + 0.5) - Timestamp now |
|
555 |
(Timestamp now + (TimeDuration fromString:'1m 10s')) - Timestamp now |
|
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
556 |
(Timestamp now + (10 seconds)) - Timestamp now |
8200 | 557 |
" |
558 |
! |
|
559 |
||
560 |
- aTimeOrNumberOfSeconds |
|
8244 | 561 |
"return the delta in seconds between 2 times or subtract a number of seconds." |
275 | 562 |
|
11515 | 563 |
"/ aTimeOrNumberOfSeconds isNumber ifTrue:[ |
564 |
"/ ^ self species basicNew |
|
565 |
"/ setMilliseconds:(self getMilliseconds - (aTimeOrNumberOfSeconds * 1000) asInteger) |
|
566 |
"/ ]. |
|
567 |
"/ ^ self getSeconds - aTimeOrNumberOfSeconds getSeconds |
|
568 |
^ aTimeOrNumberOfSeconds differenceFromTimestamp:self. |
|
275 | 569 |
|
570 |
" |
|
11518 | 571 |
Timestamp now - 3600. |
11515 | 572 |
Time now - 3600. |
11518 | 573 |
(Time now addSeconds:10) - Time now |
11515 | 574 |
(TimeDuration fromString:'1.5hr') - 3600. |
575 |
(TimeDuration fromString:'1.5hr') - (TimeDuration fromString:'1hr') |
|
8200 | 576 |
|
275 | 577 |
|t1 t2| |
578 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
579 |
t1 := Timestamp now. |
275 | 580 |
(Delay forSeconds:5) wait. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
581 |
t2 := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
582 |
Transcript showCR:('seconds passed: ' , (t2 - t1) printString). |
275 | 583 |
" |
584 |
! |
|
585 |
||
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
586 |
addDays:numberOfDays |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
587 |
"return a new instance of myself, numberOfDays afterwards." |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
588 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
589 |
^ self addSeconds:(numberOfDays * (60 * 60 * 24)) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
590 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
591 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
592 |
|t| |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
593 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
594 |
t := Timestamp now. |
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
595 |
Transcript showCR:t. |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
596 |
Transcript showCR:(t addDays:7) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
597 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
598 |
! |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
599 |
|
699 | 600 |
addHours:numberOfHours |
601 |
"return a new instance of myself, numberOfHours afterwards." |
|
275 | 602 |
|
699 | 603 |
^ self addSeconds:(numberOfHours * (60 * 60)) |
275 | 604 |
|
605 |
" |
|
606 |
|t| |
|
607 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
608 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
609 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
610 |
Transcript showCR:(t addHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
611 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
612 |
|
275 | 613 |
" |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
614 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
615 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
616 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
617 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
618 |
Transcript showCR:(t addHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
619 |
" |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
620 |
! |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
621 |
|
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
622 |
addMilliseconds:numberOfMilliSeconds |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
623 |
"return a new instance of myself, numberOfMilliSeconds afterwards." |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
624 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
625 |
^ self species basicNew |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
626 |
setMilliseconds:(self getMilliseconds + numberOfMilliSeconds) |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
627 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
628 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
629 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
630 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
631 |
t := Timestamp now. |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
632 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
633 |
Transcript showCR:(t addMilliseconds:100). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
634 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
635 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
636 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
637 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
638 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
639 |
t := Time now. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
640 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
641 |
Transcript showCR:(t addMilliseconds:1000). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
642 |
" |
275 | 643 |
! |
644 |
||
645 |
addMinutes:numberOfMinutes |
|
646 |
"return a new instance of myself, numberOfMinutes afterwards." |
|
647 |
||
648 |
^ self addSeconds:(numberOfMinutes * 60) |
|
649 |
||
650 |
" |
|
651 |
|t| |
|
652 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
653 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
654 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
655 |
Transcript showCR:(t addMinutes:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
656 |
" |
275 | 657 |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
658 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
659 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
660 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
661 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
662 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
663 |
Transcript showCR:(t addMinutes:60). |
275 | 664 |
" |
665 |
! |
|
666 |
||
699 | 667 |
addSeconds:numberOfSeconds |
668 |
"return a new instance of myself, numberOfSeconds afterwards." |
|
669 |
||
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
670 |
^ self species basicNew |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
671 |
setMilliseconds:(self getMilliseconds + (numberOfSeconds * 1000)) |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
672 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
673 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
674 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
675 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
676 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
677 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
678 |
Transcript showCR:(t addSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
679 |
" |
699 | 680 |
|
681 |
" |
|
682 |
|t| |
|
683 |
||
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
684 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
685 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
686 |
Transcript showCR:(t addSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
687 |
" |
699 | 688 |
! |
689 |
||
690 |
addTime:timeAmount |
|
691 |
"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
|
692 |
Provided for ST-80 compatibility. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
693 |
WARNING: |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
694 |
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
|
695 |
a numberOfSeconds as argument. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
696 |
Use any of addSeconds/addHours etc. to make things clear" |
699 | 697 |
|
6888
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
698 |
timeAmount isNumber ifFalse:[ |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
699 |
^ self addSeconds:(timeAmount asSeconds). |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
700 |
]. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
701 |
^ self addSeconds:timeAmount |
699 | 702 |
! |
703 |
||
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
704 |
subtractDays:numberOfDays |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
705 |
"return a new instance of myself, numberOfDays before." |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
706 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
707 |
^ self subtractSeconds:(numberOfDays * (60 * 60 * 24)) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
708 |
|
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
709 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
710 |
|t| |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
711 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
712 |
t := Timestamp now. |
6048
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
713 |
Transcript showCR:t. |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
714 |
Transcript showCR:(t subtractDays:50) |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
715 |
" |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
716 |
! |
af4b1127f362
refactored - some methods moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
6043
diff
changeset
|
717 |
|
699 | 718 |
subtractHours:numberOfHours |
719 |
"return a new instance of myself, numberOfHours before." |
|
720 |
||
721 |
^ self subtractSeconds:(numberOfHours * (60 * 60)) |
|
275 | 722 |
|
723 |
" |
|
724 |
|t| |
|
725 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
726 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
727 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
728 |
Transcript showCR:(t subtractHours:12). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
729 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
730 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
731 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
732 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
733 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
734 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
735 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
736 |
Transcript showCR:(t subtractHours:12). |
275 | 737 |
" |
738 |
! |
|
739 |
||
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
740 |
subtractMilliseconds:numberOfMilliSeconds |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
741 |
"return a new instance of myself, numberOfMilliSeconds before." |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
742 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
743 |
^ self species basicNew |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
744 |
setMilliseconds:(self getMilliseconds - numberOfMilliSeconds) |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
745 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
746 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
747 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
748 |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
749 |
t := Timestamp now. |
6043
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
750 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
751 |
Transcript showCR:(t subtractMilliseconds:100). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
752 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
753 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
754 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
755 |
|t| |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
756 |
|
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
757 |
t := Time now. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
758 |
Transcript showCR:t. |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
759 |
Transcript showCR:(t subtractMilliseconds:1000). |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
760 |
" |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
761 |
! |
ee486429674b
pushed up addMilliseconds/subtractMilliseconds
Claus Gittinger <cg@exept.de>
parents:
5968
diff
changeset
|
762 |
|
275 | 763 |
subtractMinutes:numberOfMinutes |
764 |
"return a new instance of myself, numberOfMinutes before." |
|
765 |
||
766 |
^ self subtractSeconds:(numberOfMinutes * 60) |
|
767 |
||
768 |
" |
|
769 |
|t| |
|
770 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
771 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
772 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
773 |
Transcript showCR:(t subtractMinutes:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
774 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
775 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
776 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
777 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
778 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
779 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
780 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
781 |
Transcript showCR:(t subtractMinutes:60). |
275 | 782 |
" |
783 |
! |
|
784 |
||
699 | 785 |
subtractSeconds:numberOfSeconds |
786 |
"return a new instance of myself, numberOfSeconds before." |
|
275 | 787 |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
788 |
^ self species basicNew |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
789 |
setMilliseconds:(self getMilliseconds - (numberOfSeconds * 1000)) |
275 | 790 |
|
791 |
" |
|
792 |
|t| |
|
793 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
794 |
t := Timestamp now. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
795 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
796 |
Transcript showCR:(t subtractSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
797 |
" |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
798 |
|
275 | 799 |
" |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
800 |
|t| |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
801 |
|
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
802 |
t := Time now. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
803 |
Transcript showCR:t. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
804 |
Transcript showCR:(t subtractSeconds:60). |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
805 |
" |
275 | 806 |
! |
807 |
||
808 |
subtractTime:timeAmount |
|
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
809 |
"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
|
810 |
Provided for ST-80 compatibility. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
811 |
WARNING: |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
812 |
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
|
813 |
a numberOfSeconds as argument. |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
814 |
Use any of addSeconds/addHours etc. to make things clear" |
275 | 815 |
|
6888
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
816 |
timeAmount isNumber ifFalse:[ |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
817 |
^ self subtractSeconds:(timeAmount asSeconds). |
d75cbe2e8ef7
addTime / subtractTime handle non-Number argument
Claus Gittinger <cg@exept.de>
parents:
6795
diff
changeset
|
818 |
]. |
3476
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
819 |
^ self subtractSeconds:timeAmount |
f2ebb76a952d
dont loose milliseconds when adding seconds to a Timestamp.
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
820 |
|
275 | 821 |
! ! |
822 |
||
5573
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
823 |
!AbstractTime methodsFor:'comparing'! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
824 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
825 |
< aTime |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
826 |
"return true if the receiver is before the argument" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
827 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
828 |
^ self getMilliseconds < aTime getMilliseconds |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
829 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
830 |
"Modified: 3.7.1996 / 13:10:17 / cg" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
831 |
! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
832 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
833 |
> aTime |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
834 |
"return true if the receiver is after the argument" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
835 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
836 |
^ self getMilliseconds > aTime getMilliseconds |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
837 |
|
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
838 |
"Modified: 1.7.1996 / 15:24:38 / cg" |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
839 |
! ! |
efd0dc6578ac
#-, #< and #> moved from AbsoluteTime
Claus Gittinger <cg@exept.de>
parents:
5548
diff
changeset
|
840 |
|
8200 | 841 |
!AbstractTime methodsFor:'converting'! |
842 |
||
843 |
asAbsoluteTime |
|
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
844 |
"deprecated, use #asTimestamp" |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
845 |
<resource:#obsolete> |
8200 | 846 |
|
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17728
diff
changeset
|
847 |
self obsoleteMethodWarning:'use #asTimestamp'. |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
848 |
^ self asTimestamp |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
849 |
! |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
850 |
|
17815 | 851 |
asLocalTimestamp |
852 |
"represent myself as a timestamp in the local timezone" |
|
853 |
||
854 |
^ self subclassResponsibility |
|
855 |
! |
|
856 |
||
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
857 |
asTimestamp |
17815 | 858 |
"represent myself as a Timestamp" |
859 |
||
860 |
^ self subclassResponsibility |
|
861 |
! |
|
862 |
||
863 |
asUtcTimestamp |
|
864 |
"represent myself as a timestamp in the local timezone" |
|
865 |
||
8200 | 866 |
^ self subclassResponsibility |
867 |
! ! |
|
868 |
||
11518 | 869 |
!AbstractTime methodsFor:'double dispatching'! |
870 |
||
871 |
differenceFromTimestamp:aTimestamp |
|
872 |
^ aTimestamp getSeconds - self getSeconds |
|
873 |
! ! |
|
874 |
||
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
875 |
!AbstractTime methodsFor:'printing & storing'! |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
876 |
|
4844 | 877 |
addPrintBindingsTo:aDictionary |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
878 |
"private print support: add bindings for printing to aDictionary." |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
879 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
880 |
self addPrintBindingsTo:aDictionary language:nil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
881 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
882 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
883 |
addPrintBindingsTo:aDictionary language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7672
diff
changeset
|
884 |
"private print support: add bindings for printing to aDictionary. |
17815 | 885 |
languageOrNil can be #en, #fr, #de or nil for the current language. |
886 |
||
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
887 |
bindings: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
888 |
%h hours, 00..23 (i.e. european) 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
889 |
%u hours, 00..12 (i.e. us) 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
890 |
%m minutes, 00..59 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
891 |
%s seconds, 00..59 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
892 |
%i milliseconds, 000..999 0-padded to length 3 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
893 |
%a am/pm |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
894 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
895 |
Timestamp only: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
896 |
%(day) day, 00..31 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
897 |
%(month) month, 00..12 0-padded to length 2 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
898 |
%(year) year, 4 digits 0-padded to length 4 |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
899 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
900 |
special: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
901 |
%H 24-hours - unpadded |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
902 |
%U 12-hours - unpadded |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
903 |
%M minutes - unpadded |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
904 |
%S seconds - unpadded |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
905 |
%I milliseconds, unpadded |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
906 |
%A AM/PM - uppercase |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
907 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
908 |
%t seconds within hour (unpadded) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
909 |
%T seconds from midNight (unpadded) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
910 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
911 |
%(TZD) timeZone delta from UTC in the format +/-hh:mm |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
912 |
|
17815 | 913 |
%(milli1) milliseconds, truncated to 1/10th of a second 0..9 |
914 |
%(milli2) milliseconds, truncated to 1/100th of a second 00..99 0-padded to length 2 |
|
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
915 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
916 |
Timestamp only: |
17815 | 917 |
%(Day) - day - unpadded |
918 |
%(Month) - month - unpadded |
|
919 |
%(yearOrTime) - year or time 5 digits as in unix-ls: |
|
920 |
year if it is not the current year; |
|
921 |
time otherwise |
|
922 |
%(weekDay) - day in week (1->monday, 2->tuesday, ... ,7->sunday) |
|
923 |
||
924 |
%(dayName) - full day name |
|
925 |
%(DayName) - full day name, first character uppercase |
|
926 |
%(DAYNAME) - full day name, all uppercase |
|
927 |
||
928 |
%(monthName) - full month name |
|
929 |
%(MonthName) - full month name, first character uppercase |
|
930 |
%(MONTHNAME) - full month name, all uppercase |
|
931 |
||
932 |
%(shortDayName) - short (abbreviated) day name |
|
933 |
%(ShortDayName) - short (abbreviated) day name, first character uppercase |
|
934 |
%(SHORTDAYNAME) - short (abbreviated) day name, all uppercase |
|
935 |
||
936 |
%(shortMonthName) - short (abbreviated) month name |
|
937 |
%(ShortMonthName) - short (abbreviated) month name, first character uppercase |
|
938 |
%(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase |
|
939 |
||
940 |
%(nth) - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
941 |
%(weekDayNth) - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
942 |
%(weekNth) - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
|
17728
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
943 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
944 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
945 |
The ISO8601 printString are generated with: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
946 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
947 |
Year: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
948 |
YYYY (eg 1997) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
949 |
Date today printStringFormat:'%(year)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
950 |
Timestamp now printStringFormat:'%(year)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
951 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
952 |
Year and month: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
953 |
YYYY-MM (eg 1997-07) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
954 |
Date today printStringFormat:'%(year)-%(month)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
955 |
Timestamp now printStringFormat:'%(year)-%(month)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
956 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
957 |
Complete date: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
958 |
YYYY-MM-DD (eg 1997-07-16) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
959 |
Date today printStringFormat:'%(year)-%(month)-%(day)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
960 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
961 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
962 |
Complete date plus hours and minutes: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
963 |
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
964 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m%(TZD)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
965 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
966 |
Complete date plus hours, minutes and seconds: |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
967 |
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
968 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s%(TZD)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
969 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
970 |
Complete date plus hours, minutes, seconds and a decimal fraction of a second |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
971 |
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
972 |
Timestamp now printStringFormat:'%(year)-%(month)-%(day)T%h:%m:%s.%(milli2)%(TZD)' |
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
973 |
|
bbc5fa73dfab
Merged with trunk r10466
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
974 |
" |
4844 | 975 |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
976 |
|hours minutes seconds millis usHours ampm s zone tzDelta| |
4844 | 977 |
|
978 |
hours := self hours. |
|
979 |
minutes := self minutes. |
|
980 |
seconds := self seconds. |
|
981 |
millis := self milliseconds. |
|
5968 | 982 |
zone := self timeZoneName. |
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
983 |
tzDelta := self timeZoneDeltaInMinutes. |
4844 | 984 |
|
6419 | 985 |
ampm := self meridianAbbreviation. |
986 |
usHours := self hour12. |
|
4844 | 987 |
|
988 |
aDictionary at:$H put:(s := hours printString). |
|
989 |
aDictionary at:$h put:(s leftPaddedTo:2 with:$0). |
|
990 |
aDictionary at:$U put:(s := usHours printString). |
|
991 |
aDictionary at:$u put:(s leftPaddedTo:2 with:$0). |
|
992 |
aDictionary at:$M put:(s := minutes printString). |
|
993 |
aDictionary at:$m put:(s leftPaddedTo:2 with:$0). |
|
994 |
aDictionary at:$S put:(s := seconds printString). |
|
995 |
aDictionary at:$s put:(s leftPaddedTo:2 with:$0). |
|
996 |
aDictionary at:$I put:(s := millis printString). |
|
997 |
aDictionary at:$i put:(s leftPaddedTo:3 with:$0). |
|
4904
33d322c419ba
more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents:
4844
diff
changeset
|
998 |
aDictionary at:#milli1 put:((millis // 100) printString). |
33d322c419ba
more format strings for milliseconds.
Claus Gittinger <cg@exept.de>
parents:
4844
diff
changeset
|
999 |
aDictionary at:#milli2 put:((millis // 10) printStringLeftPaddedTo:2 with:$0). |
4844 | 1000 |
aDictionary at:$t put:(seconds * minutes) printString. |
1001 |
aDictionary at:$T put:(seconds * minutes * hours) printString. |
|
1002 |
aDictionary at:$a put:ampm. |
|
1003 |
aDictionary at:$A put:ampm asUppercase. |
|
5968 | 1004 |
aDictionary at:$z put:zone. |
1005 |
aDictionary at:$Z put:zone asUppercase. |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
1006 |
|
9432 | 1007 |
tzDelta == 0 ifTrue:[ |
1008 |
s := 'Z'. |
|
1009 |
] ifFalse:[ |
|
1010 |
s := tzDelta < 0 ifTrue:[ '-' ] ifFalse:[ '+' ]. |
|
1011 |
tzDelta := tzDelta abs. |
|
1012 |
s := s , ((tzDelta // 60) printStringLeftPaddedTo:2 with:$0), |
|
1013 |
':' , ((tzDelta \\ 60) printStringLeftPaddedTo:2 with:$0). |
|
1014 |
]. |
|
6172
a3c88ea5efe9
comment and iso8601 (time/date formats) fixes
Claus Gittinger <cg@exept.de>
parents:
6048
diff
changeset
|
1015 |
aDictionary at:#TZD put:s |
17807 | 1016 |
|
1017 |
||
1018 |
" |
|
1019 |
|dict| |
|
1020 |
dict := Dictionary new. |
|
1021 |
Timestamp now addPrintBindingsTo:dict language:#en. |
|
1022 |
dict inspect |
|
1023 |
" |
|
4844 | 1024 |
! |
1025 |
||
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1026 |
printOn:aStream format:aFormatString |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1027 |
"print using a format string; |
17815 | 1028 |
See #addPrintBindingsTo:language: for allowed format strings" |
7327 | 1029 |
|
17815 | 1030 |
self printOn:aStream format:aFormatString language:nil. |
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1031 |
|
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1032 |
" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1033 |
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
|
1034 |
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
|
1035 |
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
|
1036 |
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
|
1037 |
Time now printOn:Transcript format:'%h:%m' . Transcript cr. |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1038 |
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
|
1039 |
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
|
1040 |
" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1041 |
|
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1042 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1043 |
! |
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1044 |
|
17807 | 1045 |
printOn:aStream format:aFormatString language:languageString |
1046 |
"print using a format string; |
|
17815 | 1047 |
See #addPrintBindingsTo:language: for allowed format strings" |
17807 | 1048 |
|
1049 |
|dict| |
|
1050 |
||
1051 |
dict := IdentityDictionary new. |
|
1052 |
self addPrintBindingsTo:dict language:languageString. |
|
1053 |
||
1054 |
aFormatString expandPlaceholdersWith:dict on:aStream |
|
1055 |
||
1056 |
" |
|
1057 |
Timestamp now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
|
1058 |
Time now printOn:Transcript format:'%h:%m:%s' . Transcript cr. |
|
1059 |
Time now printOn:Transcript format:'%H:%m:%s' . Transcript cr. |
|
1060 |
Time now printOn:Transcript format:'%u:%m:%s %a'. Transcript cr. |
|
1061 |
Time now printOn:Transcript format:'%h:%m' . Transcript cr. |
|
1062 |
Time now printOn:Transcript format:'%H:%m %A' . Transcript cr. |
|
1063 |
Time now printOn:Transcript format:'minutes:%M seconds:%S'. Transcript cr. |
|
1064 |
" |
|
1065 |
||
1066 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
|
1067 |
! |
|
1068 |
||
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1069 |
printStringFormat:aFormatString |
17815 | 1070 |
"print using a format string. |
1071 |
See #addPrintBindingsTo:language: for allowed format strings" |
|
10907
8b98ba82a46f
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10770
diff
changeset
|
1072 |
|
17815 | 1073 |
^ self printStringFormat:aFormatString language:nil. |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1074 |
|
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1075 |
" |
8256
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1076 |
Timestamp now printStringFormat:'%U:%m:%s %a' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1077 |
Time now printStringFormat:'%U:%m:%s %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1078 |
|
4844 | 1079 |
Time now printStringFormat:'%h:%m:%s' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1080 |
Time now printStringFormat:'%H:%m:%s' |
4844 | 1081 |
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
|
1082 |
Timestamp now printStringFormat:'%H:%m:%s.%i' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1083 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli1)' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1084 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli2)' |
4c3d944ef85a
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8244
diff
changeset
|
1085 |
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
|
1086 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1087 |
Time now printStringFormat:'%u:%m:%s %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1088 |
Time now printStringFormat:'%h:%m' |
4844 | 1089 |
Time now printStringFormat:'%h:%m' |
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1090 |
Time now printStringFormat:'%H:%m %A' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1091 |
Time now printStringFormat:'%m minutes after %U %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1092 |
Time now printStringFormat:'%t seconds after %U %a' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1093 |
Time now printStringFormat:'%T seconds from midNight' |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1094 |
" |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1095 |
|
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1096 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
17807 | 1097 |
! |
1098 |
||
1099 |
printStringFormat:aFormatString language:languageString |
|
17815 | 1100 |
"print using a format string. |
1101 |
See #addPrintBindingsTo:language: for allowed format strings" |
|
17807 | 1102 |
|
1103 |
|s| |
|
1104 |
||
1105 |
s := WriteStream on:(String new:20). |
|
1106 |
self printOn:s format:aFormatString language:languageString. |
|
1107 |
^ s contents. |
|
1108 |
||
1109 |
" |
|
1110 |
Timestamp now printStringFormat:'%U:%m:%s %a |
|
1111 |
Time now printStringFormat:'%U:%m:%s %a' |
|
1112 |
||
1113 |
Time now printStringFormat:'%h:%m:%s' |
|
1114 |
Time now printStringFormat:'%H:%m:%s' |
|
1115 |
Time now printStringFormat:'%H:%m:%s.%i' |
|
1116 |
Timestamp now printStringFormat:'%H:%m:%s.%i' |
|
1117 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli1)' |
|
1118 |
Timestamp now printStringFormat:'%H:%m:%s.%(milli2)' |
|
1119 |
Timestamp now printStringFormat:'%(day)-%(month)-%(year) :%m:%s' |
|
17815 | 1120 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#en |
1121 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#de |
|
1122 |
Timestamp now printStringFormat:'%(day)-%(monthName)-%(year) :%m:%s' language:#fr |
|
17807 | 1123 |
Time now printStringFormat:'%u:%m:%s %a' |
1124 |
Time now printStringFormat:'%h:%m' |
|
1125 |
Time now printStringFormat:'%h:%m' |
|
1126 |
Time now printStringFormat:'%H:%m %A' |
|
1127 |
Time now printStringFormat:'%m minutes after %U %a' |
|
1128 |
Time now printStringFormat:'%t seconds after %U %a' |
|
1129 |
Time now printStringFormat:'%T seconds from midNight' |
|
1130 |
" |
|
1131 |
||
1132 |
"Modified: 22.2.1996 / 16:58:30 / cg" |
|
4649
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1133 |
! ! |
3eaf75dd8973
Move printOn:format: to AbstractTime
Stefan Vogel <sv@exept.de>
parents:
3476
diff
changeset
|
1134 |
|
699 | 1135 |
!AbstractTime methodsFor:'private'! |
240 | 1136 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1137 |
fromOSTime:osTime |
699 | 1138 |
"set my time, from operatingSystems time parts" |
240 | 1139 |
|
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1140 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1141 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1142 |
"Modified: 1.7.1996 / 15:09:44 / cg" |
240 | 1143 |
! |
1144 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1145 |
getMilliseconds |
8200 | 1146 |
"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
|
1147 |
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
|
1148 |
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
|
1149 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1150 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1151 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1152 |
"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
|
1153 |
! |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1154 |
|
699 | 1155 |
getSeconds |
8200 | 1156 |
"get the seconds since some point of time in the past. |
699 | 1157 |
Since I am abstract (not knowing how the time is actually |
1158 |
represented), this must be done by a concrete class." |
|
240 | 1159 |
|
699 | 1160 |
^ self subclassResponsibility |
1161 |
! |
|
1162 |
||
1500
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1163 |
setMilliseconds:millis |
8200 | 1164 |
"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
|
1165 |
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
|
1166 |
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
|
1167 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1168 |
^ self subclassResponsibility |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1169 |
|
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1170 |
"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
|
1171 |
! |
d42e61e53cee
changed osTime to a largeInt, which includes the milliseconds
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
1172 |
|
699 | 1173 |
setSeconds:secs |
8200 | 1174 |
"set the seconds since some point of time in the past. |
699 | 1175 |
Since I am abstract (not knowing how the time is actually |
1176 |
represented), this must be done by a concrete class." |
|
1177 |
||
1178 |
^ self subclassResponsibility |
|
240 | 1179 |
! ! |
1180 |
||
2310
2cb1366e0eb3
Correct name: #secondDay --> #secondInDay.
Stefan Vogel <sv@exept.de>
parents:
1500
diff
changeset
|
1181 |
!AbstractTime class methodsFor:'documentation'! |
240 | 1182 |
|
699 | 1183 |
version |
17846 | 1184 |
^ '$Id: AbstractTime.st 10660 2011-07-18 15:22:09Z vranyj1 $' |
17747 | 1185 |
! |
1186 |
||
1187 |
version_CVS |
|
17845 | 1188 |
^ '§Header: /cvs/stx/stx/libbasic/AbstractTime.st,v 1.73 2011/01/24 19:55:34 stefan Exp §' |
17846 | 1189 |
! ! |