author | Claus Gittinger <cg@exept.de> |
Thu, 13 Nov 2014 21:39:20 +0100 | |
changeset 17053 | c654249389f9 |
parent 16983 | ef0d2f381125 |
child 17080 | cc02d25252ed |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
155 | 3 |
All Rights Reserved |
1 | 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 |
" |
|
5515 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
54 | 14 |
Magnitude subclass:#Date |
972 | 15 |
instanceVariableNames:'dateEncoding' |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
16 |
classVariableNames:'DayNames MonthNames DayAbbrevs MonthAbbrevs DefaultFormats |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
17 |
ShortFormats LongFormats EnvironmentChange' |
972 | 18 |
poolDictionaries:'' |
7673 | 19 |
category:'Magnitude-Time' |
1 | 20 |
! |
21 |
||
2706
878723bc99fc
added #shortPrintString for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1701
diff
changeset
|
22 |
!Date class methodsFor:'documentation'! |
54 | 23 |
|
88 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
155 | 27 |
All Rights Reserved |
88 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
54 | 38 |
documentation |
39 |
" |
|
92 | 40 |
Instances of Date represent dates as year, month and day encoded in the |
41 |
(private & hidden) instance dateEncoding. The value found there is |
|
42 |
year*100*100 + month*100 + day (which makes magnitude-like comparison of |
|
43 |
dates easy, but is not guaranteed for future versions). |
|
1228 | 44 |
Do not depend on the internal representation. |
54 | 45 |
|
92 | 46 |
The old representation used days since 1st Jan. 1901 internally - |
47 |
with the new implementation, it is possible to reasonably represent almost |
|
48 |
any Date. (which insurance companies will like, since they can now |
|
49 |
represent even very old peoples birthday :-) |
|
16971 | 50 |
Notice: |
51 |
no correction for pre-Gregorian dates (< 1583) is done. |
|
52 |
For dates before 1582 (when calendars were changed from Julian to Grgorian), |
|
16974 | 53 |
the so called 'proleptic gregorian calendar' is used. This assumes leap years to continue in |
16971 | 54 |
the past as if a gregorian calendar was used. Thus, 0000 is considered a leap year. |
54 | 55 |
|
92 | 56 |
The printed representation of dates is controlled by resource definitions - |
57 |
thus national variants are already supported (see file 'resources/Date.rs'). |
|
58 |
||
59 |
Compatibility notice: |
|
1228 | 60 |
due to some historic reasons, there are some methods found twice |
61 |
with different names in this class. The old ST/X methods will vanish in |
|
62 |
one of the next releases, and kept for a while to support existing |
|
63 |
applications (the info on how these methods should be named came |
|
64 |
somewhat late from the testers ..). |
|
92 | 65 |
|
1228 | 66 |
Please do not use methods marked as obsolete in their comment. |
92 | 67 |
|
68 |
Most useful methods: |
|
69 |
||
1228 | 70 |
Date today |
71 |
(Date today) addDays: |
|
72 |
(Date today) subtractDays: |
|
1295 | 73 |
|
74 |
[author:] |
|
75 |
Claus Gittinger |
|
76 |
||
77 |
[see also:] |
|
78 |
Time AbstractTime |
|
79 |
Filename |
|
80 |
OperatingSystem |
|
54 | 81 |
" |
82 |
! ! |
|
83 |
||
8145 | 84 |
!Date class methodsFor:'initialization'! |
85 |
||
86 |
initDefaultNames |
|
87 |
"read the language specific names." |
|
88 |
||
89 |
|enDayNames enDayAbbrevs enMonthNames enMonthAbbrevs |
|
12812 | 90 |
enDefaultFormat enLongFormat enShortFormat | |
8145 | 91 |
|
92 |
DayNames := Dictionary new. |
|
93 |
DayAbbrevs := Dictionary new. |
|
94 |
MonthNames := Dictionary new. |
|
95 |
MonthAbbrevs := Dictionary new. |
|
96 |
DefaultFormats := Dictionary new. |
|
97 |
LongFormats := Dictionary new. |
|
98 |
ShortFormats := Dictionary new. |
|
99 |
||
100 |
enDayNames := #('monday' |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
101 |
'tuesday' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
102 |
'wednesday' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
103 |
'thursday' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
104 |
'friday' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
105 |
'saturday' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
106 |
'sunday'). |
8145 | 107 |
|
108 |
enDayAbbrevs := #('mon' |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
109 |
'tue' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
110 |
'wed' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
111 |
'thu' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
112 |
'fri' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
113 |
'sat' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
114 |
'sun'). |
8145 | 115 |
|
116 |
enMonthNames := #('january' |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
117 |
'february' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
118 |
'march' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
119 |
'april' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
120 |
'may' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
121 |
'june' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
122 |
'july' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
123 |
'august' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
124 |
'september' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
125 |
'october' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
126 |
'november' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
127 |
'december'). |
8145 | 128 |
|
129 |
enMonthAbbrevs := #('jan' |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
130 |
'feb' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
131 |
'mar' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
132 |
'apr' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
133 |
'may' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
134 |
'jun' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
135 |
'jul' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
136 |
'aug' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
137 |
'sep' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
138 |
'oct' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
139 |
'nov' |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
140 |
'dec'). |
8145 | 141 |
|
142 |
DayNames at:#'en' put:enDayNames. |
|
143 |
DayAbbrevs at:#'en' put:enDayAbbrevs. |
|
144 |
MonthNames at:#'en' put:enMonthNames. |
|
145 |
MonthAbbrevs at:#'en' put:enMonthAbbrevs. |
|
146 |
||
147 |
DefaultFormats at:#'en' put:(enDefaultFormat := '%d-%m-%y'). |
|
148 |
ShortFormats at:#'en' put:(enShortFormat := '%d-%m-%y'). |
|
149 |
LongFormats at:#'en' put:(enLongFormat := '%(dayName), %d-%m-%y'). |
|
12812 | 150 |
|
12105 | 151 |
"/ take the "master" language here, for the caching |
152 |
EnvironmentChange := (Smalltalk language asSymbol ~~ #'en'). |
|
8145 | 153 |
|
154 |
" |
|
12812 | 155 |
Date initDefaultNames |
156 |
" |
|
157 |
! |
|
158 |
||
159 |
initNames |
|
160 |
"read the language specific names." |
|
161 |
||
162 |
|lang| |
|
163 |
||
164 |
DayNames isNil ifTrue:[ |
|
165 |
self initDefaultNames. |
|
166 |
]. |
|
167 |
||
168 |
lang := Smalltalk language asSymbol. |
|
169 |
lang ~~ #'en' ifTrue:[ |
|
170 |
self initNamesForLanguage: lang. |
|
171 |
]. |
|
172 |
||
173 |
EnvironmentChange := false |
|
174 |
||
175 |
" |
|
8145 | 176 |
Date initNames |
177 |
" |
|
178 |
! |
|
179 |
||
12812 | 180 |
initNamesForLanguage:language |
8145 | 181 |
"read the language specific names." |
182 |
||
183 |
|resources lang |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
184 |
enDayNames enDayAbbrevs enMonthNames enMonthAbbrevs monthAbbrevKeys |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
185 |
enDefaultFormat enLongFormat enShortFormat may| |
8145 | 186 |
|
8943 | 187 |
DayNames isNil ifTrue:[ |
188 |
self initDefaultNames. |
|
189 |
]. |
|
190 |
||
12812 | 191 |
lang := language asSymbol. |
8145 | 192 |
lang ~~ #'en' ifTrue:[ |
14624
58ad30334e84
care for libview not being present (tinytalk)
Claus Gittinger <cg@exept.de>
parents:
14498
diff
changeset
|
193 |
ResourcePack notNil ifTrue:[ "/ guard for tinytalk (no libview) |
58ad30334e84
care for libview not being present (tinytalk)
Claus Gittinger <cg@exept.de>
parents:
14498
diff
changeset
|
194 |
resources := ResourcePack forPackage:'stx:libbasic' resourceFileName:(language,'.rs') cached:false. |
58ad30334e84
care for libview not being present (tinytalk)
Claus Gittinger <cg@exept.de>
parents:
14498
diff
changeset
|
195 |
]. |
12812 | 196 |
resources notNil ifTrue:[ |
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
197 |
enDayNames := DayNames at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
198 |
enDayAbbrevs := DayAbbrevs at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
199 |
enMonthNames := MonthNames at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
200 |
enMonthAbbrevs := MonthAbbrevs at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
201 |
monthAbbrevKeys := enMonthAbbrevs copy. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
202 |
monthAbbrevKeys at:5 put:'MAY_ABBREV'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
203 |
|
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
204 |
enDefaultFormat := DefaultFormats at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
205 |
enShortFormat := ShortFormats at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
206 |
enLongFormat := LongFormats at:#'en'. |
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
207 |
|
12812 | 208 |
DefaultFormats at:lang put:(resources at:'DATEFORMAT' default:enDefaultFormat). |
209 |
ShortFormats at:lang put:(resources at:'SHORTDATEFORMAT' default:enShortFormat). |
|
210 |
LongFormats at:lang put:(resources at:'LONGDATEFORMAT' default:enLongFormat). |
|
211 |
||
212 |
DayNames at:lang put:(resources array:enDayNames). |
|
213 |
DayAbbrevs at:lang put:(resources array:enDayAbbrevs). |
|
214 |
MonthNames at:lang put:(resources array:enMonthNames). |
|
215 |
MonthAbbrevs at:lang put:(resources array:monthAbbrevKeys). |
|
216 |
"/ may needs special care (same key for long and short name) |
|
217 |
may := resources string:'MAY_ABBREV' default:nil. |
|
218 |
may isNil ifTrue:[ |
|
219 |
may := resources string:'may'. |
|
8196
3b3407d69207
special care for may (same key for long & short name)
Claus Gittinger <cg@exept.de>
parents:
8179
diff
changeset
|
220 |
]. |
12812 | 221 |
(MonthAbbrevs at:lang) at:5 put:may. |
8145 | 222 |
]. |
223 |
]. |
|
224 |
||
225 |
" |
|
12812 | 226 |
Date initNamesForLanguage:#de. |
227 |
Date initNamesForLanguage:#fr. |
|
228 |
Date initNamesForLanguage:#es. |
|
8145 | 229 |
" |
13736
599f4686a493
comment/format in: #initNamesForLanguage:
Claus Gittinger <cg@exept.de>
parents:
13509
diff
changeset
|
230 |
|
599f4686a493
comment/format in: #initNamesForLanguage:
Claus Gittinger <cg@exept.de>
parents:
13509
diff
changeset
|
231 |
"Modified (format): / 28-09-2011 / 15:56:41 / cg" |
8145 | 232 |
! |
233 |
||
234 |
initialize |
|
8943 | 235 |
DayNames isNil ifTrue:[ |
236 |
self initDefaultNames. |
|
237 |
]. |
|
8145 | 238 |
|
239 |
Smalltalk addDependent:self. |
|
240 |
Language ~= 'en' ifTrue:[ |
|
241 |
EnvironmentChange := true |
|
242 |
] |
|
243 |
! ! |
|
244 |
||
2706
878723bc99fc
added #shortPrintString for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1701
diff
changeset
|
245 |
!Date class methodsFor:'instance creation'! |
699 | 246 |
|
247 |
fromDays:dayCount |
|
248 |
"return a new Date, given the day-number starting with 0 at 1.Jan 1901; |
|
249 |
(i.e. 'Date fromDays:0' returns 1st Jan. 1901). |
|
250 |
Date asDays is the reverse operation. |
|
16927 | 251 |
Notice, that this is not able to represent dates before 1901!!. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
252 |
Added for GNU/ST-80 compatibility" |
699 | 253 |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
254 |
|year rest d yearIncrement| |
699 | 255 |
|
256 |
"approx. year" |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
257 |
year := (dayCount // 366) + 1901. |
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
258 |
dayCount < 0 ifTrue:[ |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
259 |
rest := dayCount negated - (self yearAsDays:year) + 1. "+1 for ST-80 compatibility" |
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
260 |
yearIncrement := -1. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
261 |
] ifFalse:[ |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
262 |
rest := dayCount - (self yearAsDays:year) + 1. "+1 for ST-80 compatibility" |
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
263 |
yearIncrement := 1. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
264 |
]. |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
265 |
rest > 365 ifTrue:[ |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
266 |
[d := self daysInYear:year. rest > d] whileTrue:[ |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
267 |
"adjust" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
268 |
year := year + yearIncrement. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
269 |
rest := rest - d. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
270 |
]. |
699 | 271 |
]. |
272 |
||
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
273 |
^ self newDay:rest year:year |
699 | 274 |
|
275 |
" |
|
276 |
Date fromDays:0 -> 1 jan 1901 |
|
277 |
Date fromDays:365 -> 1 jan 1902 |
|
278 |
Date fromDays:730 -> 1 jan 1903 |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
279 |
Date fromDays:1095 -> 1 jan 1904 |
699 | 280 |
Date fromDays:1460 ->31 dec 1904 since 1904 was a leap year |
281 |
" |
|
282 |
||
1501 | 283 |
"Modified: 1.7.1996 / 14:24:25 / cg" |
699 | 284 |
! |
285 |
||
16927 | 286 |
fromDaysFrom0:dayCount |
287 |
"return a new Date, given the day-number starting with 0 at 1.Jan 0; |
|
288 |
(i.e. 'Date fromDaysSince0:0' returns 1st Jan. 0). |
|
289 |
Date asDaysSince0 is the reverse operation. |
|
290 |
Notice, that this is a private interface" |
|
291 |
||
292 |
|year rest d yearIncrement| |
|
293 |
||
294 |
"approx. year" |
|
295 |
year := (dayCount // 366). |
|
296 |
dayCount < 0 ifTrue:[ |
|
297 |
rest := dayCount negated - (self yearAsDaysFrom0:year) + 1. "+1 for ST-80 compatibility" |
|
298 |
yearIncrement := -1. |
|
299 |
] ifFalse:[ |
|
300 |
rest := dayCount - (self yearAsDaysFrom0:year) + 1. "+1 for ST-80 compatibility" |
|
301 |
yearIncrement := 1. |
|
302 |
]. |
|
303 |
rest > 365 ifTrue:[ |
|
304 |
[d := self daysInYear:year. rest > d] whileTrue:[ |
|
305 |
"adjust" |
|
306 |
year := year + yearIncrement. |
|
307 |
rest := rest - d. |
|
308 |
]. |
|
309 |
]. |
|
310 |
||
311 |
^ self newDay:rest year:year |
|
312 |
||
313 |
" |
|
314 |
Date fromDaysSince0:0 -> 1 jan 0 |
|
315 |
Date fromDaysSince0:366 -> 1 jan 1 |
|
316 |
" |
|
317 |
! |
|
318 |
||
699 | 319 |
newDay:day month:month year:year |
320 |
"return a new Date, given the day, month and year. |
|
321 |
For your convenience, month may be either an integer |
|
16913 | 322 |
or the month's name as a string. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
323 |
|
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
324 |
WARNING: semantics changed: 0..99 is no longer treated as 1900..1999, |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
325 |
but as 0..99 now. |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
326 |
Any such adjustments must be made by the caller of this method now |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
327 |
(see those, for example readFrom:onError:)" |
699 | 328 |
|
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
329 |
|monthIndex ok| |
699 | 330 |
|
8446
e19765545de6
Dont generate a warning for years between -1 and -99
Stefan Vogel <sv@exept.de>
parents:
8247
diff
changeset
|
331 |
(year < 100 and:[year > 0]) ifTrue:[ |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
332 |
'Date [warning]: year in [0..99] no longer converted to [1900..1999]' infoPrintCR. |
699 | 333 |
]. |
16833 | 334 |
year class ~= SmallInteger ifTrue:[ |
335 |
"we support a lot of future, but LargeInteger years fail in #isLeapYear" |
|
336 |
self conversionErrorSignal raiseErrorString:' - invalid year (way too large)'. |
|
337 |
]. |
|
699 | 338 |
month isInteger ifTrue:[ |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
339 |
monthIndex := month |
699 | 340 |
] ifFalse:[ |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
341 |
monthIndex := self indexOfMonth:month |
699 | 342 |
]. |
343 |
(monthIndex == 2 and:[day == 29]) ifTrue:[ |
|
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
344 |
ok := self leapYear:year |
699 | 345 |
] ifFalse:[ |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
346 |
ok := day <= (self daysInMonth:month forYear:year) |
699 | 347 |
]. |
348 |
((day > 0) and:[ok]) ifTrue:[ |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
349 |
^ self basicNew year:year month:monthIndex day:day. |
699 | 350 |
]. |
351 |
||
352 |
"this error is triggered if you try to create a date from an |
|
353 |
invalid year/month/day combination; |
|
354 |
Such as 29-feb-year, where year is no leap year |
|
355 |
" |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
356 |
self conversionErrorSignal raiseErrorString:' - invalid date'. |
699 | 357 |
|
358 |
" |
|
359 |
Date newDay:8 month:'may' year:1993 |
|
360 |
Date newDay:8 month:5 year:1994 |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
361 |
Date newDay:29 month:'feb' year:2004 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
362 |
Date newDay:29 month:'feb' year:2003 |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
363 |
Date newDay:28 month:'feb' year:5 |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
364 |
Date newDay:28 month:'feb' year:95 |
699 | 365 |
" |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
366 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
367 |
"Modified: 19.4.1996 / 15:28:15 / cg" |
699 | 368 |
! |
369 |
||
370 |
newDay:dayInYear year:year |
|
371 |
"return a new Date, given the year and the day-in-year (starting at 1). |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
372 |
See also: Date today / Time now / Timestamp now. |
699 | 373 |
ST-80 compatibility" |
374 |
||
375 |
|monthAndDay| |
|
376 |
||
377 |
(dayInYear between:1 and:365) ifFalse:[ |
|
16835 | 378 |
(dayInYear == 366 and:[self leapYear:year]) ifFalse:[ |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
379 |
" |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
380 |
this error is triggered, when you try to create a |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
381 |
day from an invalid day-in-year; |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
382 |
for example, 366 in a non-leap year. |
16835 | 383 |
I don't know, if ST-80 wraps to the next year(s) in this case. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
384 |
" |
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
385 |
^ self conversionErrorSignal raiseErrorString:' - invalid day in year'. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
386 |
] |
699 | 387 |
]. |
388 |
monthAndDay := self monthAndDayFromDayInYear:dayInYear forYear:year. |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
389 |
^ self basicNew year:year month:(monthAndDay at:1) day:(monthAndDay at:2) |
699 | 390 |
|
391 |
" |
|
392 |
Date newDay:150 year:1994 |
|
393 |
Date newDay:1 year:1994 |
|
394 |
Date newDay:1 year:1901 |
|
395 |
Date newDay:1 year:1902 |
|
396 |
Date newDay:365 year:1992 |
|
397 |
Date newDay:366 year:1992 |
|
398 |
Date newDay:365 year:1994 |
|
399 |
Date newDay:366 year:1994 |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
400 |
Date newDay:0 year:1994 |
16913 | 401 |
|
402 |
Date newDay:271 year:2008 |
|
403 |
Date newDay:270 year:2008 |
|
404 |
Date newDay:271 year:2007 |
|
699 | 405 |
" |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
406 |
|
1501 | 407 |
"Modified: 1.7.1996 / 14:22:24 / cg" |
699 | 408 |
! |
409 |
||
16913 | 410 |
newDayInWeek:dayInWeek week:week year:yearArg |
411 |
"return a new Date, given the year, the week (1..) and the day in week (1..7). |
|
412 |
See http://en.wikipedia.org/wiki/ISO_week_date" |
|
413 |
||
414 |
|weekDayOfJan4 dayInYear year| |
|
415 |
||
416 |
year := yearArg. |
|
417 |
weekDayOfJan4 := (Date newDay:4 month:1 year:year) dayInWeek. |
|
418 |
dayInYear := (week * 7) + dayInWeek - (weekDayOfJan4 + 3). |
|
419 |
dayInYear < 1 ifTrue:[ |
|
420 |
dayInYear := dayInYear + (Date daysInYear:year-1). |
|
421 |
year := year - 1. |
|
422 |
]. |
|
423 |
dayInYear > (Date daysInYear:year) ifTrue:[ |
|
424 |
dayInYear := dayInYear - (Date daysInYear:year). |
|
425 |
year := year + 1. |
|
426 |
]. |
|
427 |
^ Date newDay:dayInYear year:year. |
|
428 |
||
429 |
" |
|
430 |
Date newDayInWeek:6 week:39 year:2008 |
|
431 |
Date newDayInWeek:1 week:40 year:2014 |
|
432 |
Date newDayInWeek:1 week:44 year:2014 |
|
433 |
" |
|
434 |
! |
|
435 |
||
699 | 436 |
readFrom:aStringOrStream onError:exceptionBlock |
437 |
"return a new Date, reading a printed representation from aStream. |
|
438 |
Notice, that this is not the storeString format and |
|
439 |
is different from the format expected by readFrom:. |
|
440 |
BUG: |
|
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
441 |
This method handles american format (i.e. month/day/year), |
12168 | 442 |
common format with letter month in the middle (10 December 2007) |
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
443 |
and ISO format (yyyy-mm-dd) - as long as yyyy is > 12. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
444 |
|
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
445 |
It does not handle the german/french and other dd-mm-yyyy. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
446 |
use readFrom:printFormat:onError: for this." |
699 | 447 |
|
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
448 |
^ [ |
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
449 |
|str items first second month day year| |
972 | 450 |
str := aStringOrStream readStream. |
699 | 451 |
|
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
452 |
items := #(1 2 3) collect:[:idx| |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
453 |
[str peek isLetterOrDigit] whileFalse:[str next]. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
454 |
(str peek isDigit) ifTrue:[ |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
455 |
Integer readFrom:str |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
456 |
] ifFalse:[ |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
457 |
str nextAlphaNumericWord |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
458 |
]. |
972 | 459 |
]. |
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
460 |
|
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
461 |
first := items at:1. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
462 |
second := items at:2. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
463 |
|
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
464 |
(first isInteger and:[second isInteger and:[first > 12]]) ifTrue:[ |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
465 |
"ISO Date: yyyy-mm-dd" |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
466 |
year := first. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
467 |
month := second. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
468 |
day := items at:3. |
972 | 469 |
] ifFalse:[ |
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
470 |
second isInteger ifTrue:[ |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
471 |
"must be an american date mm/dd/yy" |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
472 |
month := first. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
473 |
day := second. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
474 |
] ifFalse:[ |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
475 |
"3 Dec 2007" |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
476 |
day := first. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
477 |
month := second. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
478 |
]. |
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
479 |
year := items at:3. |
972 | 480 |
]. |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
481 |
(year between:0 and:99) ifTrue:[ |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
482 |
year := UserPreferences current twoDigitDateHandler value:year. |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
483 |
]. |
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
484 |
self newDay:day month:month year:year |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
485 |
] on:Error do:exceptionBlock. |
699 | 486 |
|
487 |
" |
|
488 |
Date readFromString:'31 December 1992' |
|
4997 | 489 |
Date readFrom:'19:11:1999' |
10760
70bdfdb519e3
#readFrom: handles ISO date too: yyyy-mm-dd
Stefan Vogel <sv@exept.de>
parents:
10056
diff
changeset
|
490 |
Date readFrom:'2007-12-31' onError:'wrong date'. |
4997 | 491 |
Date readFromString:'December, 5 1992' |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
492 |
Date readFromString:'12/31/1992' |
4997 | 493 |
Date readFromString:'3-jan-95' |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
494 |
Date readFromString:'3-jan-01' |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
495 |
Date readFromString:'12/31/01' |
4997 | 496 |
Date readFromString:'15.4.1992' -> german; leads to an error |
497 |
Date readFromString:'10.4.1992' -> german; leads to a wrong date |
|
498 |
Date readFromString:'10.4.1992' onError:['wrong date'] |
|
499 |
Date readFromString:'32.4.1992' onError:['wrong date'] |
|
500 |
Date readFromString:'fooBar' onError:['wrong date'] |
|
501 |
Date readFromString:'10.4' onError:['wrong date'] |
|
502 |
Date readFromString:'10041999' onError:['wrong date'] |
|
503 |
" |
|
504 |
||
505 |
"Created: 16.11.1995 / 22:50:17 / cg" |
|
506 |
"Modified: 8.10.1996 / 19:25:39 / cg" |
|
507 |
! |
|
508 |
||
7649 | 509 |
readFrom:aStringOrStream printFormat:aSqueakFormatArrayOrFormatString |
4997 | 510 |
"return a new Date, reading a printed representation from aStream. |
7649 | 511 |
aSqueakFormatArrayOrFormatString may either be a squeak formatArray |
512 |
1 day position (1, 2 or 3) |
|
513 |
2 month position (1..3) |
|
514 |
3 year position (1..3) |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
515 |
or a formatString (see printing instance protocol)." |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
516 |
|
7649 | 517 |
^ self |
518 |
readFrom:aStringOrStream |
|
519 |
printFormat:aSqueakFormatArrayOrFormatString |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
520 |
onError:[ self conversionErrorSignal raise ] |
4997 | 521 |
|
522 |
" |
|
523 |
Date readFrom:'19:11:1999' printFormat:#( 1 2 3 ) |
|
524 |
Date readFrom:'19-nov-1999' printFormat:#( 1 2 3 ) |
|
525 |
Date readFrom:'19:11:1999' printFormat:#( 2 1 3 ) -> exception: wrong month |
|
526 |
Date readFrom:'5:12:1999' printFormat:#( 2 1 3 ) |
|
527 |
Date readFrom:'may-12-1999' printFormat:#( 2 1 3 ) |
|
528 |
Date readFrom:'1999 may 12' printFormat:#( 3 2 1 ) |
|
12812 | 529 |
Date readFrom:'12/31/2001' printFormat:#( 2 1 3 ) |
530 |
Date readFrom:' 31.08.2001' printFormat:#( 1 2 3 ) |
|
531 |
Date readFrom:' 31.dec.2001' printFormat:#( 1 2 3 ) |
|
532 |
Date readFrom:' 31.Dec.2001' printFormat:#( 1 2 3 ) |
|
533 |
Date readFrom:' 31.dez.2001' printFormat:#( 1 2 3 ) |
|
12168 | 534 |
|
535 |
Date readFrom:'31/12/01' printFormat:'%d %m %y' onError:'fail' |
|
536 |
Date readFrom:'12/01' printFormat:'%m %y' onError:'fail' |
|
537 |
Date readFrom:'01' printFormat:'%y' onError:'fail' |
|
538 |
Date readFrom:'30.01' printFormat:'%d %m' onError:'fail' |
|
4997 | 539 |
" |
540 |
||
541 |
"Created: 16.11.1995 / 22:50:17 / cg" |
|
542 |
"Modified: 8.10.1996 / 19:25:39 / cg" |
|
543 |
! |
|
544 |
||
16834 | 545 |
readFrom:aStringOrStream printFormat:aFormatStringOrSqueakFormatArray language:languageOrNil onError:exceptionBlock |
4997 | 546 |
"return a new Date, reading a printed representation from aStream. |
16834 | 547 |
aFormatStringOrSqueakFormatArray may either be a squeak formatArray |
7649 | 548 |
1 day position (1, 2 or 3) |
549 |
2 month position (1..3) |
|
550 |
3 year position (1..3) |
|
551 |
or a formatString (see printing instance protocol). |
|
12812 | 552 |
For now %d, %m, %monthName, %shortMonthName and %y are supported in the formatString. |
553 |
The formatString can have any of these characters '-.:,;/' as separator. |
|
554 |
The formatString can also use a space as separator (for ex. '%d %m %y') and any separator will be allowed. |
|
555 |
However, when a character separator is defined, only that separator will be expected. |
|
7649 | 556 |
TODO: make this a general feature of all DateAndTime classes. |
4997 | 557 |
" |
558 |
||
16835 | 559 |
|str| |
7649 | 560 |
|
561 |
str := aStringOrStream readStream. |
|
562 |
||
16835 | 563 |
[ |
564 |
|day month year| |
|
565 |
||
566 |
aFormatStringOrSqueakFormatArray isArray ifTrue:[ |
|
567 |
|arg| |
|
568 |
||
569 |
arg := Array new:3. |
|
570 |
||
571 |
1 to:3 do:[:i||v| |
|
572 |
[str peek isLetterOrDigit] whileFalse:[str next]. |
|
573 |
||
574 |
v := (str peek isDigit) ifTrue:[Integer readFrom:str] |
|
575 |
ifFalse:[str nextAlphaNumericWord]. |
|
576 |
arg at:i put:v |
|
577 |
]. |
|
578 |
year := arg at:(aFormatStringOrSqueakFormatArray at:3). |
|
579 |
day := arg at:(aFormatStringOrSqueakFormatArray at:1). |
|
580 |
month := arg at:(aFormatStringOrSqueakFormatArray at:2). |
|
7649 | 581 |
] ifFalse:[ |
16835 | 582 |
|formatStream fc c sel somePartAssoc| |
583 |
||
584 |
formatStream := aFormatStringOrSqueakFormatArray readStream. |
|
585 |
||
586 |
[formatStream atEnd] whileFalse:[ |
|
587 |
fc := formatStream next. |
|
588 |
fc == $% ifTrue:[ |
|
589 |
sel := ''. |
|
590 |
(fc := formatStream peekOrNil) notNil ifTrue:[ |
|
591 |
fc = $( ifTrue:[ |
|
592 |
formatStream next. |
|
593 |
sel := formatStream upTo:$) |
|
7649 | 594 |
] ifFalse:[ |
16835 | 595 |
sel := sel , (formatStream throughAnyForWhich:[:ch | ch isLetter]) |
7649 | 596 |
] |
16835 | 597 |
]. |
598 |
somePartAssoc := self readDatePartFrom:str format:sel language:languageOrNil. |
|
599 |
somePartAssoc key == #day ifTrue:[ |
|
600 |
day := somePartAssoc value. |
|
601 |
] ifFalse:[somePartAssoc key == #month ifTrue:[ |
|
602 |
month := somePartAssoc value. |
|
603 |
] ifFalse:[somePartAssoc key == #year ifTrue:[ |
|
604 |
year := somePartAssoc value. |
|
7649 | 605 |
] ifFalse:[ |
16835 | 606 |
self error:'unexpected date part' |
607 |
]]]. |
|
608 |
] ifFalse:[ |
|
609 |
fc == Character space ifTrue:[ |
|
610 |
"/ Skip most possible separator characters |
|
611 |
"/ (if not enough, should check for isNationalAlphaNumeric instead) |
|
612 |
[(c := str peek) isSeparator |
|
613 |
or:[ '-.:,;/\|?<>[]{}()#@!!$&^+=~*_"`' includes:c]] whileTrue:[str next]. |
|
614 |
] ifFalse:[ |
|
615 |
str skipSeparators. |
|
616 |
str next ~= fc ifTrue:[^ exceptionBlock value]. |
|
617 |
str skipSeparators. |
|
7649 | 618 |
] |
16835 | 619 |
] |
620 |
]. |
|
4997 | 621 |
]. |
7649 | 622 |
|
16835 | 623 |
day isNil ifTrue:[ day := 1 ]. |
624 |
month isNil ifTrue:[ month := 1 ]. |
|
625 |
year isNil ifTrue:[ year := Date today year ]. |
|
626 |
||
627 |
(year between:0 and:99) ifTrue:[ |
|
628 |
year := UserPreferences current twoDigitDateHandler value:year. |
|
629 |
]. |
|
8878 | 630 |
^ self newDay:day month:month year:year. |
631 |
] on:Error do:[:ex| ^ exceptionBlock value]. |
|
4997 | 632 |
|
633 |
" |
|
6624
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
634 |
Date readFrom:'31 December 1992' printFormat:#(1 2 3) onError:'fail' |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
635 |
Date readFrom:'19:11:1999' printFormat:#(1 2 3) onError:'fail' |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
636 |
Date readFrom:'December, 5 1992' printFormat:#(1 2 3) onError:'fail' |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
637 |
Date readFrom:'3-jan-95' printFormat:#(1 2 3) onError:'fail' |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
638 |
Date readFrom:'12/31/1992' printFormat:#(1 2 3) onError:'fail' |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
639 |
Date readFrom:'15.4.1992' printFormat:#(1 2 3) onError:'wrong date' -> german |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
640 |
Date readFrom:'10.4.1992' printFormat:#(1 2 3) onError:'fail' -> german |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
641 |
Date readFrom:'10.4.1992' printFormat:#(1 2 3) onError:['wrong date'] |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
642 |
Date readFrom:'32.4.1992' printFormat:#(1 2 3) onError:['wrong date'] |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
643 |
Date readFrom:'fooBar' printFormat:#(1 2 3) onError:['wrong date'] |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
644 |
Date readFrom:'10.4' printFormat:#(1 2 3) onError:['wrong date'] |
886265eff14c
#readFrom:onError: - avoid block creation
Stefan Vogel <sv@exept.de>
parents:
6419
diff
changeset
|
645 |
Date readFrom:'10041999' printFormat:#(1 2 3) onError:['wrong date'] |
6952
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
646 |
|
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
647 |
Date readFrom:'31/12/92' printFormat:#(1 2 3) onError:'fail' |
a6704f70a3cf
conversion of year in [00..99] to 1900.. no longer done
Claus Gittinger <cg@exept.de>
parents:
6872
diff
changeset
|
648 |
Date readFrom:'31/12/01' printFormat:#(1 2 3) onError:'fail' |
7649 | 649 |
|
650 |
Date readFrom:'31/12/01' printFormat:'%d %m %y' onError:'fail' |
|
651 |
Date readFrom:'12/01' printFormat:'%m %y' onError:'fail' |
|
652 |
Date readFrom:'01' printFormat:'%y' onError:'fail' |
|
12812 | 653 |
Date readFrom:'30.01' printFormat:'%d %m' onError:'fail' |
654 |
||
655 |
Date readFrom:'3-3-1995' printFormat:'%d %m %y' language: #de onError:'fail' |
|
656 |
Date readFrom:'3-März-1995' printFormat:'%d %monthName %y' language: #de onError:'fail' |
|
657 |
Date readFrom:'3-mär-1995' printFormat:'%d %shortMonthName %y' language: #de onError:'fail' |
|
658 |
Date readFrom:'3/mär/1995' printFormat:'%d %shortMonthName %y' language: #de onError:'fail' |
|
659 |
Date readFrom:'3/mär/1995' printFormat:'%d-%shortMonthName-%y' language: #de onError:'fail' |
|
660 |
Date readFrom:'3-dez-1995' printFormat:'%d %shortMonthName %y' language: #de onError:'fail' |
|
661 |
Date readFrom:'3-Dez-1995' printFormat:'%d %shortMonthName %y' language: #de onError:'fail' |
|
662 |
Date readFrom:'3-Dezember-1995' printFormat:'%d %monthName %y' language: #de onError:'fail' |
|
663 |
||
4421 | 664 |
" |
665 |
||
666 |
"Created: 16.11.1995 / 22:50:17 / cg" |
|
667 |
"Modified: 8.10.1996 / 19:25:39 / cg" |
|
668 |
! |
|
669 |
||
11786 | 670 |
readFrom:aStringOrStream printFormat:aSqueakFormatArrayOrFormatString onError:exceptionBlock |
671 |
"return a new Date, reading a printed representation from aStream. |
|
672 |
aSqueakFormatArrayOrFormatString may either be a squeak formatArray |
|
673 |
1 day position (1, 2 or 3) |
|
674 |
2 month position (1..3) |
|
675 |
3 year position (1..3) |
|
676 |
or a formatString (see printing instance protocol). |
|
677 |
All of the %-formats as in the printString are supported here. |
|
678 |
(i.e. %d, %m and %y, %shortMonthName and %monthName) |
|
679 |
TODO: make this a general feature of all DateAndTime classes. |
|
680 |
" |
|
681 |
||
682 |
^ self |
|
683 |
readFrom:aStringOrStream |
|
684 |
printFormat:aSqueakFormatArrayOrFormatString |
|
685 |
language:nil |
|
686 |
onError:exceptionBlock |
|
687 |
||
688 |
" |
|
689 |
Date readFrom:'31 December 1992' printFormat:#(1 2 3) onError:'fail' |
|
690 |
Date readFrom:'19:11:1999' printFormat:#(1 2 3) onError:'fail' |
|
691 |
Date readFrom:'December, 5 1992' printFormat:#(1 2 3) onError:'fail' |
|
692 |
Date readFrom:'3-jan-95' printFormat:#(1 2 3) onError:'fail' |
|
693 |
Date readFrom:'12/31/1992' printFormat:#(1 2 3) onError:'fail' |
|
694 |
Date readFrom:'15.4.1992' printFormat:#(1 2 3) onError:'wrong date' -> german |
|
695 |
Date readFrom:'10.4.1992' printFormat:#(1 2 3) onError:'fail' -> german |
|
696 |
Date readFrom:'10.4.1992' printFormat:#(1 2 3) onError:['wrong date'] |
|
697 |
Date readFrom:'32.4.1992' printFormat:#(1 2 3) onError:['wrong date'] |
|
698 |
Date readFrom:'fooBar' printFormat:#(1 2 3) onError:['wrong date'] |
|
699 |
Date readFrom:'10.4' printFormat:#(1 2 3) onError:['wrong date'] |
|
700 |
Date readFrom:'10041999' printFormat:#(1 2 3) onError:['wrong date'] |
|
701 |
||
702 |
Date readFrom:'31/12/92' printFormat:#(1 2 3) onError:'fail' |
|
703 |
Date readFrom:'31/12/01' printFormat:#(1 2 3) onError:'fail' |
|
704 |
||
705 |
Date readFrom:'31/12/01' printFormat:'%d %m %y' onError:'fail' |
|
706 |
Date readFrom:'12/01' printFormat:'%m %y' onError:'fail' |
|
707 |
Date readFrom:'01' printFormat:'%y' onError:'fail' |
|
708 |
Date readFrom:'30.01' printFormat:'%d %m' onError:'fail' |
|
709 |
" |
|
710 |
||
711 |
"Created: 16.11.1995 / 22:50:17 / cg" |
|
712 |
"Modified: 8.10.1996 / 19:25:39 / cg" |
|
713 |
! |
|
714 |
||
699 | 715 |
today |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
716 |
"return a date, representing today. |
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
717 |
See also: Time now / Timestamp now." |
699 | 718 |
|
1501 | 719 |
^ self fromOSTime:(OperatingSystem getOSTime) |
699 | 720 |
|
721 |
" |
|
722 |
Date today |
|
723 |
" |
|
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
724 |
|
1501 | 725 |
"Modified: 1.7.1996 / 15:20:16 / cg" |
5548 | 726 |
! |
727 |
||
728 |
tomorrow |
|
729 |
"return a date, representing tomorrow. |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
730 |
See also: Time now / Timestamp now." |
5548 | 731 |
|
732 |
^ Date today addDays:1 |
|
733 |
||
734 |
" |
|
735 |
Date tomorrow |
|
736 |
Date tomorrow dayInWeek |
|
737 |
" |
|
738 |
! |
|
739 |
||
13234 | 740 |
utcToday |
741 |
"return a date, representing today. |
|
742 |
See also: Time now / Timestamp now." |
|
743 |
||
744 |
^ self new fromUtcOSTime:(OperatingSystem getOSTime) |
|
745 |
||
746 |
" |
|
747 |
Date today |
|
748 |
Date utcToday |
|
749 |
" |
|
750 |
||
751 |
"Modified: 1.7.1996 / 15:20:16 / cg" |
|
752 |
! |
|
753 |
||
5548 | 754 |
yesterday |
755 |
"return a date, representing yesterday. |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
756 |
See also: Time now / Timestamp now." |
5548 | 757 |
|
758 |
^ Date today subtractDays:1 |
|
759 |
||
760 |
" |
|
761 |
Date yesterday |
|
762 |
Date yesterday dayInWeek |
|
763 |
" |
|
699 | 764 |
! ! |
765 |
||
7299 | 766 |
!Date class methodsFor:'Compatibility-Dolphin'! |
6872 | 767 |
|
768 |
newDay:day monthIndex:month year:year |
|
769 |
^ self newDay:day month:month year:year |
|
770 |
||
771 |
" |
|
772 |
Date newDay:8 monthIndex:5 year:1993 |
|
773 |
" |
|
774 |
||
775 |
"Modified: 19.4.1996 / 15:28:15 / cg" |
|
776 |
! ! |
|
777 |
||
7646 | 778 |
!Date class methodsFor:'Compatibility-ST80'! |
779 |
||
7648 | 780 |
newDay:day monthNumber:monthIndex year:year |
7646 | 781 |
"ST80 compatibility" |
782 |
||
783 |
^ self newDay:day month:monthIndex year:year |
|
784 |
! ! |
|
785 |
||
7299 | 786 |
!Date class methodsFor:'Compatibility-Squeak'! |
7005 | 787 |
|
11815 | 788 |
current |
789 |
"return the current date" |
|
790 |
||
791 |
^ self today |
|
792 |
||
793 |
" |
|
794 |
Date current |
|
795 |
" |
|
796 |
! |
|
797 |
||
7005 | 798 |
fromSeconds:seconds |
799 |
"Answer an instance of me which is 'seconds' seconds after January 1, 1901." |
|
800 |
||
801 |
| secondsInDay | |
|
802 |
||
803 |
secondsInDay := 24 * 60 * 60. |
|
804 |
^self fromDays: seconds // secondsInDay |
|
805 |
||
806 |
" |
|
807 |
Date fromSeconds:0 |
|
808 |
Date fromSeconds:(24 * 60 * 60 * 365) |
|
809 |
" |
|
11181 | 810 |
! |
811 |
||
812 |
readMMDDYYYYFrom:aStringOrStream onError:exceptionBlock |
|
813 |
"return a new Date, reading a printed representation from aStream. |
|
814 |
Notice, that this is not the storeString format and |
|
815 |
is different from the format expected by readFrom:" |
|
816 |
||
817 |
^ [ |
|
11182 | 818 |
|str monthString month dayString day year yearString| |
11181 | 819 |
|
820 |
str := aStringOrStream readStream. |
|
11182 | 821 |
monthString := str next:2. |
822 |
dayString := str next:2. |
|
823 |
yearString := str next:4. |
|
824 |
||
825 |
day := Integer readFrom:dayString. |
|
826 |
month := Integer readFrom:monthString. |
|
827 |
year := Integer readFrom:yearString. |
|
11181 | 828 |
|
829 |
self newDay:day month:month year:year |
|
830 |
] on:Error do:exceptionBlock |
|
831 |
||
832 |
" |
|
833 |
Date readMMDDYYYYFrom:'10041999' onError:['wrong date'] |
|
834 |
Date readMMDDYYYYFrom:'100419' onError:['wrong date'] |
|
835 |
||
836 |
Date readMMDDYYYYFrom:'10040001' onError:['wrong date'] |
|
837 |
" |
|
838 |
||
839 |
"Created: 16.11.1995 / 22:50:17 / cg" |
|
840 |
"Modified: 8.10.1996 / 19:25:39 / cg" |
|
841 |
! |
|
842 |
||
843 |
readYYYYMMDDFrom:aStringOrStream onError:exceptionBlock |
|
844 |
"return a new Date, reading a printed representation from aStream. |
|
845 |
Notice, that this is not the storeString format and |
|
846 |
is different from the format expected by readFrom:" |
|
847 |
||
848 |
^ [ |
|
11182 | 849 |
|str monthString month dayString day yearString year| |
11181 | 850 |
|
851 |
str := aStringOrStream readStream. |
|
11182 | 852 |
yearString := str next:4. |
853 |
monthString := str next:2. |
|
854 |
dayString := str next:2. |
|
855 |
||
856 |
day := Integer readFrom:dayString. |
|
857 |
month := Integer readFrom:monthString. |
|
858 |
year := Integer readFrom:yearString. |
|
11181 | 859 |
|
860 |
self newDay:day month:month year:year |
|
861 |
] on:Error do:exceptionBlock |
|
862 |
||
863 |
" |
|
864 |
Date readYYYYMMDDFrom:'19991004' onError:['wrong date'] |
|
11182 | 865 |
Date readYYYYMMDDFrom:'911004' onError:['wrong date'] |
11181 | 866 |
" |
16191 | 867 |
! |
868 |
||
869 |
year:yr month:mon day:day |
|
870 |
^ self newDay:day month:mon year:yr |
|
7005 | 871 |
! ! |
872 |
||
17053 | 873 |
|
11553 | 874 |
!Date class methodsFor:'change & update'! |
875 |
||
876 |
update:something with:aParameter from:changedObject |
|
877 |
((something == #Language) or:[something == #LanguageTerritory]) ifTrue:[ |
|
878 |
"just remember change for next access" |
|
879 |
EnvironmentChange := true |
|
880 |
] |
|
881 |
||
882 |
"Created: 15.6.1996 / 15:19:25 / cg" |
|
883 |
! ! |
|
884 |
||
11127 | 885 |
!Date class methodsFor:'error handling'! |
886 |
||
887 |
conversionErrorSignal |
|
888 |
"return the signal used for conversion error handling" |
|
889 |
||
890 |
^ DateConversionError |
|
891 |
! ! |
|
892 |
||
2706
878723bc99fc
added #shortPrintString for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1701
diff
changeset
|
893 |
!Date class methodsFor:'general queries'! |
699 | 894 |
|
16913 | 895 |
abbreviatedDayNamesForLanguage:languageOrNilForDefault |
896 |
"return a collection of short month-names for a given language or the |
|
897 |
current language if nil is given. |
|
898 |
The returned strings depend on the resource translation file to be present for the |
|
899 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
900 |
If not, english names are returned" |
|
901 |
||
902 |
|langDayAbbrevs lang| |
|
903 |
||
904 |
(DayAbbrevs isNil or:[EnvironmentChange]) ifTrue:[ |
|
905 |
self initNames |
|
906 |
]. |
|
907 |
lang := languageOrNilForDefault notNil ifTrue:[languageOrNilForDefault] ifFalse:[Smalltalk language]. |
|
908 |
langDayAbbrevs := DayAbbrevs at:lang ifAbsent:nil. |
|
909 |
||
910 |
"/ If language is not found, try to initialize it from the resources and try again |
|
911 |
langDayAbbrevs isNil ifTrue:[ |
|
912 |
self initNamesForLanguage: lang. |
|
913 |
"/ If language initialization failed, take english dayAbbrevs |
|
914 |
langDayAbbrevs := DayAbbrevs at:lang ifAbsent:[DayAbbrevs at:#en.]. |
|
915 |
]. |
|
916 |
^ langDayAbbrevs |
|
917 |
||
918 |
" |
|
919 |
self abbreviatedDayNamesForLanguage:#en |
|
920 |
self abbreviatedDayNamesForLanguage:#de |
|
921 |
self abbreviatedDayNamesForLanguage:#fr |
|
922 |
self abbreviatedDayNamesForLanguage:#es |
|
923 |
self abbreviatedDayNamesForLanguage:#zulu |
|
924 |
||
925 |
self abbreviatedDayNamesForLanguage:nil |
|
926 |
" |
|
927 |
! |
|
928 |
||
929 |
abbreviatedMonthNamesForLanguage:languageOrNilForDefault |
|
930 |
"return a collection of short month-names for a given language or the |
|
931 |
current language if nil is given. |
|
932 |
The returned strings depend on the resource translation file to be present for the |
|
933 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
934 |
If not, english names are returned" |
|
935 |
||
936 |
|langMonthAbbrevs lang| |
|
937 |
||
938 |
(MonthAbbrevs isNil or:[EnvironmentChange]) ifTrue:[ |
|
939 |
self initNames |
|
940 |
]. |
|
941 |
lang := languageOrNilForDefault notNil ifTrue:[languageOrNilForDefault] ifFalse:[Smalltalk language]. |
|
942 |
langMonthAbbrevs := MonthAbbrevs at:lang ifAbsent:nil. |
|
943 |
||
944 |
"/ If language is not found, try to initialize it from the resources and try again |
|
945 |
langMonthAbbrevs isNil ifTrue:[ |
|
946 |
self initNamesForLanguage: lang. |
|
947 |
"/ If language initialization failed, take english monthAbbrevs |
|
948 |
langMonthAbbrevs := MonthAbbrevs at:lang ifAbsent:[MonthAbbrevs at:#en.]. |
|
949 |
]. |
|
950 |
^ langMonthAbbrevs |
|
951 |
||
952 |
" |
|
953 |
self abbreviatedMonthNamesForLanguage:#en |
|
954 |
self abbreviatedMonthNamesForLanguage:#de |
|
955 |
self abbreviatedMonthNamesForLanguage:#fr |
|
956 |
self abbreviatedMonthNamesForLanguage:#es |
|
957 |
self abbreviatedMonthNamesForLanguage:#zulu |
|
958 |
||
959 |
self abbreviatedMonthNamesForLanguage:nil |
|
960 |
" |
|
961 |
||
962 |
"Modified (format): / 18-07-2011 / 09:34:20 / cg" |
|
963 |
! |
|
964 |
||
699 | 965 |
abbreviatedNameOfDay:dayIndex |
16913 | 966 |
"given a day index (1..7), |
967 |
return the abbreviated name of the day |
|
968 |
for the current language setting" |
|
699 | 969 |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
970 |
^ self abbreviatedNameOfDay:dayIndex language:nil |
699 | 971 |
|
972 |
" |
|
973 |
Date abbreviatedNameOfDay:4 |
|
974 |
" |
|
975 |
! |
|
976 |
||
16913 | 977 |
abbreviatedNameOfDay:dayIndex language:langOrNilForDefault |
978 |
"given a day index (1..7), |
|
979 |
return the abbreviated name of the day. |
|
980 |
For nil, the current default language us used. |
|
981 |
For unknown languages, english is used." |
|
982 |
||
983 |
^ (self abbreviatedDayNamesForLanguage:langOrNilForDefault) at:dayIndex |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
984 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
985 |
" |
16913 | 986 |
Date abbreviatedNameOfDay:4 language:#en |
987 |
Date abbreviatedNameOfDay:4 language:#de |
|
988 |
Date abbreviatedNameOfDay:4 language:#zulu |
|
989 |
Date abbreviatedNameOfDay:4 language:nil |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
990 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
991 |
! |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
992 |
|
699 | 993 |
abbreviatedNameOfMonth:monthIndex |
16913 | 994 |
"given a month index (1..12), |
995 |
return the abbreviated name of the month |
|
996 |
for the current language setting" |
|
997 |
||
699 | 998 |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
999 |
^ self abbreviatedNameOfMonth:monthIndex language:nil |
699 | 1000 |
|
1001 |
" |
|
1002 |
Date abbreviatedNameOfMonth:11 |
|
1003 |
Date abbreviatedNameOfMonth:12 |
|
1004 |
" |
|
1005 |
! |
|
1006 |
||
16913 | 1007 |
abbreviatedNameOfMonth:monthIndex language:langOrNilForDefault |
1008 |
"given a month index (1..12), |
|
1009 |
return the abbreviated name of the month. |
|
1010 |
For nil, the current default language us used. |
|
1011 |
For unknown languages, english is used." |
|
1012 |
||
1013 |
^ (self abbreviatedMonthNamesForLanguage:langOrNilForDefault) at:monthIndex |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1014 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1015 |
" |
16913 | 1016 |
Date abbreviatedNameOfMonth:11 language:#en |
1017 |
Date abbreviatedNameOfMonth:12 language:#en |
|
1018 |
Date abbreviatedNameOfMonth:12 language:#de |
|
1019 |
Date abbreviatedNameOfMonth:12 language:#fr |
|
1020 |
Date abbreviatedNameOfMonth:12 language:#zulu |
|
1021 |
Date abbreviatedNameOfMonth:12 language:nil |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1022 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1023 |
! |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1024 |
|
699 | 1025 |
dateAndTimeNow |
16983 | 1026 |
"return an array containing the date and time of now. |
1027 |
As these provide no timezone info, this should be only used for user interface purposes." |
|
699 | 1028 |
|
1029 |
^ Time dateAndTimeNow |
|
1030 |
||
1031 |
" |
|
1032 |
Date dateAndTimeNow |
|
1033 |
" |
|
1034 |
! |
|
1035 |
||
16913 | 1036 |
dayNamesForLanguage:languageOrNilForDefault |
1037 |
"return a collection of day-names for a given language or the |
|
1038 |
current language if nil is given. |
|
1039 |
The returned strings depend on the resource translation file to be present for the |
|
1040 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
1041 |
If not, english names are returned" |
|
1042 |
||
1043 |
|langDayNames lang| |
|
1044 |
||
1045 |
(DayNames isNil or:[EnvironmentChange]) ifTrue:[ |
|
1046 |
self initNames |
|
1047 |
]. |
|
1048 |
lang := languageOrNilForDefault notNil ifTrue:[languageOrNilForDefault] ifFalse:[Smalltalk language]. |
|
1049 |
langDayNames := DayNames at:lang ifAbsent:nil. |
|
1050 |
||
1051 |
"/ If language is not found, try to initialize it from the resources and try again |
|
1052 |
langDayNames isNil ifTrue:[ |
|
1053 |
self initNamesForLanguage: lang. |
|
1054 |
"/ If language initialization failed, take english dayNames |
|
1055 |
langDayNames := DayNames at:lang ifAbsent:[DayNames at:#en]. |
|
1056 |
]. |
|
1057 |
^ langDayNames |
|
1058 |
||
1059 |
" |
|
1060 |
self dayNamesForLanguage:#en |
|
1061 |
self dayNamesForLanguage:#de |
|
1062 |
self dayNamesForLanguage:#fr |
|
1063 |
self dayNamesForLanguage:#es |
|
1064 |
||
1065 |
self dayNamesForLanguage:#zulu |
|
1066 |
self dayNamesForLanguage:nil |
|
1067 |
" |
|
1068 |
||
1069 |
"Modified (format): / 18-07-2011 / 09:34:08 / cg" |
|
1070 |
! |
|
1071 |
||
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1072 |
dayOfFirstWeekInYear:aYear |
16913 | 1073 |
"for a given year, return the day corresponding to that year's monday of week-01. |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1074 |
The 1st week is the one, in which the first thursday is found; |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1075 |
and the 1st day of that week is the preceeding monday |
16983 | 1076 |
(that means: that the returned day might be a day of the previous year!!)" |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1077 |
|
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1078 |
|day dayInWeekOf1stJan firstThursday firstDayInWeek| |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1079 |
|
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1080 |
"/ find the first thursday ... |
11127 | 1081 |
day := Date newDay:1 year:aYear. |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1082 |
dayInWeekOf1stJan := day dayInWeek. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1083 |
dayInWeekOf1stJan > 4 ifTrue:[ |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1084 |
firstThursday := day addDays:(4 - dayInWeekOf1stJan + 7). |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1085 |
] ifFalse:[ |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1086 |
firstThursday := day addDays:(4 - dayInWeekOf1stJan). |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1087 |
]. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1088 |
"/ back to the preceeding monday |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1089 |
firstDayInWeek := firstThursday subtractDays:3. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1090 |
^ firstDayInWeek |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1091 |
|
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1092 |
" |
14496 | 1093 |
Date newDay:1 year:1900 |
1094 |
Date dayOfFirstWeekInYear:1900 |
|
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1095 |
Date dayOfFirstWeekInYear:1998 |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1096 |
Date dayOfFirstWeekInYear:1999 |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1097 |
Date dayOfFirstWeekInYear:2000 |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1098 |
Date dayOfFirstWeekInYear:2001 |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1099 |
" |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1100 |
! |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1101 |
|
699 | 1102 |
dayOfWeek:dayName |
1103 |
"given the name of a day (either string or symbol), |
|
1104 |
return the day-index (1 for monday; 7 for sunday). |
|
1105 |
Return 0 for invalid day name" |
|
1106 |
||
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1107 |
|d| |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1108 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1109 |
d := self dayOfWeek:dayName language:nil. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1110 |
d == 0 ifTrue:[ |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1111 |
d := self dayOfWeek:dayName language:'en'. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1112 |
]. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1113 |
^ d |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1114 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1115 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1116 |
Date dayOfWeek:'wednesday' |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1117 |
Date dayOfWeek:'Wednesday' |
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1118 |
Date dayOfWeek:'Mittwoch' |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1119 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1120 |
! |
6976 | 1121 |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1122 |
dayOfWeek:dayName language:lang |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1123 |
"given the name of a day (either string or symbol), |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1124 |
return the day-index (1 for monday; 7 for sunday). |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1125 |
Return 0 for invalid day name. |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1126 |
For nil, Smalltalk language is used, |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1127 |
for unknown languages, english is used." |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1128 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1129 |
|idx langDayNames| |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1130 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1131 |
langDayNames := self dayNamesForLanguage:lang. |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1132 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1133 |
idx := langDayNames indexOf:dayName. |
6976 | 1134 |
idx == 0 ifTrue:[ |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1135 |
idx := langDayNames indexOf:dayName asLowercase. |
6976 | 1136 |
]. |
1137 |
^ idx |
|
699 | 1138 |
|
1139 |
" |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1140 |
Date dayOfWeek:'wednesday' language:'en' |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1141 |
Date dayOfWeek:'Wednesday' language:'en' |
699 | 1142 |
" |
1143 |
! |
|
1144 |
||
1145 |
daysInMonth:month forYear:yearInteger |
|
1146 |
"given the name of a month and a year, return the number |
|
1147 |
of days this month has (modified GNU). |
|
1148 |
return 0 if the month name was invalid. |
|
1149 |
For your convenience, month maybe an integer or name-string." |
|
1150 |
||
1151 |
|monthIndex "{ Class: SmallInteger }"| |
|
1152 |
||
1153 |
month isInteger ifTrue:[ |
|
1154 |
monthIndex := month |
|
1155 |
] ifFalse:[ |
|
1156 |
monthIndex := self indexOfMonth:month |
|
1157 |
]. |
|
1158 |
||
1159 |
^ self daysInMonthIndex:monthIndex forYear:yearInteger |
|
1160 |
||
1161 |
" |
|
1162 |
Date daysInMonth:2 forYear:1980 |
|
1163 |
Date daysInMonth:2 forYear:1981 |
|
1164 |
Date daysInMonth:'feb' forYear:1981 |
|
1165 |
" |
|
1166 |
! |
|
1167 |
||
1168 |
daysInYear:yearInteger |
|
1169 |
"return the number of days in a year" |
|
1170 |
||
1171 |
(self leapYear:yearInteger) ifTrue:[^ 366]. |
|
1172 |
^ 365 |
|
1173 |
||
1174 |
" |
|
1175 |
Date daysInYear:1900 |
|
1176 |
Date daysInYear:1901 |
|
1177 |
Date daysInYear:1904 |
|
1178 |
Date daysInYear:1980 |
|
1179 |
Date daysInYear:1981 |
|
1180 |
" |
|
1181 |
! |
|
1182 |
||
1183 |
daysUntilMonth:month forYear:yearInteger |
|
1184 |
"given the name of a month and a year, return the number |
|
1185 |
of days from 1st january to last of prev month of that year. |
|
1186 |
Return 0 if the month name/index is invalid or is january. |
|
1187 |
For your convenience, month maybe an integer or name-string." |
|
1188 |
||
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1189 |
|monthIndex| |
699 | 1190 |
|
1191 |
month isInteger ifTrue:[ |
|
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1192 |
monthIndex := month |
699 | 1193 |
] ifFalse:[ |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1194 |
monthIndex := self indexOfMonth:month |
699 | 1195 |
]. |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1196 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1197 |
^ self daysUntilMonthIndex:monthIndex forYear:yearInteger |
699 | 1198 |
|
1199 |
" |
|
1200 |
Date daysUntilMonth:'feb' forYear:1993 |
|
1201 |
Date daysUntilMonth:'jan' forYear:1993 |
|
1202 |
" |
|
1203 |
! |
|
1204 |
||
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1205 |
defaultFormatString |
16983 | 1206 |
"a language specific format string to present dates in user interfaces. |
1207 |
Do not use this to store/retrieve dates (use ISO8601 for that)" |
|
1208 |
||
8118 | 1209 |
(DefaultFormats isNil or:[EnvironmentChange]) ifTrue:[ |
16983 | 1210 |
self initNames |
8118 | 1211 |
]. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1212 |
^ DefaultFormats at:Language ifAbsent:(DefaultFormats at:#en). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1213 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1214 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1215 |
Date today printStringFormat:(Date defaultFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1216 |
Date today printStringFormat:(Date longFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1217 |
Date today printStringFormat:(Date shortFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1218 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1219 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1220 |
|
5778 | 1221 |
firstDayOfYear:inYear |
1222 |
"return the weekDay-index of the 1st-january of the given year. |
|
1223 |
1->monday, 2->tuesday, ... 7->sunday" |
|
1224 |
||
1225 |
| t d | |
|
1226 |
||
1227 |
((inYear < 1) or:[ inYear > 9999]) ifTrue:[ |
|
1228 |
^ 0. |
|
1229 |
]. |
|
1230 |
||
1231 |
"/ normal Gregorian calendar: one extra day per four years |
|
1232 |
t := 4 + inYear + ((inYear + 3) // 4). |
|
1233 |
||
1234 |
inYear > 1800 ifTrue:[ |
|
1235 |
"/ Julian calendar: regular Gregorian less 3 days per 400 |
|
1236 |
t := t - ((inYear - 1701) // 100) + ((inYear - 1601) // 400). |
|
1237 |
]. |
|
1238 |
inYear > 1752 ifTrue:[ |
|
1239 |
"/ calendar changeover |
|
1240 |
t := t + 3. |
|
1241 |
]. |
|
1242 |
d := t \\ 7. |
|
1243 |
"/ convert from 0 (sunday) .. 6 (saturday) |
|
1244 |
"/ to 1 (munday) .. 7 (sunday) |
|
1245 |
d == 0 ifTrue:[^ 7]. |
|
1246 |
^ d |
|
1247 |
||
1248 |
" |
|
1249 |
self firstDayOfYear:2000 |
|
1250 |
(Date newDay:1 year:2000) dayInWeek |
|
1251 |
self firstDayOfYear:1999 |
|
1252 |
(Date newDay:1 year:1999) dayInWeek |
|
1253 |
self firstDayOfYear:1998 |
|
1254 |
(Date newDay:1 year:1998) dayInWeek |
|
1255 |
self firstDayOfYear:2001 |
|
1256 |
(Date newDay:1 year:2001) dayInWeek |
|
1257 |
self firstDayOfYear:2002 |
|
1258 |
(Date newDay:1 year:2002) dayInWeek |
|
1259 |
self firstDayOfYear:2006 |
|
1260 |
(Date newDay:1 year:2006) dayInWeek |
|
1261 |
||
1262 |
self firstDayOfYear:1800 |
|
1263 |
(Date newDay:1 year:1800) dayInWeek |
|
1264 |
" |
|
1265 |
! |
|
1266 |
||
699 | 1267 |
indexOfMonth:aMonthString |
1268 |
"given the name of a month (either string or symbol), |
|
1269 |
return the month-index (1 for jan; 12 for december). |
|
1270 |
The given string may be a full or abbreviated name, |
|
1271 |
case is ignored. |
|
1272 |
Return 0 for invalid month name." |
|
1273 |
||
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1274 |
|monthIndex| |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1275 |
|
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1276 |
monthIndex := self indexOfMonth:aMonthString language:nil. |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1277 |
"/ if not found, retry in english |
12105 | 1278 |
(monthIndex == 0 and:[ Smalltalk language ~= 'en' ]) |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1279 |
ifTrue:[ |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1280 |
monthIndex := self indexOfMonth:aMonthString language:'en'. |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1281 |
]. |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1282 |
^ monthIndex |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1283 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1284 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1285 |
Date indexOfMonth:'jan' |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1286 |
Date indexOfMonth:'Jan' |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1287 |
Date indexOfMonth:'December' |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1288 |
Date indexOfMonth:'Dezember' |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1289 |
Date indexOfMonth:'december' |
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1290 |
Date indexOfMonth:'dezember' |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1291 |
" |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1292 |
|
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1293 |
"Modified: / 08-10-2006 / 14:22:06 / cg" |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1294 |
! |
699 | 1295 |
|
14714 | 1296 |
indexOfMonth:aMonthString language:languageOrNil |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1297 |
"given the name of a month (either string or symbol), |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1298 |
return the month-index (1 for jan; 12 for december). |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1299 |
The given string may be a full or abbreviated name, |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1300 |
case is ignored. |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1301 |
Return 0 for invalid month name. |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1302 |
For nil, Smalltalk language (i.e. the current language setting) is used, |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1303 |
for unknown languages, english is used." |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1304 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1305 |
|idx name langMonthNames langMonthAbbrevs| |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1306 |
|
14714 | 1307 |
langMonthNames := self monthNamesForLanguage:languageOrNil. |
16839 | 1308 |
langMonthAbbrevs := self abbreviatedMonthNamesForLanguage:languageOrNil. |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1309 |
|
699 | 1310 |
name := aMonthString asLowercase. |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1311 |
idx := langMonthAbbrevs indexOf:name. |
699 | 1312 |
idx ~~ 0 ifTrue:[^ idx]. |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1313 |
idx := langMonthNames indexOf:name. |
699 | 1314 |
idx ~~ 0 ifTrue:[^ idx]. |
1315 |
||
1316 |
name at:1 put:(name at:1) asUppercase. |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1317 |
idx := langMonthAbbrevs indexOf:name. |
699 | 1318 |
idx ~~ 0 ifTrue:[^ idx]. |
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1319 |
idx := langMonthNames indexOf:name. |
699 | 1320 |
idx ~~ 0 ifTrue:[^ idx]. |
1321 |
||
1322 |
^ idx |
|
1323 |
||
1324 |
" |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1325 |
Date indexOfMonth:'jan' language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1326 |
Date indexOfMonth:'Jan' language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1327 |
Date indexOfMonth:'December' language:#en |
699 | 1328 |
" |
10056
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1329 |
|
3c8e8c867a13
indexofmonth: try english as second chance
Claus Gittinger <cg@exept.de>
parents:
9262
diff
changeset
|
1330 |
"Modified: / 08-10-2006 / 14:20:17 / cg" |
699 | 1331 |
! |
1332 |
||
1333 |
leapYear:yearInteger |
|
16971 | 1334 |
"return true, if yearInteger is a leap year. |
1335 |
For years before 1583, the proleptic calendar is used |
|
1336 |
(i.e. assuming there was a gregorian calendar in effect)" |
|
699 | 1337 |
|
1338 |
|y "{ Class: SmallInteger }"| |
|
1339 |
||
1340 |
y := yearInteger. |
|
1341 |
(y \\ 4 == 0) ifTrue:[ |
|
16971 | 1342 |
(y \\ 100 ~~ 0) ifTrue:[^ true]. |
1343 |
(y \\ 400 == 0) ifTrue:[^ true] |
|
699 | 1344 |
]. |
1345 |
^ false |
|
1346 |
||
1347 |
" |
|
1348 |
Date leapYear:1992 |
|
1349 |
Date leapYear:1994 |
|
1350 |
Date leapYear:1900 |
|
1351 |
Date leapYear:2000 |
|
16971 | 1352 |
|
1353 |
Date leapYear:0 |
|
1354 |
Date leapYear:-1 |
|
1355 |
Date leapYear:-2 |
|
1356 |
Date leapYear:-3 |
|
1357 |
Date leapYear:-4 |
|
699 | 1358 |
" |
1359 |
! |
|
1360 |
||
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1361 |
longFormatString |
8118 | 1362 |
(LongFormats isNil or:[EnvironmentChange]) ifTrue:[ |
1363 |
self initNames |
|
1364 |
]. |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1365 |
^ LongFormats at:Language ifAbsent:(LongFormats at:#en). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1366 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1367 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1368 |
Date today printStringFormat:(Date defaultFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1369 |
Date today printStringFormat:(Date longFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1370 |
Date today printStringFormat:(Date shortFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1371 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1372 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1373 |
|
699 | 1374 |
monthAndDayFromDayInYear:aDayInYear forYear:yearInteger |
1375 |
"given a day-in-year (1..365) return an Array containing the |
|
1376 |
month index and the day-in-month. Return nil if the argument is invalid." |
|
1377 |
||
1378 |
|restDays daysInMonth| |
|
1379 |
||
1380 |
restDays := aDayInYear. |
|
1381 |
restDays < 1 ifTrue:[^ nil]. |
|
1382 |
||
1383 |
1 to:12 do:[:m | |
|
1384 |
daysInMonth := self daysInMonthIndex:m forYear:yearInteger. |
|
1385 |
restDays <= daysInMonth ifTrue:[ |
|
1386 |
^ Array with:m with:restDays |
|
1387 |
]. |
|
1388 |
restDays := restDays - daysInMonth |
|
1389 |
]. |
|
1390 |
restDays > daysInMonth ifTrue:[^ nil]. |
|
1391 |
^ Array with:12 with:restDays |
|
1392 |
||
1393 |
" |
|
1394 |
Date monthAndDayFromDayInYear:66 forYear:1980 |
|
1395 |
Date monthAndDayFromDayInYear:66 forYear:1981 |
|
1396 |
" |
|
1397 |
! |
|
1398 |
||
16913 | 1399 |
monthNamesForLanguage:languageOrNilForDefault |
1400 |
"return a collection of month-names for a given language or the |
|
1401 |
current language if nil is given. |
|
1402 |
The returned strings depend on the resource translation file to be present for the |
|
1403 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
1404 |
If not, english names are returned" |
|
1405 |
||
1406 |
|langMonthNames lang| |
|
1407 |
||
1408 |
(MonthNames isNil or:[EnvironmentChange]) ifTrue:[ |
|
1409 |
self initNames |
|
1410 |
]. |
|
1411 |
lang := languageOrNilForDefault notNil ifTrue:[languageOrNilForDefault] ifFalse:[Smalltalk language]. |
|
1412 |
langMonthNames := MonthNames at:lang ifAbsent:nil. |
|
1413 |
||
1414 |
"/ If language is not found, try to initialize it from the resources and try again |
|
1415 |
langMonthNames isNil ifTrue:[ |
|
1416 |
self initNamesForLanguage: lang. |
|
1417 |
"/ If language initialization failed, take english monthNames |
|
1418 |
langMonthNames := MonthNames at:lang ifAbsent:[MonthNames at:#en.]. |
|
1419 |
]. |
|
1420 |
^ langMonthNames |
|
1421 |
||
1422 |
" |
|
1423 |
self monthNamesForLanguage:#en |
|
1424 |
self monthNamesForLanguage:#de |
|
1425 |
self monthNamesForLanguage:#fr |
|
1426 |
self monthNamesForLanguage:#es |
|
1427 |
||
1428 |
self monthNamesForLanguage:#zulu |
|
1429 |
self monthNamesForLanguage:nil |
|
1430 |
" |
|
1431 |
||
1432 |
"Modified: / 18-07-2011 / 09:34:32 / cg" |
|
1433 |
! |
|
1434 |
||
699 | 1435 |
nameOfDay:dayIndex |
1436 |
"given a day index (1..7), return the name of the day" |
|
1437 |
||
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1438 |
^ self nameOfDay:dayIndex language:nil |
699 | 1439 |
|
1440 |
" |
|
8795 | 1441 |
Date nameOfDay:1 |
699 | 1442 |
Date nameOfDay:4 |
1443 |
" |
|
1444 |
! |
|
1445 |
||
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1446 |
nameOfDay:dayIndex language:lang |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1447 |
"given a day index (1..7), return the name of the day. |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1448 |
For nil, Smalltalk language is used, |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1449 |
for unknown languages, english is used." |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1450 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1451 |
^ (self dayNamesForLanguage:lang) at:dayIndex |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1452 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1453 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1454 |
Date nameOfDay:4 language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1455 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1456 |
! |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1457 |
|
699 | 1458 |
nameOfMonth:monthIndex |
1459 |
"given a month index (1..12), return the name of the month" |
|
1460 |
||
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1461 |
^ self nameOfMonth:monthIndex language:nil |
699 | 1462 |
|
1463 |
" |
|
1464 |
Date nameOfMonth:11 |
|
1465 |
Date nameOfMonth:12 |
|
1466 |
Date nameOfMonth:4 |
|
1467 |
" |
|
1468 |
! |
|
1469 |
||
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1470 |
nameOfMonth:monthIndex language:lang |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1471 |
"given a month index (1..12), return the name of the month. |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1472 |
For nil, Smalltalk language is used, |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1473 |
for unknown languages, english is used." |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1474 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1475 |
^ (self monthNamesForLanguage:lang) at:monthIndex |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1476 |
|
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1477 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1478 |
Date nameOfMonth:11 language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1479 |
Date nameOfMonth:12 language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1480 |
Date nameOfMonth:4 language:#en |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1481 |
" |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1482 |
! |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1483 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1484 |
shortFormatString |
8118 | 1485 |
(ShortFormats isNil or:[EnvironmentChange]) ifTrue:[ |
1486 |
self initNames |
|
1487 |
]. |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1488 |
^ ShortFormats at:Language ifAbsent:(ShortFormats at:#en). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1489 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1490 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1491 |
Date today printStringFormat:(Date defaultFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1492 |
Date today printStringFormat:(Date longFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1493 |
Date today printStringFormat:(Date shortFormatString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1494 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1495 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
1496 |
|
5548 | 1497 |
weekInYearOf:aDateOrTimestamp |
1498 |
"for a given date or timeStamp, return the week-number. |
|
14496 | 1499 |
The returned week number starts with 1 for the first week which has a thursday in it. |
1500 |
(see DIN 1355-1/ISO 8601) |
|
1501 |
The rule is: |
|
1502 |
every monday (and only monday), a new week begins |
|
1503 |
the first week is the one which has at least 4 days of the new year in it |
|
1504 |
||
1505 |
Be prepared: this definition can lead to the 1st week starting in the old year!!" |
|
5548 | 1506 |
|
13234 | 1507 |
|date dayInYear numDays dayOfFirstWeekInYear dayOfFirstWeekInNextYear week| |
1508 |
||
1509 |
date := aDateOrTimestamp asDate. |
|
1510 |
||
1511 |
dayInYear := date dayInYear. |
|
1512 |
dayOfFirstWeekInYear := self dayOfFirstWeekInYear:date year. |
|
1513 |
||
1514 |
numDays := date subtractDate:dayOfFirstWeekInYear. |
|
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1515 |
"/ careful with the first days - could be W52/W53 of the previous year ... |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1516 |
numDays < 0 ifTrue:[ |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1517 |
"/ not in a week here ... |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1518 |
"/ can be either 52 or 53, depending on the previous year. |
13234 | 1519 |
^ self weekInYearOf:(Date newDay:31 month:12 year:date year - 1) |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1520 |
]. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1521 |
|
5548 | 1522 |
"/ compute the week |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1523 |
week := numDays // 7 + 1. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1524 |
|
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1525 |
"/ careful with the last days - could be W01 of the next year ... |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1526 |
week == 53 ifTrue:[ |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1527 |
dayOfFirstWeekInNextYear := self dayOfFirstWeekInYear:aDateOrTimestamp year + 1. |
13234 | 1528 |
date >= dayOfFirstWeekInNextYear ifTrue:[ |
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1529 |
^ 1 |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1530 |
]. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1531 |
]. |
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
1532 |
^ week |
5548 | 1533 |
|
1534 |
" |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1535 |
Timestamp now weekInYear |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1536 |
Date weekInYearOf:(Date newDay:31 month:12 year:1999) was a friday; |
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1537 |
Date weekInYearOf:(Timestamp newDay:1 year:2000) was a saturday; therefore last week of 1999 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1538 |
Date weekInYearOf:(Timestamp newDay:2 year:2000) was a sunday; therefore last week of 1999 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1539 |
Date weekInYearOf:(Timestamp newDay:3 year:2000) was a monday -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1540 |
Date weekInYearOf:(Timestamp newDay:4 year:2000) was a tuesday -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1541 |
Date weekInYearOf:(Timestamp newDay:5 year:2000) was a wed -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1542 |
Date weekInYearOf:(Timestamp newDay:6 year:2000) was a thursday -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1543 |
Date weekInYearOf:(Timestamp newDay:7 year:2000) was a fri -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1544 |
Date weekInYearOf:(Timestamp newDay:8 year:2000) was a sat -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1545 |
Date weekInYearOf:(Timestamp newDay:9 year:2000) was a sun -> W01 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1546 |
Date weekInYearOf:(Timestamp newDay:10 year:2000) was a monday -> W02 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1547 |
Date weekInYearOf:(Timestamp newDay:16 year:2000) was a sunday -> W02 |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
1548 |
Date weekInYearOf:(Timestamp newDay:17 year:2000) was a monday -> W03 |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1549 |
Date weekInYearOf:(Date newDay:1 month:1 year:2001) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1550 |
Date weekInYearOf:(Date newDay:2 month:1 year:2001) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1551 |
Date weekInYearOf:(Date newDay:3 month:1 year:2001) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1552 |
Date weekInYearOf:(Date newDay:24 month:12 year:2001) -> W52 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1553 |
Date weekInYearOf:(Date newDay:30 month:12 year:2001) -> W52 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1554 |
Date weekInYearOf:(Date newDay:31 month:12 year:2001) -> W01 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1555 |
Date weekInYearOf:(Date newDay:1 month:1 year:2002) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1556 |
Date weekInYearOf:(Date newDay:2 month:1 year:2002) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1557 |
Date weekInYearOf:(Date newDay:7 month:1 year:2002) |
16913 | 1558 |
Date weekInYearOf:(Date newDay:26 month:9 year:2008) |
1559 |
Date weekInYearOf:(Date newDay:27 month:9 year:2008) |
|
1560 |
Date weekInYearOf:(Date newDay:4 month:1 year:2008) |
|
1561 |
||
1562 |
Date weekInYearOf:(Date newDay:1 month:1 year:2010) |
|
1563 |
Date weekInYearOf:(Date newDay:2 month:1 year:2010) |
|
1564 |
Date weekInYearOf:(Date newDay:3 month:1 year:2010) |
|
1565 |
Date weekInYearOf:(Date newDay:4 month:1 year:2010) |
|
5548 | 1566 |
" |
1567 |
! |
|
1568 |
||
699 | 1569 |
yearAsDays: yearInteger |
1570 |
"Returns the number of days since Jan 1, 1901. (GNU) |
|
1571 |
to the first Jan of the year, yearInteger. |
|
16927 | 1572 |
For 1901 this is zero, for 1902 it's 365. |
699 | 1573 |
Defined for years >= 1901" |
1574 |
||
1575 |
|y "{ Class: SmallInteger }"| |
|
1576 |
||
1577 |
y := yearInteger - 1900. |
|
1578 |
y := y - 1. |
|
1579 |
^ (y * 365) |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
1580 |
+ (y // 4) |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
1581 |
- (y // 100) |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
1582 |
+ ((y + 300) // 400) |
699 | 1583 |
|
1584 |
" |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
1585 |
Date yearAsDays:5 |
14496 | 1586 |
Date yearAsDays:1900 |
699 | 1587 |
Date yearAsDays:1901 |
1588 |
Date yearAsDays:1902 |
|
1589 |
Date yearAsDays:1903 |
|
1590 |
Date yearAsDays:1904 |
|
1591 |
Date yearAsDays:1905 |
|
1592 |
Date yearAsDays:1994 |
|
1593 |
(Date yearAsDays:2001) - (Date yearAsDays:2000) |
|
1594 |
" |
|
16927 | 1595 |
! |
1596 |
||
1597 |
yearAsDaysFrom0: yearInteger |
|
1598 |
"Returns the number of days since Jan 1, 0 to Jan 1, yearInteger |
|
16983 | 1599 |
without caring for gregorian calendar change |
16927 | 1600 |
(i.e. as if there was a gregorian for all time). |
1601 |
Also assuming that the leapYear rules were present in pre-gregorian times also. |
|
16983 | 1602 |
Used internally to compute date differences. |
1603 |
||
1604 |
In previous versions, dates were counted relative to 1.1.1901. |
|
1605 |
This is no longer done; however, for backward compatibility, the old yearAsDays |
|
1606 |
and Date fromDays is still supported. |
|
1607 |
||
1608 |
For years >= 1901 it must hold that: |
|
1609 |
yearAsDaysFrom0(d1) - yearAsDaysFrom0(d2) |
|
1610 |
is the same as |
|
1611 |
yearAsDays(d1) - yearAsDays(d2) |
|
1612 |
" |
|
16927 | 1613 |
|
1614 |
|y "{ Class: SmallInteger }"| |
|
1615 |
||
1616 |
yearInteger == 0 ifTrue:[^ 0]. |
|
1617 |
y := yearInteger - 1. |
|
1618 |
^ 366 "/ 0 would have been a leap year |
|
1619 |
+ (y * 365) |
|
1620 |
+ (y // 4) "/ every 4th year is a leap year |
|
1621 |
- (y // 100) "/ but not evey 100th |
|
1622 |
+ (y // 400) "/ but evey 400th is |
|
1623 |
||
1624 |
" |
|
16983 | 1625 |
Date yearAsDaysFrom0:1900 |
1626 |
Date yearAsDaysFrom0:1901 |
|
1627 |
Date yearAsDaysFrom0:1902 |
|
1628 |
Date yearAsDaysFrom0:1903 |
|
1629 |
Date yearAsDaysFrom0:1904 |
|
1630 |
Date yearAsDaysFrom0:1905 |
|
1631 |
Date yearAsDaysFrom0:1994 |
|
16927 | 1632 |
|
1633 |
(Date yearAsDays:2001) - (Date yearAsDays:2000) |
|
16983 | 1634 |
(Date yearAsDaysFrom0:2001) - (Date yearAsDaysFrom0:2000) |
16927 | 1635 |
|
1636 |
(Date yearAsDays:2002) - (Date yearAsDays:2001) |
|
16983 | 1637 |
(Date yearAsDaysFrom0:2002) - (Date yearAsDaysFrom0:2001) |
1638 |
||
1639 |
Date yearAsDaysFrom0:-4 -1461 -- -4 was a leap year |
|
1640 |
Date yearAsDaysFrom0:-3 -1095 |
|
1641 |
Date yearAsDaysFrom0:-2 -730 |
|
1642 |
Date yearAsDaysFrom0:-1 -365 |
|
1643 |
Date yearAsDaysFrom0:0 0 |
|
1644 |
Date yearAsDaysFrom0:1 366 -- 0 was a leap year |
|
1645 |
Date yearAsDaysFrom0:2 731 |
|
1646 |
Date yearAsDaysFrom0:3 1096 |
|
1647 |
Date yearAsDaysFrom0:4 1461 |
|
1648 |
Date yearAsDaysFrom0:5 1827 -- 0 and 4 are leap years |
|
16927 | 1649 |
" |
699 | 1650 |
! ! |
1651 |
||
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1652 |
!Date class methodsFor:'obsolete'! |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1653 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1654 |
day:day month:month year:year |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1655 |
"return a new Date, given the day, month and year. |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1656 |
Obsolete: |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1657 |
use newDay:month:year: for ST-80 compatibility" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1658 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1659 |
<resource: #obsolete> |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1660 |
|
16838 | 1661 |
self obsoleteMethodWarning:'use #newDay:month:year: (2014-09)'. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1662 |
^ self newDay:day month:month year:year |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1663 |
! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1664 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1665 |
day:dayInYear year:year |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1666 |
"return a new Date, given the year and the day-in-year (starting at 1). |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1667 |
Obsolete: |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1668 |
use newDay:year: for ST-80 compatibility" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1669 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1670 |
<resource: #obsolete> |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1671 |
|
16838 | 1672 |
self obsoleteMethodWarning:'use #newDay:year: (2014-09)'. |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1673 |
^ self newDay:dayInYear year:year |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1674 |
! |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1675 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1676 |
isLeapYear:yearInteger |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1677 |
"Return true, if a year is a leap year. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1678 |
Obsolete: |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1679 |
Please use the ST-80 compatible #leapYear for new programs, |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1680 |
since this method will vanish." |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1681 |
<resource:#obsolete> |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1682 |
|
16838 | 1683 |
self obsoleteMethodWarning:'use #leapYear: (2014-09)'. |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1684 |
^ self leapYear:yearInteger |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1685 |
! ! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1686 |
|
17053 | 1687 |
|
2706
878723bc99fc
added #shortPrintString for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1701
diff
changeset
|
1688 |
!Date class methodsFor:'private'! |
1 | 1689 |
|
13509 | 1690 |
dayAbbrevsForLanguage:languageOrNilForDefault |
16913 | 1691 |
<resource: #obsolete> |
1692 |
"return a collection of short day-names for a given language or the |
|
1693 |
current language if nil is given. |
|
1694 |
The returned strings depend on the resource translation file to be present for the |
|
1695 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
1696 |
If not, english names are returned" |
|
1697 |
||
1698 |
^ self abbreviatedDayNamesForLanguage:languageOrNilForDefault |
|
12812 | 1699 |
|
1700 |
" |
|
1701 |
self dayAbbrevsForLanguage:#en |
|
1702 |
self dayAbbrevsForLanguage:#de |
|
1703 |
self dayAbbrevsForLanguage:#fr |
|
1704 |
self dayAbbrevsForLanguage:#es |
|
16913 | 1705 |
self dayAbbrevsForLanguage:nil |
1706 |
self dayAbbrevsForLanguage:#zulu |
|
12812 | 1707 |
" |
13509 | 1708 |
|
1709 |
"Modified (format): / 18-07-2011 / 09:34:14 / cg" |
|
7793
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1710 |
! |
8abaefe33259
keep english strings for day/month names/abbrevs
Claus Gittinger <cg@exept.de>
parents:
7673
diff
changeset
|
1711 |
|
699 | 1712 |
daysInMonthIndex: monthIndex forYear: yearInteger |
1713 |
"return the number of days in month monthIndex of |
|
1714 |
year yearInteger (modified GNU). |
|
1715 |
Return 0 for invalid month index. |
|
1716 |
This is the internal version of daysInMonth:forYear:" |
|
1717 |
||
1718 |
|days| |
|
1719 |
||
1720 |
(monthIndex between:1 and:12) ifFalse:[^ 0]. |
|
1721 |
||
1722 |
days := #(31 28 31 "Jan Feb Mar" |
|
1723 |
30 31 30 "Apr May Jun" |
|
1724 |
31 31 30 "Jul Aug Sep" |
|
1725 |
31 30 31 "Oct Nov Dec" |
|
1726 |
) at: monthIndex. |
|
1727 |
||
1728 |
(monthIndex == 2) ifTrue:[ |
|
1729 |
(self leapYear:yearInteger) ifTrue:[ |
|
1730 |
^ days + 1 |
|
1731 |
] |
|
1732 |
]. |
|
1733 |
^ days |
|
1734 |
||
1735 |
" |
|
1736 |
Date daysInMonthIndex:2 forYear:1994 |
|
1737 |
Date daysInMonthIndex:2 forYear:1980 |
|
1738 |
Date daysInMonthIndex:2 forYear:1981 |
|
1739 |
" |
|
1740 |
! |
|
1741 |
||
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1742 |
daysUntilMonthIndex: monthIndex forYear: yearInteger |
16913 | 1743 |
"return the number of days from 1st January up to month monthIndex of |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1744 |
year yearInteger (modified GNU). |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1745 |
Return 0 for invalid month index. |
16913 | 1746 |
This is the internal version of dayInMonth:forYear:" |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1747 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1748 |
|days| |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1749 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1750 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1751 |
|sum| |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1752 |
sum := 0. |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1753 |
#(31 28 31 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1754 |
30 31 30 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1755 |
31 31 30 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1756 |
31 30 31 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1757 |
) collect:[:each | |first| first:= sum. sum := sum + each. first] |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1758 |
#(0 31 59 90 120 151 181 212 243 273 304 334) |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1759 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1760 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1761 |
(monthIndex between:1 and:12) ifFalse:[^ 0]. |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1762 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1763 |
days := #(0 31 59 90 120 151 181 212 243 273 304 334) at: monthIndex. |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1764 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1765 |
(monthIndex > 2) ifTrue:[ |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1766 |
(self leapYear:yearInteger) ifTrue:[ |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1767 |
^ days + 1 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1768 |
] |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1769 |
]. |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1770 |
^ days |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1771 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1772 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1773 |
Date daysUntilMonthIndex:3 forYear:1994 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1774 |
Date daysUntilMonthIndex:3 forYear:1980 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1775 |
Date daysUntilMonthIndex:3 forYear:1981 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
1776 |
" |
54 | 1777 |
! ! |
1778 |
||
11786 | 1779 |
!Date class methodsFor:'private-encoding/decoding'! |
54 | 1780 |
|
1781 |
encodeYear:y month:m day:d |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1782 |
"the internal encoding is strictly private, |
92 | 1783 |
and should not be used outside." |
1784 |
||
16927 | 1785 |
"this encoding was chosen to be easily readable... |
1786 |
and also sortable" |
|
54 | 1787 |
^ (((y * 100) + m) * 100) + d |
11786 | 1788 |
! |
1789 |
||
1790 |
readDatePartFrom:str format:fmt language:languageOrNil |
|
1791 |
"read a single component (such as %shortName) from str" |
|
1792 |
||
12812 | 1793 |
|dayName monthName day month year format string | |
1794 |
||
1795 |
format := fmt. |
|
1796 |
string := str throughAnyForWhich:[:ch | ch isNationalAlphaNumeric]. |
|
1797 |
||
1798 |
((format sameAs:'dayName') or:[format sameAs:'shortDayName']) ifTrue:[ |
|
11786 | 1799 |
"/ skipped, in case the format is 'monday, 23rd of may...' - not used for decoding |
12812 | 1800 |
dayName := string. |
11786 | 1801 |
^ nil. |
1802 |
]. |
|
12812 | 1803 |
(format sameAs:'d') ifTrue:[ |
1804 |
day := Integer readFrom:string. |
|
11786 | 1805 |
^ #day -> day |
1806 |
]. |
|
12812 | 1807 |
|
1808 |
(format sameAs:'m') ifTrue:[ |
|
1809 |
month := Integer readFrom:string. |
|
11786 | 1810 |
^ #month -> month |
1811 |
]. |
|
12812 | 1812 |
(format sameAs:'monthName') ifTrue:[ |
1813 |
monthName := string. |
|
1814 |
month := (Date monthNamesForLanguage:languageOrNil) findFirst:[:m | monthName sameAs:m]. |
|
1815 |
"/ month == 0 ifTrue:[self error:'invalid month name']. |
|
1816 |
^ #month -> month |
|
1817 |
]. |
|
1818 |
(format sameAs:'shortMonthName') ifTrue:[ |
|
1819 |
monthName := string. |
|
1820 |
month := (Date abbreviatedMonthNamesForLanguage:languageOrNil) findFirst:[:m | monthName sameAs:m]. |
|
1821 |
"/ month == 0 ifTrue:[self error:'invalid month name']. |
|
1822 |
^ #month -> month |
|
1823 |
]. |
|
1824 |
||
1825 |
format = 'y' ifTrue:[ |
|
1826 |
year := Integer readFrom:string. |
|
11786 | 1827 |
year < 100 ifTrue:[ |
11787 | 1828 |
^ #year -> (year + 2000) |
11786 | 1829 |
]. |
1830 |
^ #year -> year |
|
1831 |
]. |
|
12812 | 1832 |
format = 'Y' ifTrue:[ |
1833 |
year := Integer readFrom:string. |
|
11786 | 1834 |
year >= 100 ifTrue:[ |
11787 | 1835 |
^ #year -> year |
11786 | 1836 |
]. |
11787 | 1837 |
^ #year -> (year + 2000) |
11786 | 1838 |
]. |
1839 |
self error:'unknown format specifier' |
|
54 | 1840 |
! ! |
1841 |
||
7258 | 1842 |
!Date class methodsFor:'private-instance creation'! |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1843 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1844 |
fromOSTime:osTime |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1845 |
"return a date, representing the date given by the operatingSystem time. |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1846 |
This somewhat clumsy implementation hides the OS's date representation |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1847 |
(i.e. makes this class independent of what the OS starts its time values with). |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1848 |
Dont use this method, the osTime representation is totally unportable." |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1849 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1850 |
^ self basicNew fromOSTime:osTime |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1851 |
|
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1852 |
" |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1853 |
Date fromOSTime:0 -> on UNIX: this should return 1st Jan 1970 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1854 |
thats where Unix time starts |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1855 |
On other systems, it may be something different. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1856 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
1857 |
Date fromOSTime:(24*60*60*1000) -> on UNIX: the day after |
1227
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1858 |
" |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1859 |
! ! |
e89b39909085
commentary & category changes
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
1860 |
|
17053 | 1861 |
|
7261 | 1862 |
!Date methodsFor:'Compatibility-ANSI'! |
6419 | 1863 |
|
1864 |
dayOfWeek |
|
1865 |
"return the week-day of the receiver - 1 is sunday, 7 for saturday. |
|
1866 |
WARNING: different from dayInWeek (which returns 1 for monday, ... 7 for sunday). |
|
1867 |
" |
|
1868 |
||
1869 |
|d| |
|
1870 |
||
1871 |
d := self dayInWeek. |
|
1872 |
d == 7 ifTrue:[ |
|
1873 |
^ 1 |
|
1874 |
]. |
|
1875 |
^ d + 1 |
|
1876 |
||
1877 |
" |
|
1878 |
Date today dayOfWeek |
|
1879 |
Date today dayInWeek |
|
1880 |
" |
|
1881 |
! |
|
1882 |
||
1883 |
dayOfWeekAbbreviation |
|
1884 |
"return the short week-day of the receiver as a string. |
|
1885 |
The returned string depends on the language setting. |
|
1886 |
Expect things like 'mon', 'tue' ..." |
|
1887 |
||
1888 |
^ self abbreviatedDayName |
|
1889 |
||
1890 |
" |
|
1891 |
Date today dayOfWeekAbbreviation |
|
1892 |
" |
|
1893 |
! |
|
1894 |
||
1895 |
dayOfWeekName |
|
1896 |
"return the week-day of the receiver as a string. |
|
1897 |
The returned string depends on the language setting. |
|
1898 |
Expect things like 'monday', 'tuesday' ..." |
|
1899 |
||
1900 |
^ self weekday |
|
1901 |
||
1902 |
" |
|
1903 |
Date today dayOfWeekName |
|
1904 |
Date today dayOfWeekAbbreviation |
|
1905 |
" |
|
1906 |
! |
|
1907 |
||
1908 |
dayOfYear |
|
1909 |
"return the day-nr within the year of the receiver - 1..365/366" |
|
1910 |
||
1911 |
^ self dayInYear |
|
1912 |
||
1913 |
" |
|
1914 |
Date today dayOfYear |
|
1915 |
" |
|
1916 |
! |
|
1917 |
||
1918 |
monthAbbreviation |
|
1919 |
"return the month of the receiver as a string. |
|
1920 |
The returned string depends on the language setting. |
|
1921 |
Expect things like 'jan', 'feb' ..." |
|
1922 |
||
1923 |
^ self abbreviatedMonthName |
|
1924 |
||
1925 |
" |
|
1926 |
Date today monthAbbreviation |
|
1927 |
" |
|
1928 |
! ! |
|
1929 |
||
7261 | 1930 |
!Date methodsFor:'Compatibility-ST80'! |
5515 | 1931 |
|
11740 | 1932 |
firstDayInMonth |
1933 |
"Return the first day in the month of the receiver" |
|
1934 |
||
1935 |
^ self subtractDays:(self dayOfMonth - 1) |
|
1936 |
||
1937 |
" |
|
1938 |
Date today |
|
11895 | 1939 |
Date today firstDayInMonth |
1940 |
Date today firstDayInMonth subtractDays:1 |
|
11740 | 1941 |
(Date today subtractDays:30) firstDayInMonth |
1942 |
(Date today subtractDays:122) firstDayInMonth |
|
1943 |
(Date today subtractDays:154) firstDayInMonth |
|
1944 |
" |
|
1945 |
! |
|
1946 |
||
11895 | 1947 |
lastDayInMonth |
1948 |
"Return the last day in the month in which the receiver is." |
|
1949 |
||
1950 |
^ self addDays:(self daysInMonth - self day). |
|
1951 |
||
1952 |
" |
|
1953 |
Date today |
|
1954 |
Date today lastDayInMonth |
|
1955 |
Date today lastDayInMonth addDays:1 |
|
1956 |
" |
|
1957 |
! |
|
1958 |
||
11664 | 1959 |
next:dayName |
1960 |
"Return the next date whose weekday name is dayName. |
|
1961 |
Caveat; dayName is expected to be in the current language" |
|
1962 |
||
1963 |
|ti ni| |
|
1964 |
||
1965 |
ti := self weekdayIndex. |
|
1966 |
ni := (self class dayOfWeek:dayName). |
|
1967 |
^ self addDays:(ni > ti ifTrue:[ ni-ti ] ifFalse:[ 7+ni-ti ]) |
|
1968 |
||
1969 |
" |
|
1970 |
Date today |
|
1971 |
Date today next:#Friday |
|
1972 |
Date today next:#Sunday |
|
1973 |
Date today next:#Monday |
|
1974 |
Date today next:#Thursday |
|
1975 |
Date today next:#WednesDay |
|
1976 |
" |
|
1977 |
! |
|
1978 |
||
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1979 |
nextDayWithIndex:dayIndex |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1980 |
"Return the next date whose weekday name is dayName. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1981 |
dayIndex is Monday=1, ... , Sunday=7" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1982 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1983 |
|ti| |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1984 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1985 |
self assert:(dayIndex between:1 and:7). |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1986 |
ti := self weekdayIndex. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1987 |
^ self addDays:(dayIndex > ti ifTrue:[ dayIndex-ti ] ifFalse:[ 7+dayIndex-ti ]) |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1988 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1989 |
" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1990 |
Date today |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1991 |
Date today nextDayWithIndex:5 - next Friday |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1992 |
Date today nextDayWithIndex:7 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1993 |
Date today nextDayWithIndex:1 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1994 |
Date today nextDayWithIndex:4 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1995 |
Date today nextDayWithIndex:3 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1996 |
" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1997 |
! |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
1998 |
|
6976 | 1999 |
previous:dayName |
2000 |
"Return the previous date whose weekday name is dayName. |
|
2001 |
Caveat; dayName is expected to be in the current language" |
|
2002 |
||
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2003 |
^ self previousDayWithIndex:(self class dayOfWeek:dayName). |
6976 | 2004 |
|
2005 |
" |
|
11664 | 2006 |
Date today |
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2007 |
Date today previous:#Montag |
6976 | 2008 |
Date today previous:#Monday |
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2009 |
|
11664 | 2010 |
Date today previous:#Friday |
2011 |
Date today previous:#Sunday |
|
2012 |
Date today previous:#Monday |
|
2013 |
Date today previous:#Thursday |
|
2014 |
Date today previous:#WednesDay |
|
2015 |
Date today previous:#TuesDay |
|
6976 | 2016 |
" |
2017 |
! |
|
2018 |
||
11665
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2019 |
previousDayWithIndex:dayIndex |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2020 |
"Return the previous date whose weekday name is dayIndex. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2021 |
dayIndex is Monday=1, ... , Sunday=7" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2022 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2023 |
|ti| |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2024 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2025 |
self assert:(dayIndex between:1 and:7). |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2026 |
ti := self weekdayIndex. |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2027 |
^ self subtractDays:(((ti - dayIndex - 1) \\ 7) + 1) |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2028 |
|
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2029 |
" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2030 |
Date today |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2031 |
Date today previousDayWithIndex:1 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2032 |
Date today previousDayWithIndex:5 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2033 |
Date today previousDayWithIndex:7 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2034 |
Date today previousDayWithIndex:4 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2035 |
Date today previousDayWithIndex:3 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2036 |
Date today previousDayWithIndex:2 |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2037 |
" |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2038 |
! |
352825372305
+nextDayWithIndex and previousDayWithIndex:
Claus Gittinger <cg@exept.de>
parents:
11664
diff
changeset
|
2039 |
|
7023 | 2040 |
printFormat:aFormatArray |
2041 |
"Obsolete, backward ST-80 compatible formatted printing - see printStringFormat: |
|
2042 |
Return a string containing a printed representation of the receiver. |
|
2043 |
The formatArray argument consists of 6 or 7 integers which control |
|
2044 |
the resulting string. The entries are: |
|
2045 |
1 day position (1, 2 or 3) |
|
2046 |
2 month position (1..3) |
|
2047 |
3 year position (1..3) |
|
2048 |
4 asciiValue of separator character or separator character |
|
2049 |
or collection of 2 separator characters |
|
2050 |
5 month format (1: numeric; 2: abbreviated name; 3: fullname |
|
2051 |
4: abbreviated uppercase 5: full uppercase) |
|
2052 |
6 year format (1 include century; 2 exclude century) |
|
2053 |
7 (optional) true/false. |
|
2054 |
if true, print numbers in 2-digit format |
|
2055 |
(i.e. with leading zeros); |
|
2056 |
Taken as false, if ommited |
|
2057 |
||
2058 |
Day and monthnames are in the currently active language. |
|
2059 |
||
2060 |
This method supports more options than the ST-80 version; month formats |
|
2061 |
4 and 5, non-numeric separators and the optional 7th parameter are not |
|
2062 |
supported by ST-80. Be aware of this for compatibility reasons. |
|
2063 |
||
2064 |
Notice that not all formats can be scanned (correctly) by #readFrom: |
|
2065 |
This is an ST-80 compatibility method - I would have choosen another |
|
2066 |
(less cryptic) formatString ... |
|
2067 |
" |
|
2068 |
||
7961 | 2069 |
^ self printFormat:aFormatArray forLanguage:nil |
2070 |
||
2071 |
" |
|
2072 |
Date today printFormat:#(1 2 3 '' 1 2) |
|
2073 |
Date today printFormat:#(1 2 3 $- 1 2) |
|
2074 |
Date today printFormat:#(1 2 3 $. 1 2 true) |
|
2075 |
Date today printFormat:#(2 1 3 32 3 1) |
|
2076 |
Date today printFormat:#(2 1 3 #(' ' ', ') 3 1) |
|
2077 |
Date today printFormat:#(1 2 3 $- 2 1) |
|
2078 |
Date today printFormat:#(1 2 3 $- 4 1) |
|
2079 |
" |
|
2080 |
! |
|
2081 |
||
2082 |
printFormat:aFormatArray forLanguage:languageOrNil |
|
2083 |
"Obsolete, backward ST-80 compatible formatted printing - see printStringFormat: |
|
2084 |
Return a string containing a printed representation of the receiver. |
|
2085 |
The formatArray argument consists of 6 or 7 integers which control |
|
2086 |
the resulting string. The entries are: |
|
2087 |
1 day position (1, 2 or 3) |
|
2088 |
2 month position (1..3) |
|
2089 |
3 year position (1..3) |
|
2090 |
4 asciiValue of separator character or separator character |
|
2091 |
or collection of 2 separator characters |
|
2092 |
5 month format (1: numeric; 2: abbreviated name; 3: fullname |
|
2093 |
4: abbreviated uppercase 5: full uppercase) |
|
2094 |
6 year format (1 include century; 2 exclude century) |
|
2095 |
7 (optional) true/false. |
|
2096 |
if true, print numbers in 2-digit format |
|
2097 |
(i.e. with leading zeros); |
|
2098 |
Taken as false, if ommited |
|
2099 |
||
2100 |
Day and monthnames are in the currently active language. |
|
2101 |
||
2102 |
This method supports more options than the ST-80 version; month formats |
|
2103 |
4 and 5, non-numeric separators and the optional 7th parameter are not |
|
2104 |
supported by ST-80. Be aware of this for compatibility reasons. |
|
2105 |
||
2106 |
Notice that not all formats can be scanned (correctly) by #readFrom: |
|
2107 |
This is an ST-80 compatibility method - I would have choosen another |
|
2108 |
(less cryptic) formatString ... |
|
2109 |
" |
|
2110 |
||
7023 | 2111 |
|mf upperCase day month year components sep1 sep2 leadingZeros| |
2112 |
||
2113 |
aFormatArray size > 6 ifTrue:[ |
|
2114 |
leadingZeros := aFormatArray at:7 |
|
2115 |
] ifFalse:[ |
|
2116 |
leadingZeros := false. |
|
2117 |
]. |
|
2118 |
||
2119 |
components := Array new:3. |
|
2120 |
day := self day. |
|
2121 |
leadingZeros ifTrue:[ |
|
2122 |
day := day printStringLeftPaddedTo:2 with:$0 |
|
2123 |
] ifFalse:[ |
|
2124 |
day := day printString |
|
2125 |
]. |
|
2126 |
components at:(aFormatArray at:1) put:day. |
|
2127 |
||
2128 |
upperCase := false. |
|
2129 |
mf := aFormatArray at:5. |
|
2130 |
(mf between:4 and:5) ifTrue:[mf := mf - 2. upperCase := true]. |
|
2131 |
||
2132 |
mf == 1 ifTrue:[ |
|
2133 |
month := self month. |
|
2134 |
leadingZeros ifTrue:[ |
|
2135 |
month := month printStringLeftPaddedTo:2 with:$0 |
|
2136 |
] ifFalse:[ |
|
2137 |
month := month printString |
|
2138 |
] |
|
2139 |
] ifFalse:[ |
|
2140 |
mf == 2 ifTrue:[ |
|
7961 | 2141 |
month := self abbreviatedMonthNameForLanguage:languageOrNil |
7023 | 2142 |
] ifFalse:[ |
7961 | 2143 |
month := self monthNameForLanguage:languageOrNil |
7023 | 2144 |
] |
2145 |
]. |
|
2146 |
upperCase ifTrue:[month := month asUppercase]. |
|
2147 |
components at:(aFormatArray at:2) put:month. |
|
2148 |
||
2149 |
year := self year. |
|
2150 |
(aFormatArray at:6) == 2 ifTrue:[ |
|
2151 |
year := year \\ 100. |
|
2152 |
year := year printStringLeftPaddedTo:2 with:$0 |
|
2153 |
]. |
|
2154 |
year := year printString. |
|
2155 |
components at:(aFormatArray at:3) put:year. |
|
2156 |
||
2157 |
sep1 := sep2 := (aFormatArray at:4). |
|
2158 |
sep1 isString ifFalse:[ |
|
2159 |
sep1 isCollection ifTrue:[ |
|
2160 |
sep2 := (sep1 at:2). |
|
2161 |
sep1 := (sep1 at:1). |
|
2162 |
] ifFalse:[ |
|
2163 |
sep1 := sep2 := sep1 asCharacter |
|
2164 |
] |
|
2165 |
]. |
|
2166 |
||
2167 |
^ (components at:1) |
|
2168 |
, sep1 asString |
|
2169 |
, (components at:2) |
|
2170 |
, sep2 asString |
|
2171 |
, (components at:3) |
|
2172 |
||
2173 |
" |
|
7961 | 2174 |
Date today printFormat:#(1 2 3 '' 1 2) |
2175 |
Date today printFormat:#(1 2 3 $- 1 2) |
|
7023 | 2176 |
Date today printFormat:#(1 2 3 $. 1 2 true) |
2177 |
Date today printFormat:#(2 1 3 32 3 1) |
|
2178 |
Date today printFormat:#(2 1 3 #(' ' ', ') 3 1) |
|
7961 | 2179 |
Date today printFormat:#(1 2 3 $- 2 1) forLanguage:#en |
2180 |
Date today printFormat:#(1 2 3 $- 4 1) forLanguage:#en |
|
2181 |
" |
|
2182 |
! |
|
2183 |
||
2184 |
printFormat:aFormatArray forLanguage:languageOrNil on:aStream |
|
2185 |
"Obsolete, backward ST-80 compatible formatted printing - see comment |
|
2186 |
in printFormat:. |
|
2187 |
Append a printed representation of the receiver to aStream. |
|
2188 |
The argument, aFormatString controls the format, as described |
|
2189 |
in the #printFormat: method. |
|
2190 |
Notice that not all formats can be scanned (correctly) by #readFrom:" |
|
2191 |
||
2192 |
aStream nextPutAll:(self printFormat:aFormatArray forLanguage:languageOrNil) |
|
2193 |
||
2194 |
||
2195 |
"european formats: |
|
2196 |
||
2197 |
Date today printFormat:#(1 2 3 $- 1 2) on:Transcript. Transcript cr. |
|
2198 |
Date today printFormat:#(1 2 3 $- 2 2) on:Transcript. Transcript cr. |
|
2199 |
Date today printFormat:#(1 2 3 $- 2 1) on:Transcript. Transcript cr. |
|
2200 |
Date today printFormat:#(1 2 3 $- 3 2) on:Transcript. Transcript cr. |
|
2201 |
Date today printFormat:#(1 2 3 $. 1 2) on:Transcript. Transcript cr. |
|
2202 |
Date today printFormat:#(1 2 3 $. 1 2 true) on:Transcript. Transcript cr. |
|
2203 |
||
2204 |
US formats: |
|
2205 |
||
2206 |
Date today printFormat:#(2 1 3 32 3 1) on:Transcript. Transcript cr. |
|
2207 |
Date today printFormat:#(2 1 3 32 2 2) on:Transcript. Transcript cr. |
|
2208 |
Date today printFormat:#(2 1 3 $/ 1 2) on:Transcript. Transcript cr. |
|
2209 |
Date today printFormat:#(2 1 3 $- 2 1) on:Transcript. Transcript cr. |
|
2210 |
Date today printFormat:#(2 1 3 #(' ' ', ') 2 1) on:Transcript. Transcript cr. |
|
2211 |
Date today printFormat:#(1 2 3 $- 2 1) on:Transcript. Transcript cr. |
|
2212 |
Date today printFormat:#(1 2 3 $- 4 1) on:Transcript. Transcript cr. |
|
7023 | 2213 |
" |
2214 |
! |
|
2215 |
||
2216 |
printFormat:aFormatArray on:aStream |
|
2217 |
"Obsolete, backward ST-80 compatible formatted printing - see comment |
|
2218 |
in printFormat:. |
|
2219 |
Append a printed representation of the receiver to aStream. |
|
2220 |
The argument, aFormatString controls the format, as described |
|
2221 |
in the #printFormat: method. |
|
2222 |
Notice that not all formats can be scanned (correctly) by #readFrom:" |
|
2223 |
||
2224 |
aStream nextPutAll:(self printFormat:aFormatArray) |
|
2225 |
||
2226 |
||
2227 |
"european formats: |
|
2228 |
||
2229 |
Date today printFormat:#(1 2 3 $- 1 2) on:Transcript. Transcript cr. |
|
2230 |
Date today printFormat:#(1 2 3 $- 2 2) on:Transcript. Transcript cr. |
|
2231 |
Date today printFormat:#(1 2 3 $- 2 1) on:Transcript. Transcript cr. |
|
2232 |
Date today printFormat:#(1 2 3 $- 3 2) on:Transcript. Transcript cr. |
|
2233 |
Date today printFormat:#(1 2 3 $. 1 2) on:Transcript. Transcript cr. |
|
2234 |
Date today printFormat:#(1 2 3 $. 1 2 true) on:Transcript. Transcript cr. |
|
2235 |
||
2236 |
US formats: |
|
2237 |
||
2238 |
Date today printFormat:#(2 1 3 32 3 1) on:Transcript. Transcript cr. |
|
2239 |
Date today printFormat:#(2 1 3 32 2 2) on:Transcript. Transcript cr. |
|
2240 |
Date today printFormat:#(2 1 3 $/ 1 2) on:Transcript. Transcript cr. |
|
2241 |
Date today printFormat:#(2 1 3 $- 2 1) on:Transcript. Transcript cr. |
|
2242 |
Date today printFormat:#(2 1 3 #(' ' ', ') 2 1) on:Transcript. Transcript cr. |
|
2243 |
Date today printFormat:#(1 2 3 $- 2 1) on:Transcript. Transcript cr. |
|
2244 |
Date today printFormat:#(1 2 3 $- 4 1) on:Transcript. Transcript cr. |
|
2245 |
" |
|
2246 |
! |
|
2247 |
||
5515 | 2248 |
shortPrintString |
2249 |
"dummy - for now" |
|
2250 |
||
2251 |
^ self printString |
|
2252 |
||
2253 |
"Created: 20.6.1997 / 17:16:48 / cg" |
|
6976 | 2254 |
! |
2255 |
||
2256 |
weekdayIndex |
|
2257 |
"Return the day index; Monday=1, ... , Sunday=7" |
|
2258 |
||
2259 |
^ (self asDays + 1) \\ 7 + 1 "1 January 1901 was a Tuesday" |
|
2260 |
||
2261 |
" |
|
2262 |
Date today dayName |
|
2263 |
Date today weekdayIndex |
|
2264 |
" |
|
5515 | 2265 |
! ! |
2266 |
||
7261 | 2267 |
!Date methodsFor:'Compatibility-Squeak'! |
4407 | 2268 |
|
2269 |
mmddyyyy |
|
4462 | 2270 |
"return a printed representation of the receiver in the |
2271 |
form mmddyyyy. |
|
2272 |
The receiver can be reconstructed with: |
|
2273 |
Date readMMDDYYYYFrom:aStringOrStream onError:[...]" |
|
2274 |
||
11182 | 2275 |
^ self printStringFormat:'%m%d%y' |
2276 |
||
2277 |
"/ ^ (self month printStringLeftPaddedTo:2 with:$0) |
|
2278 |
"/ , (self day printStringLeftPaddedTo:2 with:$0) |
|
2279 |
"/ , (self year printStringLeftPaddedTo:4 with:$0) |
|
4407 | 2280 |
|
2281 |
" |
|
2282 |
Date today mmddyyyy |
|
2283 |
" |
|
2284 |
! ! |
|
2285 |
||
699 | 2286 |
!Date methodsFor:'accessing'! |
241 | 2287 |
|
699 | 2288 |
abbreviatedDayName |
16913 | 2289 |
"return the short week-day-name of the receiver as a string. |
699 | 2290 |
The returned string depends on the language setting. |
2291 |
Expect things like 'mon', 'tue' ..." |
|
54 | 2292 |
|
699 | 2293 |
^ self class abbreviatedNameOfDay:(self dayInWeek) |
92 | 2294 |
|
2295 |
" |
|
699 | 2296 |
Date today abbreviatedDayName |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2297 |
(Date newDay:15 month:4 year:1959) abbreviatedDayName |
92 | 2298 |
" |
2299 |
! |
|
2300 |
||
16913 | 2301 |
abbreviatedDayNameForLanguage:lang |
2302 |
"return the short week-day-name of the receiver as a string. |
|
2303 |
The returned string depends on the resource translation file to be present for the |
|
2304 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
2305 |
If not, the english name is returned. |
|
2306 |
Expect things like 'mon', 'tue' ..." |
|
2307 |
||
2308 |
^ self class abbreviatedNameOfDay:(self dayInWeek) language:lang |
|
2309 |
||
2310 |
" |
|
2311 |
Date today abbreviatedDayNameForLanguage:#en |
|
2312 |
Date today abbreviatedDayNameForLanguage:#de |
|
2313 |
Date today abbreviatedDayNameForLanguage:#zulu |
|
2314 |
||
2315 |
(Date newDay:15 month:4 year:1959) abbreviatedDayName |
|
2316 |
" |
|
2317 |
! |
|
2318 |
||
699 | 2319 |
abbreviatedMonthName |
16913 | 2320 |
"return the short month name of the receiver as a string. |
699 | 2321 |
The returned string depends on the language setting. |
2322 |
Expect things like 'jan', 'feb' ..." |
|
54 | 2323 |
|
699 | 2324 |
^ self class abbreviatedNameOfMonth:(self month) |
68 | 2325 |
|
92 | 2326 |
" |
699 | 2327 |
Date today abbreviatedMonthName |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2328 |
(Date newDay:15 month:4 year:1959) abbreviatedMonthName |
92 | 2329 |
" |
2330 |
! |
|
2331 |
||
7794
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2332 |
abbreviatedMonthNameForLanguage:lang |
16913 | 2333 |
"return the short month-name of the receiver as a string in a given language. |
2334 |
The returned string depends on the resource translation file to be present for the |
|
2335 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
2336 |
If not, the english name is returned. |
|
7794
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2337 |
Expect things like 'jan', 'feb' ..." |
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2338 |
|
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2339 |
^ self class abbreviatedNameOfMonth:(self month) language:lang |
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2340 |
|
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2341 |
" |
7961 | 2342 |
Date today abbreviatedMonthNameForLanguage:#en |
2343 |
Date today abbreviatedMonthNameForLanguage:#de |
|
16913 | 2344 |
Date today abbreviatedMonthNameForLanguage:#zulu |
7794
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2345 |
" |
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2346 |
! |
7f1901b11541
accessor for language specific abbreviated month name
penk
parents:
7793
diff
changeset
|
2347 |
|
92 | 2348 |
asDays |
2349 |
"return the number of days elapsed since 01-Jan-1901 |
|
2350 |
and the receiver's day; starts with 0 for 1-1-1901. |
|
2351 |
Date>>fromDays: is the reverse operation. |
|
16927 | 2352 |
Notice, that this is not able to represent dates before 1901!!. |
2353 |
For GNU/ST-80 compatibility." |
|
68 | 2354 |
|
2355 |
|yr| |
|
2356 |
||
2357 |
yr := self year. |
|
2358 |
^ (self class yearAsDays:yr) |
|
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2359 |
+ (self class daysUntilMonthIndex:self month forYear:yr) |
68 | 2360 |
+ self day |
85 | 2361 |
- 1 |
68 | 2362 |
|
92 | 2363 |
" |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2364 |
(Date newDay: 5 month: 8 year: 1962) asDays -> should be 22496 |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2365 |
(Date newDay: 1 month: 1 year: 1901) asDays -> 0 |
16913 | 2366 |
(Date newDay: 31 month: 12 year: 1900) asDays -> -1 |
2367 |
(Date newDay: 1 month: 1 year: 1800) asDays -> -36889 |
|
2368 |
Date today asDays |
|
2369 |
Date fromDays:(Date today asDays + 7) |
|
92 | 2370 |
" |
77 | 2371 |
! |
2372 |
||
16927 | 2373 |
asDaysFrom0 |
2374 |
"return the number of days elapsed since 01-Jan-0 |
|
2375 |
and the receiver's day; starts with 0 for 1-1-0. |
|
2376 |
Date>>fromDaysFrom0: is the reverse operation. |
|
2377 |
Notice, that this is not able to represent dates before 0!!." |
|
2378 |
||
2379 |
|yr| |
|
2380 |
||
2381 |
yr := self year. |
|
2382 |
^ (self class yearAsDaysFrom0:yr) |
|
2383 |
+ (self class daysUntilMonthIndex:self month forYear:yr) |
|
2384 |
+ self day |
|
2385 |
- 1 |
|
2386 |
||
2387 |
" |
|
2388 |
(Date newDay: 1 month: 1 year: 0) asDaysFrom0 -> should be 0 |
|
2389 |
(Date newDay: 1 month: 1 year: 1) asDaysFrom0 -> should be 366 |
|
2390 |
Date fromDaysFrom0:(Date today asDaysFrom0 + 7) |
|
2391 |
" |
|
2392 |
! |
|
2393 |
||
77 | 2394 |
asSeconds |
92 | 2395 |
"return the seconds between 1.jan.1901 and the same time in the receivers |
2396 |
day. (i.e. midnight to midnight). |
|
1501 | 2397 |
This does not include any leapSeconds ... strictly speaking, this is incorrect. |
77 | 2398 |
ST-80 compatibility." |
2399 |
||
92 | 2400 |
^ 60*60*24 * self asDays |
77 | 2401 |
|
92 | 2402 |
" |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2403 |
(Date newDay: 5 month: 8 year: 1962) asSeconds |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2404 |
(Date newDay: 1 month: 1 year: 1901) asSeconds |
92 | 2405 |
(Date today addDays:7) asSeconds - Date today asSeconds |
1501 | 2406 |
" |
2407 |
||
2408 |
"Modified: 1.7.1996 / 14:19:17 / cg" |
|
699 | 2409 |
! |
2410 |
||
2411 |
day |
|
2412 |
"return the day (1..31) of the receiver" |
|
2413 |
||
2414 |
^ dateEncoding \\ 100 |
|
2415 |
||
8626 | 2416 |
"example: |
699 | 2417 |
Date today day |
2418 |
" |
|
2419 |
! |
|
2420 |
||
2421 |
dayInWeek |
|
5778 | 2422 |
"return the week-day of the receiver - 1 for monday, 7 for sunday. |
6419 | 2423 |
WARNING: different from ANSIs dayOfWeek (which returns 1 for sunday, ... 7 for saturday). |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2424 |
WARNING: does not care for pre-gregorian dates |
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2425 |
(i.e. do not use this for dates before 1583) |
5778 | 2426 |
" |
699 | 2427 |
|
3256
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2428 |
|wday| |
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2429 |
|
16927 | 2430 |
wday := self asDaysFrom0 \\ 7 - 1. |
2431 |
"/ wday := (1 "knowing, that 1st Jan 1901 was a tuesday" |
|
2432 |
"/ + self asDays) \\ 7 + 1. |
|
3256
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2433 |
wday < 1 ifTrue:[ |
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2434 |
wday := wday + 7 |
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2435 |
]. |
637d16a0c83b
care for date before 1.1.1900 in dayInWeek.
Claus Gittinger <cg@exept.de>
parents:
2706
diff
changeset
|
2436 |
^ wday |
699 | 2437 |
|
2438 |
" |
|
16927 | 2439 |
Date today dayInWeek |
2440 |
Date tomorrow dayInWeek |
|
5548 | 2441 |
Date yesterday dayInWeek |
16927 | 2442 |
(Date today subtractDays:2) dayInWeek |
2443 |
Date today weekday |
|
2444 |
Date tomorrow weekday |
|
2445 |
Date yesterday weekday |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2446 |
(Date newDay:15 month:4 year:1959) dayInWeek |
16927 | 2447 |
(Date newDay:1 month:1 year:1901) dayInWeek |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2448 |
(Date newDay:31 month:12 year:1900) dayInWeek |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2449 |
(Date newDay:31 month:12 year:1899) dayInWeek |
699 | 2450 |
" |
1501 | 2451 |
|
3257 | 2452 |
"Modified: / 1.2.1998 / 14:10:27 / cg" |
699 | 2453 |
! |
2454 |
||
5548 | 2455 |
dayInYear |
2456 |
"return the day-nr within the year of the receiver - 1 .. 365/366" |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2457 |
|
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2458 |
" |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2459 |
|daysSoFar| |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2460 |
daysSoFar := 0. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2461 |
#(0 31 28 31 30 31 30 31 31 30 31 30) collect:[:i| daysSoFar := daysSoFar + i] |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2462 |
" |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2463 |
|
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2464 |
|days month| |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2465 |
|
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2466 |
month := self month. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2467 |
|
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2468 |
days := #(0 31 59 90 120 151 181 212 243 273 304 334) at:month. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2469 |
days := days + self day. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2470 |
(month > 2 and:[self class leapYear:self year]) ifTrue:[ |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2471 |
days := days + 1. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2472 |
]. |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2473 |
|
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2474 |
^ days |
5548 | 2475 |
|
2476 |
" |
|
2477 |
Date today dayInYear |
|
2478 |
(Date newDay:1 year:1999) dayInYear |
|
2479 |
(Date newDay:1 year:2000) dayInYear |
|
2480 |
(Date newDay:2 year:2000) dayInYear |
|
11349
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2481 |
(Date newDay:59 year:2004) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2482 |
(Date newDay:60 year:2004) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2483 |
(Date newDay:61 year:2004) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2484 |
(Date newDay:366 year:2004) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2485 |
(Date newDay:59 year:2005) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2486 |
(Date newDay:60 year:2005) dayInYear |
8ce689609977
Fix computation and printing of dates before 1901.
Stefan Vogel <sv@exept.de>
parents:
11182
diff
changeset
|
2487 |
(Date newDay:365 year:2005) dayInYear |
5548 | 2488 |
" |
2489 |
! |
|
2490 |
||
77 | 2491 |
dayOfMonth |
2492 |
"Answer the day of the month represented by me. |
|
2493 |
Same as day; for ST-80 compatibility." |
|
2494 |
||
2495 |
^ self day |
|
92 | 2496 |
|
2497 |
" |
|
2498 |
Date today dayOfMonth |
|
2499 |
" |
|
2500 |
! |
|
2501 |
||
2502 |
daysInMonth |
|
2503 |
"return the number of days in the month of the receiver" |
|
2504 |
||
2505 |
^ Date daysInMonth:(self month) forYear:(self year) |
|
2506 |
||
2507 |
" |
|
2508 |
Date today daysInMonth |
|
2509 |
" |
|
2510 |
! |
|
2511 |
||
2512 |
daysInYear |
|
2513 |
"return the number of days in the year of the receiver" |
|
2514 |
||
2515 |
^ Date daysInYear:(self year) |
|
2516 |
||
2517 |
" |
|
2518 |
Date today daysInYear |
|
2519 |
" |
|
2520 |
! |
|
2521 |
||
5778 | 2522 |
daysLeftInMonth |
2523 |
"return the number of days left in the month of the receiver" |
|
2524 |
||
2525 |
^ self daysInMonth - self day |
|
2526 |
||
2527 |
" |
|
2528 |
Date today daysLeftInMonth |
|
2529 |
" |
|
2530 |
! |
|
2531 |
||
92 | 2532 |
daysLeftInYear |
11079
cd8abd9e87a7
oops - daysLeftInYear was wrong
Claus Gittinger <cg@exept.de>
parents:
10912
diff
changeset
|
2533 |
"return the number of days left in the year of the receiver. |
cd8abd9e87a7
oops - daysLeftInYear was wrong
Claus Gittinger <cg@exept.de>
parents:
10912
diff
changeset
|
2534 |
Today is excluded from the count (i.e. in a non-leap-year, |
cd8abd9e87a7
oops - daysLeftInYear was wrong
Claus Gittinger <cg@exept.de>
parents:
10912
diff
changeset
|
2535 |
the first january will return 364)" |
cd8abd9e87a7
oops - daysLeftInYear was wrong
Claus Gittinger <cg@exept.de>
parents:
10912
diff
changeset
|
2536 |
|
cd8abd9e87a7
oops - daysLeftInYear was wrong
Claus Gittinger <cg@exept.de>
parents:
10912
diff
changeset
|
2537 |
^ (Date daysInYear:(self year)) - self dayOfYear |
92 | 2538 |
|
2539 |
" |
|
5282 | 2540 |
Date today daysLeftInYear |
92 | 2541 |
" |
77 | 2542 |
! |
2543 |
||
13234 | 2544 |
isLeapYear |
17053 | 2545 |
"return true, if the receiver's year is a leap year" |
68 | 2546 |
|
699 | 2547 |
^ Date leapYear:(self year) |
68 | 2548 |
|
92 | 2549 |
" |
13234 | 2550 |
Date today isLeapYear |
2551 |
(Date newDay:1 month:1 year:1992) isLeapYear |
|
92 | 2552 |
" |
68 | 2553 |
! |
2554 |
||
699 | 2555 |
month |
2556 |
"return the month (1..12) of the receiver" |
|
92 | 2557 |
|
699 | 2558 |
^ (dateEncoding // 100) \\ 100 |
68 | 2559 |
|
92 | 2560 |
" |
699 | 2561 |
Date today month |
92 | 2562 |
" |
68 | 2563 |
! |
2564 |
||
77 | 2565 |
monthIndex |
2566 |
"return the index of the month (e.g. Feb.=2). |
|
2567 |
Same as month; for ST-80 compatibility." |
|
2568 |
||
2569 |
^ self month |
|
2570 |
! |
|
2571 |
||
68 | 2572 |
monthName |
2573 |
"return the month of the receiver as a string. |
|
2574 |
The returned string depends on the language setting. |
|
2575 |
Expect things like 'january', 'february' ..." |
|
2576 |
||
2577 |
^ self class nameOfMonth:(self month) |
|
2578 |
||
92 | 2579 |
" |
2580 |
Date today monthName |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2581 |
(Date newDay:15 month:4 year:1959) monthName |
92 | 2582 |
" |
68 | 2583 |
! |
2584 |
||
7961 | 2585 |
monthNameForLanguage:languageOrNil |
16913 | 2586 |
"return the month-name of the receiver as a string in a given language. |
2587 |
The returned string depends on the resource translation file to be present for the |
|
2588 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
2589 |
If not, the english name is returned. |
|
7961 | 2590 |
Expect things like 'january', 'february' ..." |
2591 |
||
2592 |
^ self class nameOfMonth:(self month) language:languageOrNil |
|
2593 |
||
2594 |
" |
|
16913 | 2595 |
Date today monthName |
2596 |
||
2597 |
Date today monthNameForLanguage:#en |
|
2598 |
Date today monthNameForLanguage:#de |
|
2599 |
Date today monthNameForLanguage:#zulu |
|
7961 | 2600 |
" |
2601 |
! |
|
2602 |
||
5548 | 2603 |
weekInYear |
2604 |
"return the week number of the receiver - 1 for Jan, 1st. |
|
2605 |
each week is Mon .. Sun (i.e. Sunday belongs to the previous week)" |
|
2606 |
||
2607 |
^ self class weekInYearOf:self |
|
2608 |
||
2609 |
" |
|
2610 |
Date today weekInYear |
|
2611 |
(Date newDay:1 year:2000) weekInYear was a saturday |
|
2612 |
(Date newDay:2 year:2000) weekInYear was a sunday |
|
2613 |
(Date newDay:3 year:2000) weekInYear was a monday |
|
2614 |
(Date newDay:4 year:2000) weekInYear was a tuesday |
|
2615 |
(Date newDay:5 year:2000) weekInYear was a wed |
|
2616 |
(Date newDay:6 year:2000) weekInYear was a thursday |
|
2617 |
(Date newDay:7 year:2000) weekInYear was a fri |
|
2618 |
(Date newDay:8 year:2000) weekInYear was a sat |
|
2619 |
(Date newDay:9 year:2000) weekInYear was a sun |
|
2620 |
(Date newDay:10 year:2000) weekInYear was a monday |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2621 |
(Date newDay:3 month:1 year:2001) weekInYear |
5548 | 2622 |
" |
2623 |
! |
|
2624 |
||
699 | 2625 |
weekday |
2626 |
"return the week-day of the receiver as a string. |
|
16913 | 2627 |
The returned string depends on the current language setting. |
699 | 2628 |
Expect things like 'monday', 'tuesday' ... |
2629 |
For ST-80 compatibility" |
|
2630 |
||
2631 |
^ self class nameOfDay:(self dayInWeek) |
|
2632 |
||
2633 |
" |
|
2634 |
Date today weekday |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2635 |
(Date newDay:15 month:4 year:1959) weekday |
699 | 2636 |
" |
2637 |
! |
|
2638 |
||
16913 | 2639 |
weekdayForLanguage:lang |
2640 |
"return the week-day-name of the receiver as a string in a given language. |
|
2641 |
The returned string depends on the resource translation file to be present for the |
|
2642 |
given language (i.e. libbasic/resources(<lang>.rs). |
|
2643 |
If not, the english name is returned. |
|
2644 |
Expect things like 'monday', 'tuesday'..." |
|
2645 |
||
2646 |
^ self class nameOfDay:(self dayInWeek) language:lang |
|
2647 |
||
2648 |
" |
|
2649 |
Date today weekdayForLanguage:#de -> Mittwoch |
|
2650 |
Date today weekdayForLanguage:#en -> wednesday |
|
2651 |
Date today weekdayForLanguage:#zulu -> wednesday |
|
2652 |
||
2653 |
(Date newDay:15 month:4 year:1959) weekdayForLanguage:#de |
|
2654 |
(Date newDay:15 month:4 year:1959) weekdayForLanguage:#en |
|
2655 |
(Date newDay:15 month:4 year:1959) weekdayForLanguage:#zulu |
|
2656 |
" |
|
2657 |
! |
|
2658 |
||
699 | 2659 |
year |
16927 | 2660 |
"return the year of the receiver" |
699 | 2661 |
|
2662 |
^ dateEncoding // (100*100) |
|
68 | 2663 |
|
699 | 2664 |
" |
2665 |
Date today year |
|
16927 | 2666 |
Date today subtractDays:(1000 * 365) |
2667 |
Date today addDays:(1000 * 365) |
|
699 | 2668 |
" |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2669 |
! |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2670 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2671 |
year:year month:month day:day |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2672 |
dateEncoding := self class encodeYear:year month:month day:day |
699 | 2673 |
! ! |
2674 |
||
2675 |
!Date methodsFor:'arithmetic'! |
|
2676 |
||
8201 | 2677 |
+ days |
2678 |
"return a new date representing 'days' after the receiver. |
|
2679 |
The argument should be some kind of integer. |
|
2680 |
This is the same as #addDays." |
|
2681 |
||
16927 | 2682 |
^ self class fromDaysFrom0:(self asDaysFrom0 + days) |
8201 | 2683 |
|
2684 |
" |
|
2685 |
Date today + 7. |
|
2686 |
||
2687 |
Date today to:(Date today + 28) by:7 do:[:date| |
|
2688 |
Transcript show:date weekday; show:', '; showCr:date |
|
2689 |
]. |
|
2690 |
" |
|
2691 |
! |
|
2692 |
||
2693 |
- aDateOrNumberOfDays |
|
2694 |
"return the delta in days (anInteger) between 2 dates or |
|
2695 |
subtract a number of days from a date returning a Date" |
|
2696 |
||
2697 |
aDateOrNumberOfDays class == self class ifTrue:[ |
|
16927 | 2698 |
^ self asDaysFrom0 - aDateOrNumberOfDays asDaysFrom0 |
8201 | 2699 |
]. |
2700 |
||
16927 | 2701 |
^ self class fromDaysFrom0:(self asDaysFrom0 - aDateOrNumberOfDays asInteger) |
8201 | 2702 |
|
2703 |
" |
|
16927 | 2704 |
Date today - Date yesterday |
2705 |
Date today - 3 |
|
2706 |
Date today + 3 |
|
8201 | 2707 |
" |
2708 |
! |
|
2709 |
||
699 | 2710 |
addDays:days |
2711 |
"return a new date representing 'days' after the receiver. |
|
2712 |
The argument should be some kind of integer. |
|
2713 |
For ST-80 compatibility." |
|
2714 |
||
16927 | 2715 |
^ self class fromDaysFrom0:(self asDaysFrom0 + days) |
699 | 2716 |
|
2717 |
" |
|
2718 |
Date today addDays:7 |
|
2719 |
" |
|
2720 |
! |
|
2721 |
||
14331 | 2722 |
addMonths:numberOfMonths |
16927 | 2723 |
"Return a new instance which added numberOfMonths to self months. |
2724 |
Keep the day of month if possible. |
|
14331 | 2725 |
If the month of the new instance has fewer days than self dayOfMonth set the day to the last |
2726 |
day of the new instance's month. |
|
2727 |
Does (probably) not work correct for resulting dates before calendar reform. |
|
2728 |
" |
|
2729 |
|yearToAdd years monthsInYear tempDate newMonth newMonthAsDate| |
|
2730 |
||
2731 |
yearToAdd := 0. |
|
2732 |
years := numberOfMonths // 12. |
|
2733 |
monthsInYear := numberOfMonths \\ 12. |
|
2734 |
tempDate := self addYears:years. |
|
2735 |
||
2736 |
newMonth := tempDate month + monthsInYear. |
|
2737 |
(newMonth between:1 and:12) ifFalse:[ |
|
2738 |
newMonth := newMonth \\ 12. |
|
2739 |
yearToAdd := 1. |
|
2740 |
]. |
|
2741 |
||
2742 |
newMonthAsDate := self class |
|
2743 |
newDay:1 |
|
2744 |
month:newMonth |
|
2745 |
year:(tempDate year + yearToAdd). |
|
2746 |
||
2747 |
^ self class |
|
2748 |
newDay:(newMonthAsDate daysInMonth min:tempDate day) |
|
2749 |
month:newMonth |
|
2750 |
year:(tempDate year + yearToAdd) |
|
2751 |
||
2752 |
"Created: / 23-08-2012 / 11:04:17 / sr" |
|
2753 |
"Created: / 24-08-2012 / 12:14:52 / anwild" |
|
2754 |
! |
|
2755 |
||
2756 |
addMonthsUsingEncoding:numberOfMonths |
|
16927 | 2757 |
"Return a new instance which added numberOfMonths to self months. |
2758 |
Keep the day of month if possible. |
|
2759 |
If the month of the new instance has fewer days than self dayOfMonth, |
|
2760 |
set the day to the last day of the new instance's month. |
|
2761 |
Does (probably) not work correct for resulting dates before calendar reform." |
|
2762 |
||
14331 | 2763 |
| newEncoding | |
16927 | 2764 |
|
14331 | 2765 |
newEncoding := dateEncoding |
2766 |
+ ((numberOfMonths + self month) // 12 * 10000) "the new year" |
|
2767 |
+ ((((numberOfMonths \\ 12) + self month) \\ 12) * 100) "the new month" |
|
2768 |
- (self month * 100) "in the line above the new month is already completely calculated. So subtract the current month" |
|
2769 |
- self day "in the line below the new day is already completely calculated. So subtract the current day" |
|
2770 |
+ (self day min: self daysInMonth). "the new day considering the maximum number of days in the new month." |
|
16927 | 2771 |
^ Date |
2772 |
newDay: newEncoding \\ 100 |
|
2773 |
month: (newEncoding // 100 \\ 100) |
|
2774 |
year: newEncoding // 10000. |
|
14331 | 2775 |
|
2776 |
"Created: / 24-08-2012 / 15:18:44 / anwild" |
|
2777 |
! |
|
2778 |
||
2779 |
addYears:numberOfYears |
|
16927 | 2780 |
"Return a new instance which is the same date, but numberOfYears ahead of self. |
2781 |
Cares about leap years. |
|
2782 |
I.e. goes from a leap year's 29.feb to a non-leap year's 28.feb." |
|
2783 |
||
2784 |
|newYear newDay newMonth| |
|
14331 | 2785 |
|
2786 |
newYear := self year + numberOfYears. |
|
16927 | 2787 |
newDay := self day. |
2788 |
newMonth := self month. |
|
2789 |
||
2790 |
"/ special care for the 29th of February in a leapYear |
|
2791 |
(newDay = 29 and:[newMonth == 2]) ifTrue:[ |
|
2792 |
(self class leapYear:newYear) ifFalse: [ |
|
14331 | 2793 |
newDay := 28. |
2794 |
]. |
|
2795 |
]. |
|
2796 |
||
2797 |
^ self class |
|
2798 |
newDay:newDay |
|
16927 | 2799 |
month:newMonth |
14331 | 2800 |
year:newYear |
2801 |
||
2802 |
"Created: / 23-08-2012 / 11:05:04 / sr" |
|
2803 |
"Created: / 24-08-2012 / 12:14:09 / anwild" |
|
2804 |
! |
|
2805 |
||
9262 | 2806 |
daysSince:aDate |
2807 |
"return the number of days between the receiver and the argument, |
|
2808 |
aDate, which should be some kind of date" |
|
2809 |
||
16927 | 2810 |
^ self asDaysFrom0 - aDate asDaysFrom0 |
9262 | 2811 |
|
2812 |
" |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2813 |
Date today daysSince:(Date newDay:1 month:1 year:1901) |
9262 | 2814 |
" |
2815 |
! |
|
2816 |
||
699 | 2817 |
daysUntil:aDate |
2818 |
"return the number of days between the receiver and the argument, |
|
8201 | 2819 |
aDate, which should be some kind of date" |
699 | 2820 |
|
16927 | 2821 |
^ aDate asDaysFrom0 - self asDaysFrom0 |
68 | 2822 |
|
92 | 2823 |
" |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2824 |
(Date newDay:24 month:12 year:1994) daysUntil:(Date day:1 month:1 year:1995) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2825 |
(Date newDay:1 month:2 year:1992) daysUntil:(Date day:1 month:3 year:1992) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2826 |
(Date newDay:1 month:2 year:1994) daysUntil:(Date day:1 month:3 year:1994) |
699 | 2827 |
|
2828 |
|delta| |
|
2829 |
delta := Date today |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2830 |
daysUntil:(Date newDay:25 month:12 year:Date today year). |
699 | 2831 |
Transcript show:'still '; |
8201 | 2832 |
show:delta ; |
2833 |
showCR:' days till xmas' |
|
699 | 2834 |
" |
2835 |
! |
|
2836 |
||
11741 | 2837 |
firstDayInPreviousMonth:nMonths |
16927 | 2838 |
"Return the first day of a previous month (0=this month, 1=prev. month, etc.). |
2839 |
CG: there are two such methods - which one is obsolete?" |
|
2840 |
||
2841 |
^ self firstDayOfPreviousMonth:nMonths |
|
11741 | 2842 |
|
2843 |
" |
|
2844 |
(Date newDay:3 month:6 year:2009) firstDayInMonth |
|
2845 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:0 |
|
2846 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:5 |
|
2847 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:6 |
|
2848 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:7 |
|
2849 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:17 |
|
2850 |
(Date newDay:3 month:6 year:2009) firstDayInPreviousMonth:18 |
|
2851 |
" |
|
2852 |
! |
|
2853 |
||
2854 |
firstDayOfPreviousMonth:nMonths |
|
16927 | 2855 |
"Return the first day of a previous month (0=this month). |
2856 |
CG: there are two such methods - which one is obsolete? (see firstDayInPreviousMonth:)" |
|
11741 | 2857 |
|
2858 |
|month year| |
|
2859 |
||
2860 |
month := self month. |
|
2861 |
year := self year. |
|
2862 |
month := month - nMonths. |
|
2863 |
month < 1 ifTrue:[ |
|
2864 |
year := year - 1 - (month negated // 12). |
|
2865 |
month := (12 - (month negated \\ 12)). |
|
2866 |
]. |
|
2867 |
||
2868 |
^ Date newDay:1 month:month year:year. |
|
2869 |
||
2870 |
" |
|
2871 |
(Date newDay:3 month:6 year:2009) firstDayInMonth |
|
2872 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:0 |
|
2873 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:5 |
|
2874 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:6 |
|
2875 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:7 |
|
2876 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:17 |
|
2877 |
(Date newDay:3 month:6 year:2009) firstDayOfPreviousMonth:18 |
|
2878 |
" |
|
2879 |
! |
|
2880 |
||
699 | 2881 |
subtractDate:aDate |
2882 |
"return the number of days between the receiver and aDate" |
|
2883 |
||
16927 | 2884 |
^ self asDaysFrom0 - aDate asDaysFrom0 |
699 | 2885 |
|
2886 |
" |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2887 |
(Date newDay:1 month:1 year:1995) subtractDate:(Date newDay:24 month:12 year:1994) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2888 |
(Date newDay:1 month:3 year:1992) subtractDate:(Date newDay:1 month:2 year:1992) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2889 |
(Date newDay:1 month:3 year:1994) subtractDate:(Date newDay:1 month:2 year:1994) |
699 | 2890 |
" |
2891 |
! |
|
2892 |
||
2893 |
subtractDays:days |
|
2894 |
"return a new date representing 'days' before the receiver. |
|
2895 |
The argument should be some kind of integer. |
|
2896 |
For ST-80 compatibility" |
|
2897 |
||
16927 | 2898 |
^ self class fromDaysFrom0:(self asDaysFrom0 - days) |
699 | 2899 |
|
2900 |
" |
|
2901 |
Date today subtractDays:7 |
|
92 | 2902 |
" |
1 | 2903 |
! ! |
2904 |
||
2905 |
!Date methodsFor:'comparing'! |
|
2906 |
||
29 | 2907 |
< aDate |
2908 |
"return true, if the date represented by the receiver |
|
2909 |
is before the argument, aDate" |
|
2910 |
||
54 | 2911 |
(aDate isMemberOf:Date) ifTrue:[ |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2912 |
^ dateEncoding < aDate dateEncoding |
54 | 2913 |
]. |
29 | 2914 |
|
54 | 2915 |
"the argument must understand year, month and day to be |
2916 |
comparable, whatever it is" |
|
2917 |
||
12796 | 2918 |
^ dateEncoding < (Date encodeYear:aDate year month:aDate month day:aDate day) |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2919 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2920 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2921 |
Date today < (Date day:24 month:12 year:2000) |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2922 |
Date today < (Date day:24 month:12 year:1900) |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2923 |
Date today < Timestamp now |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2924 |
Date today-1 < Timestamp now |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2925 |
" |
29 | 2926 |
! |
1 | 2927 |
|
2928 |
= aDate |
|
2929 |
"return true, if the date represented by the receiver |
|
2930 |
is the same as the one represented by argument, aDate" |
|
2931 |
||
155 | 2932 |
(aDate isMemberOf:Date) ifFalse:[^ false]. |
2933 |
||
2934 |
^ dateEncoding = aDate dateEncoding |
|
54 | 2935 |
|
2936 |
"the argument must understand year, month and day to be |
|
2937 |
comparable, whatever it is" |
|
2938 |
||
155 | 2939 |
" |
54 | 2940 |
^ dateEncoding = (Date encodeYear:aDate year |
155 | 2941 |
month:aDate month |
2942 |
day:aDate day) |
|
2943 |
" |
|
68 | 2944 |
"Date today = ((Date today plusDays:7) minusDays:7)" |
92 | 2945 |
! |
2946 |
||
699 | 2947 |
> aDate |
2948 |
"return true, if the date represented by the receiver |
|
2949 |
is after the argument, aDate" |
|
2950 |
||
2951 |
(aDate isMemberOf:Date) ifTrue:[ |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2952 |
^ dateEncoding > aDate dateEncoding |
699 | 2953 |
]. |
2954 |
||
2955 |
"the argument must understand year, month and day to be |
|
2956 |
comparable, whatever it is" |
|
2957 |
||
12796 | 2958 |
^ dateEncoding > (Date encodeYear:aDate year month:aDate month day:aDate day) |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2959 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2960 |
" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2961 |
Date today > (Date newDay:24 month:12 year:2099) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2962 |
Date today > (Date newDay:24 month:12 year:1900) |
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2963 |
Date today > Timestamp now |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
2964 |
Date today+1 > Timestamp now |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2965 |
" |
699 | 2966 |
! |
2967 |
||
92 | 2968 |
hash |
2969 |
"return an integer useful for hashing on dates" |
|
2970 |
||
2971 |
^ dateEncoding |
|
1 | 2972 |
! ! |
2973 |
||
1501 | 2974 |
!Date methodsFor:'converting'! |
2975 |
||
4408 | 2976 |
asDate |
2977 |
"return the receiver" |
|
2978 |
||
2979 |
^ self |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2980 |
! |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2981 |
|
13234 | 2982 |
asLocalTimestamp |
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2983 |
"return an TimeStamp instance, representing midnight of last night" |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2984 |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2985 |
^ Timestamp |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2986 |
year:(self year) month:(self month) day:(self day) |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
2987 |
hour:0 minute:0 second:0 millisecond:0 |
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2988 |
|
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
2989 |
" |
13234 | 2990 |
Date today asLocalTimestamp |
2991 |
" |
|
2992 |
! |
|
2993 |
||
2994 |
asTimestamp |
|
2995 |
"return an TimeStamp instance, representing midnight of last night" |
|
2996 |
||
2997 |
^ self asLocalTimestamp |
|
2998 |
||
2999 |
" |
|
8247
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
3000 |
Date today asTimestamp |
146e7e7dcf57
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
8201
diff
changeset
|
3001 |
" |
13234 | 3002 |
! |
3003 |
||
3004 |
asUtcTimestamp |
|
16927 | 3005 |
"return an UtcTimestamp instance, representing midnight of last night" |
13234 | 3006 |
|
3007 |
^ UtcTimestamp |
|
3008 |
year:(self year) month:(self month) day:(self day) |
|
3009 |
hour:0 minute:0 second:0 millisecond:0 |
|
3010 |
||
3011 |
" |
|
3012 |
Date today asUtcTimestamp |
|
3013 |
" |
|
5775
92b02a4a7e83
week in year - again (based upon thursday-rule)
Claus Gittinger <cg@exept.de>
parents:
5679
diff
changeset
|
3014 |
! ! |
1501 | 3015 |
|
14496 | 3016 |
|
17053 | 3017 |
|
8201 | 3018 |
!Date methodsFor:'obsolete'! |
3019 |
||
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3020 |
asAbsoluteTime |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3021 |
"deprecated, use #asTimestamp" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3022 |
<resource:#obsolete> |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3023 |
|
12001 | 3024 |
self obsoleteMethodWarning:'use #asTimestamp'. |
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3025 |
^ self asTimestamp |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3026 |
! |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3027 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3028 |
dayCount |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3029 |
"return the number of days since 1st. Jan. 1901; |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3030 |
starting with 0 for this date. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3031 |
Date>>fromDays: is the reverse operation. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3032 |
Obsolete: |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3033 |
please use asDays for ST-80 compatibility" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3034 |
<resource:#obsolete> |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3035 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3036 |
^ self asDays. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3037 |
! |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3038 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3039 |
dayName |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3040 |
"return the week-day of the receiver as a string. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3041 |
The returned string depends on the language setting. |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3042 |
Expect things like 'monday', 'tuesday' ... |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3043 |
Obsolete: |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3044 |
use #weekday for ST-80 compatibility" |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3045 |
<resource:#obsolete> |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3046 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3047 |
^ self weekday |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3048 |
! |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3049 |
|
13234 | 3050 |
leap |
3051 |
"return true, if the receivers year is a leap year" |
|
3052 |
<resource: #obsolete> |
|
3053 |
||
3054 |
^ self isLeapYear |
|
3055 |
||
3056 |
" |
|
3057 |
Date today leap |
|
3058 |
(Date newDay:1 month:1 year:1992) leap |
|
3059 |
" |
|
3060 |
! |
|
3061 |
||
8201 | 3062 |
minusDays:days |
3063 |
"return a new date representing 'days' before the receiver. |
|
3064 |
The argument should be some kind of integer. |
|
3065 |
Obsolete: |
|
3066 |
Please dont use this method since it will vanish. |
|
3067 |
Use #subtractDays: instead for ST-80 compatibility." |
|
3068 |
||
3069 |
<resource: #obsolete> |
|
3070 |
||
3071 |
self obsoleteMethodWarning:'use #substractDays:'. |
|
3072 |
^ self subtractDays:days |
|
3073 |
! |
|
3074 |
||
3075 |
plusDays:days |
|
3076 |
"return a new date representing 'days' after the receiver. |
|
3077 |
The argument should be some kind of integer. |
|
3078 |
Obsolete: |
|
3079 |
Please dont use this method since it will vanish. |
|
3080 |
Use #addDays: instead for ST-80 compatibility." |
|
3081 |
||
3082 |
<resource: #obsolete> |
|
3083 |
||
3084 |
self obsoleteMethodWarning:'use #addDays:'. |
|
3085 |
^ self addDays:days |
|
3086 |
! ! |
|
3087 |
||
17053 | 3088 |
|
54 | 3089 |
!Date methodsFor:'printing & storing'! |
1 | 3090 |
|
5778 | 3091 |
addPrintBindingsTo:aDictionary |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3092 |
self addPrintBindingsTo:aDictionary language:nil. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3093 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3094 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3095 |
addPrintBindingsTo:aDictionary language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3096 |
"private print support: add bindings for printing to aDictionary. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3097 |
languageOrNil can only be #en or nil for the current language. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3098 |
valid format items are: |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3099 |
%d - day, 01..31 0-padded to length 2 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3100 |
%m - month, 01..12 0-padded to length 2 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3101 |
%w - week in year, 00..53 0-padded to length 2 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3102 |
%y - year, full i.e. 1999, 2004 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3103 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3104 |
special: |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3105 |
%D - day - unpadded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3106 |
%M - month - unpadded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3107 |
%W - week in year - unpadded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3108 |
%Y - year, last 2 digits only i.e. 99, 04 (danger: year 2k bug) |
5778 | 3109 |
|
13174
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3110 |
%(weekDay) - day in week (1->monday, 2->tuesday, ... ,7->sunday) |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3111 |
|
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3112 |
%(dayName) - full day name |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3113 |
%(DayName) - full day name, first character uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3114 |
%(DAYNAME) - full day name, all uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3115 |
|
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3116 |
%(monthName) - full month name |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3117 |
%(MonthName) - full month name, first character uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3118 |
%(MONTHNAME) - full month name, all uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3119 |
|
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3120 |
%(shortDayName) - short (abbreviated) day name |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3121 |
%(ShortDayName) - short (abbreviated) day name, first character uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3122 |
%(SHORTDAYNAME) - short (abbreviated) day name, all uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3123 |
|
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3124 |
%(shortMonthName) - short (abbreviated) month name |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3125 |
%(ShortMonthName) - short (abbreviated) month name, first character uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3126 |
%(SHORTMONTHNAME) - short (abbreviated) month name, all uppercase |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3127 |
|
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3128 |
%(nth) - counting day-in-month (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3129 |
%(weekDayNth) - counting day-in-week (1->'st'; 2->'nd'; 3->'rd'; 4...->'th') |
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3130 |
%(weekNth) - counting week-in-year (1->'st'; 2->'nd'; 3->'rd'; 4...->'th')" |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3131 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3132 |
|day ds dsPadded0 dsPaddedB month ms msPadded0 msPaddedB |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3133 |
year weekInYear monthName shortMonthName |
12663 | 3134 |
dayInWeek dayOfWeek dayName shortDayName ws wsPadded0| |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3135 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3136 |
day := self day. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3137 |
ds := day printString. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3138 |
dsPaddedB := day printStringLeftPaddedTo:2. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3139 |
dsPadded0 := day printStringLeftPaddedTo:2 with:$0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3140 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3141 |
month := self month. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3142 |
ms := month printString. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3143 |
msPaddedB := month printStringLeftPaddedTo:2. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3144 |
msPadded0 := month printStringLeftPaddedTo:2 with:$0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3145 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3146 |
year := self year. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3147 |
weekInYear := self weekInYear. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3148 |
ws := weekInYear printString. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3149 |
wsPadded0 := weekInYear printStringLeftPaddedTo:2 with:$0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3150 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3151 |
dayInWeek := self dayInWeek. "/ 1 .. 7 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3152 |
dayOfWeek := self dayOfWeek. "/ 0 .. 6 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3153 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3154 |
monthName := self class nameOfMonth:(self month) language:languageOrNil. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3155 |
dayName := self class nameOfDay:dayInWeek language:languageOrNil. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3156 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3157 |
aDictionary at:#day put:dsPadded0. "/ 0-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3158 |
aDictionary at:#daypadded put:dsPaddedB. "/ Blank-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3159 |
aDictionary at:#dayPadded put:dsPaddedB. "/ Blank-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3160 |
aDictionary at:#Day put:ds. "/ unpadded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3161 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3162 |
aDictionary at:#month put:msPadded0. "/ 0-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3163 |
aDictionary at:#monthPadded put:msPaddedB. "/ Blank-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3164 |
aDictionary at:#monthpadded put:msPaddedB. "/ Blank-padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3165 |
aDictionary at:#Month put:ms. "/ unpadded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3166 |
aDictionary at:#mon put:msPadded0. "/ 0-padded - for backward compatibility only |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3167 |
aDictionary at:#Mon put:ms. "/ unpadded - for backward compatibility only |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3168 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3169 |
aDictionary at:#year put:year. "/ padded |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3170 |
aDictionary at:#week put:wsPadded0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3171 |
aDictionary at:#Week put:ws. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3172 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3173 |
year ~~ Date today year ifTrue:[ |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3174 |
aDictionary at:#yearOrTime put:(' ' , year printString). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3175 |
]. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3176 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3177 |
aDictionary at:$d put:dsPadded0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3178 |
aDictionary at:$D put:ds. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3179 |
aDictionary at:$m put:msPadded0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3180 |
aDictionary at:$M put:ms. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3181 |
aDictionary at:$y put:year. |
12663 | 3182 |
aDictionary at:$Y put:((year \\ 100) printStringLeftPaddedTo:2 with:$0). |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3183 |
aDictionary at:$w put:wsPadded0. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3184 |
aDictionary at:$W put:ws. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3185 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3186 |
aDictionary at:#monthName put:monthName. |
14496 | 3187 |
aDictionary at:#monthname put:monthName asLowercase. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3188 |
aDictionary at:#MonthName put:monthName asUppercaseFirst. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3189 |
aDictionary at:#MONTHNAME put:monthName asUppercase. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3190 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3191 |
aDictionary at:#dayName put:dayName. |
14496 | 3192 |
aDictionary at:#dayname put:dayName asLowercase. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3193 |
aDictionary at:#DayName put:dayName asUppercaseFirst. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3194 |
aDictionary at:#DAYNAME put:dayName asUppercase. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3195 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3196 |
aDictionary at:#weekDay put:dayInWeek. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3197 |
aDictionary at:#weekday put:dayInWeek. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3198 |
aDictionary at:#weekDayUS put:dayOfWeek. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3199 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3200 |
aDictionary at:#shortDayName put:(shortDayName := self class abbreviatedNameOfDay:(self dayInWeek) language:languageOrNil). |
14496 | 3201 |
aDictionary at:#shortdayname put:shortDayName asLowercase. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3202 |
aDictionary at:#ShortDayName put:shortDayName asUppercaseFirst. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3203 |
aDictionary at:#SHORTDAYNAME put:shortDayName asUppercase. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3204 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3205 |
aDictionary at:#shortMonthName put:(shortMonthName := self class abbreviatedNameOfMonth:(self month) language:languageOrNil). |
14496 | 3206 |
aDictionary at:#shortmonthname put:shortMonthName asLowercase. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3207 |
aDictionary at:#ShortMonthName put:shortMonthName asUppercaseFirst. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3208 |
aDictionary at:#SHORTMONTHNAME put:shortMonthName asUppercase. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3209 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3210 |
aDictionary at:#nth put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th') at:day \\ 10 + 1). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3211 |
"/ 0 1 2 3 4 5 6 7 8 9 |
13174
2fe9eccdb8e4
comment/format in: #addPrintBindingsTo:language:
Stefan Vogel <sv@exept.de>
parents:
12814
diff
changeset
|
3212 |
aDictionary at:#weekDayNth put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th') at:(dayOfWeek-1) \\ 10 + 1). |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3213 |
"/ 0 1 2 3 4 5 6 |
14496 | 3214 |
aDictionary at:#weekDayUSNth put:(#('st' 'nd' 'rd' 'th' 'th' 'th' 'th') at:(dayOfWeek-1) \\ 10 + 1). |
3215 |
"/ 0 1 2 3 4 5 6 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3216 |
aDictionary at:#weekNth put:(#('th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th') at:weekInYear \\ 10 + 1). |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3217 |
"/ 0 1 2 3 4 5 6 7 8 9 |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3218 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3219 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3220 |
printOn:aStream |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3221 |
"append a printed representation of the receiver to aStream" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3222 |
|
10908
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3223 |
self printOn:aStream format:(self class defaultFormatString) language:nil. |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3224 |
|
5778 | 3225 |
" |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3226 |
Date today printOn:Transcript. Transcript cr. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3227 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3228 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3229 |
"Modified: 27.8.1995 / 01:01:49 / claus" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3230 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3231 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3232 |
printOn:aStream format:aFormatStringOrSqueakFormatArray |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3233 |
"print using a format string; |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3234 |
see #addPrintBindingsTo: for a list of valid format strings" |
5778 | 3235 |
|
10908
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3236 |
self printOn:aStream format:aFormatStringOrSqueakFormatArray language:nil. |
5778 | 3237 |
|
3238 |
" |
|
3239 |
Date today printOn:Transcript format:'%y%m%d' (iso format) |
|
3240 |
Date today printOn:Transcript format:'%y-%m-%d' (iso format) |
|
3241 |
Date today printOn:Transcript format:'%y-W%w' (iso format - working week) |
|
3242 |
Date today printOn:Transcript format:'%d-%m-%y' (european trivia format) |
|
3243 |
Date today printOn:Transcript format:'%m/%d/%y' (us trivia format) |
|
3244 |
Date today printOn:Transcript format:'%D-%(monthName)-%y' (us trivia format) |
|
3245 |
Date today printOn:Transcript format:'%D-%(MonthName)-%y' (us trivia format) |
|
3246 |
Date today printOn:Transcript format:'%D-%(MONTHNAME)-%y' (us trivia format) |
|
3247 |
Date today printOn:Transcript format:'%(DayName), %D%(nth) of %(MonthName), %y' |
|
3248 |
Date today printOn:Transcript format:'%(ShortDayName), %D-%(ShortMonthName)-%y' |
|
3249 |
Date today printOn:Transcript format:'%d%m%Y' (millenium bug format - danger) |
|
3250 |
Date today printOn:Transcript format:'Today is the %(weekDay) day of the week' |
|
3251 |
" |
|
15200 | 3252 |
"short form (as in blogs like www.stackoverflow, www.superuser etc.) |
3253 |
Date today printOn:Transcript format:'%(MonthName) %D ''%Y' |
|
3254 |
Timestamp now printOn:Transcript format:'%(MonthName) %D ''%Y at %h:%m' |
|
3255 |
" |
|
7023 | 3256 |
" |
3257 |
String streamContents:[:s | |
|
3258 |
Date today printOn:s format:#(1 2 3 $/ 1 2) |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3259 |
] |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3260 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3261 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3262 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3263 |
printOn:aStream format:aFormatStringOrSqueakFormatArray language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3264 |
"print using a format string; |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3265 |
languageOrNil can only be #en or nil for the current language. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3266 |
see #addPrintBindingsTo: for a list of valid format strings" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3267 |
|
10908
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3268 |
|dict| |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3269 |
|
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3270 |
aFormatStringOrSqueakFormatArray isArray ifTrue:[ |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3271 |
"backward compatibility: a squeak/st80 format array" |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3272 |
self printFormat:aFormatStringOrSqueakFormatArray on:aStream. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3273 |
^ self. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3274 |
]. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3275 |
|
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3276 |
dict := IdentityDictionary new. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3277 |
self addPrintBindingsTo:dict language:languageOrNil. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3278 |
|
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3279 |
aFormatStringOrSqueakFormatArray expandPlaceholdersWith:dict on:aStream |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3280 |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3281 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3282 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3283 |
Date today |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3284 |
printOn:Transcript |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3285 |
format:'%y%m%d' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3286 |
language:#en |
7023 | 3287 |
" |
5778 | 3288 |
! |
3289 |
||
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3290 |
printOn:aStream language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3291 |
"append a printed representation of the receiver to aStream. |
8179 | 3292 |
The argument languageOrNil can only be #en or nil for the current language." |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3293 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3294 |
|format| |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3295 |
|
8118 | 3296 |
(DefaultFormats isNil or:[EnvironmentChange]) ifTrue:[ |
8145 | 3297 |
self class initNames |
8118 | 3298 |
]. |
8179 | 3299 |
format := DefaultFormats at:(languageOrNil ? Language) ifAbsent:[DefaultFormats at:#en]. |
3300 |
self printOn:aStream format:format language:languageOrNil. |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3301 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3302 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3303 |
Date today printOn:Transcript language:#en |
13195
d3a5d03a1c1c
comment/format in: #printOn:language:
Claus Gittinger <cg@exept.de>
parents:
13174
diff
changeset
|
3304 |
Date today printOn:Transcript language:#de |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3305 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3306 |
|
8179 | 3307 |
"Modified: / 27-08-1995 / 01:01:49 / claus" |
3308 |
"Modified: / 12-03-2004 / 19:23:54 / cg" |
|
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3309 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3310 |
|
7023 | 3311 |
printStringFormat:aFormatStringOrArray |
5778 | 3312 |
"print using a format string; |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3313 |
see #addPrintBindingsTo: for a list of valid format strings" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3314 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3315 |
^ self printStringFormat:aFormatStringOrArray language:nil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3316 |
|
5778 | 3317 |
" |
8111
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3318 |
Date today printStringFormat:'%y%m%d' (iso format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3319 |
Date today printStringFormat:'%y-%m-%d' (iso format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3320 |
Date today printStringFormat:'%y-W%w' (iso format - working week) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3321 |
Date today printStringFormat:'%d-%m-%y' (european trivia format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3322 |
Date today printStringFormat:'%m/%d/%y' (us trivia format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3323 |
Date today printStringFormat:'%D-%(monthName)-%y' (us trivia format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3324 |
Date today printStringFormat:'%D-%(MonthName)-%y' (us trivia format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3325 |
Date today printStringFormat:'%D-%(MONTHNAME)-%y' (us trivia format) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3326 |
Date today printStringFormat:'%(DayName), %D%(nth) of %(MonthName), %y' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3327 |
Date today printStringFormat:'%(ShortDayName), %D-%(ShortMonthName)-%y' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3328 |
Date today printStringFormat:'%d%m%Y' (millenium bug format - danger) |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3329 |
Date today printStringFormat:'Today is day %(weekDay) of the week' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3330 |
Date today printStringFormat:'Today is the %(weekDay)%(weekDayNth) day of the week' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3331 |
Date today printStringFormat:'Today is the %(Day)%(nth) day of the month' |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3332 |
" |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3333 |
! |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3334 |
|
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3335 |
printStringFormat:aFormatStringOrArray language:languageOrNil |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3336 |
"print using a format string; |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3337 |
languageOrNil can only be #en or nil for the current language. |
67347b7e3e69
print bindings (care for language specifics)
Claus Gittinger <cg@exept.de>
parents:
7961
diff
changeset
|
3338 |
see #addPrintBindingsTo: for a list of valid format strings" |
5778 | 3339 |
|
10908
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3340 |
|s| |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3341 |
|
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3342 |
s := WriteStream on:(String new:20). |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3343 |
self printOn:s format:aFormatStringOrArray language:languageOrNil. |
88b75a3ed4eb
Now printStringXXXX uses printOn:XXXX.
Stefan Vogel <sv@exept.de>
parents:
10879
diff
changeset
|
3344 |
^ s contents. |
5778 | 3345 |
|
3346 |
" |
|
3347 |
Date today printStringFormat:'%y%m%d' (iso format) |
|
3348 |
Date today printStringFormat:'%y-%m-%d' (iso format) |
|
3349 |
Date today printStringFormat:'%y-W%w' (iso format - working week) |
|
3350 |
Date today printStringFormat:'%d-%m-%y' (european trivia format) |
|
3351 |
Date today printStringFormat:'%m/%d/%y' (us trivia format) |
|
3352 |
Date today printStringFormat:'%D-%(monthName)-%y' (us trivia format) |
|
3353 |
Date today printStringFormat:'%D-%(MonthName)-%y' (us trivia format) |
|
3354 |
Date today printStringFormat:'%D-%(MONTHNAME)-%y' (us trivia format) |
|
3355 |
Date today printStringFormat:'%(DayName), %D%(nth) of %(MonthName), %y' |
|
3356 |
Date today printStringFormat:'%(ShortDayName), %D-%(ShortMonthName)-%y' |
|
3357 |
Date today printStringFormat:'%d%m%Y' (millenium bug format - danger) |
|
7327 | 3358 |
Date today printStringFormat:'Today is day %(weekDay) of the week' |
3359 |
Date today printStringFormat:'Today is the %(weekDay)%(weekDayNth) day of the week' |
|
3360 |
Date today printStringFormat:'Today is the %(Day)%(nth) day of the month' |
|
5778 | 3361 |
" |
3362 |
! |
|
3363 |
||
699 | 3364 |
storeOn:aStream |
3365 |
"append a representation to aStream, from which the receiver |
|
3366 |
can be reconstructed" |
|
3367 |
||
3368 |
aStream nextPutAll:'('; nextPutAll:'Date day:'. |
|
3369 |
self day printOn:aStream. |
|
3370 |
aStream nextPutAll:' month:'. |
|
3371 |
self month printOn:aStream. |
|
3372 |
aStream nextPutAll:' year:'. |
|
3373 |
self year printOn:aStream. |
|
3374 |
aStream nextPutAll:')' |
|
3375 |
||
3376 |
" |
|
3377 |
Date today storeOn:Transcript |
|
3378 |
Date today storeString |
|
3379 |
" |
|
1 | 3380 |
! ! |
699 | 3381 |
|
7258 | 3382 |
!Date methodsFor:'private-accessing'! |
699 | 3383 |
|
3384 |
dateEncoding |
|
3385 |
"the internal encoding is stricktly private, |
|
3386 |
and should not be used outside." |
|
3387 |
||
3388 |
^ dateEncoding |
|
3389 |
! |
|
3390 |
||
3391 |
dateEncoding:anInteger |
|
3392 |
"the internal encoding is stricktly private, |
|
3393 |
and should not be used outside." |
|
3394 |
||
3395 |
dateEncoding := anInteger |
|
3396 |
! |
|
3397 |
||
3398 |
fromOSTime:osTime |
|
13234 | 3399 |
"set my dateEncoding as date in the local timezone from an OS time. |
699 | 3400 |
This somewhat clumsy implementation hides the OS's date representation |
3401 |
(i.e. makes this class independent of what the OS starts its time values with). |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3402 |
Don't use this method, the osTime representation is totally unportable." |
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3403 |
|
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3404 |
|v| |
5858 | 3405 |
|
3406 |
v := OperatingSystem computeTimeAndDateFrom:osTime. |
|
11350
68606ef82813
Fix examples. Use common dateEncoding methods.
Stefan Vogel <sv@exept.de>
parents:
11349
diff
changeset
|
3407 |
dateEncoding := self class encodeYear:v year month:v month day:v day |
1501 | 3408 |
|
3409 |
"Modified: 1.7.1996 / 15:23:12 / cg" |
|
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3410 |
! |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3411 |
|
13234 | 3412 |
fromUtcOSTime:osTime |
3413 |
"set my dateEncoding as UTC date from an OS time. |
|
3414 |
This somewhat clumsy implementation hides the OS's date representation |
|
3415 |
(i.e. makes this class independent of what the OS starts its time values with). |
|
3416 |
Don't use this method, the osTime representation is totally unportable." |
|
3417 |
||
3418 |
|v| |
|
3419 |
||
3420 |
v := OperatingSystem computeUTCTimeAndDateFrom:osTime. |
|
3421 |
dateEncoding := self class encodeYear:v year month:v month day:v day |
|
3422 |
||
3423 |
"Modified: 1.7.1996 / 15:23:12 / cg" |
|
3424 |
! |
|
3425 |
||
11593
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3426 |
getMilliseconds |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3427 |
"compatibility with Timestamp for comparing" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3428 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3429 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3430 |
((Timestamp epoch addDays:365) asDate asDays - 365) -> 25202 |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3431 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3432 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3433 |
^ 1000 * 60*60*24 * (self asDays - 25202) |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3434 |
|
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3435 |
" |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3436 |
Date today asTimestamp getMilliseconds |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3437 |
- |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3438 |
Date today getMilliseconds |
4d5d359f2008
Allow for comparisons with TimeStamp
Stefan Vogel <sv@exept.de>
parents:
11553
diff
changeset
|
3439 |
" |
699 | 3440 |
! ! |
3441 |
||
11176 | 3442 |
!Date methodsFor:'visiting'! |
3443 |
||
3444 |
acceptVisitor:aVisitor with:aParameter |
|
16725 | 3445 |
"dispatch for visitor pattern; send #visitDate:with: to aVisitor" |
11176 | 3446 |
|
3447 |
^ aVisitor visitDate:self with:aParameter |
|
3448 |
! ! |
|
3449 |
||
2706
878723bc99fc
added #shortPrintString for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1701
diff
changeset
|
3450 |
!Date class methodsFor:'documentation'! |
699 | 3451 |
|
3452 |
version |
|
17053 | 3453 |
^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.159 2014-11-13 20:39:20 cg Exp $' |
12097 | 3454 |
! |
3455 |
||
3456 |
version_CVS |
|
17053 | 3457 |
^ '$Header: /cvs/stx/stx/libbasic/Date.st,v 1.159 2014-11-13 20:39:20 cg Exp $' |
699 | 3458 |
! ! |
6795
519894240d97
more printFormats: yearOrDate (as in unix); dayPadded and monthPadded
penk
parents:
6624
diff
changeset
|
3459 |
|
14714 | 3460 |
|
699 | 3461 |
Date initialize! |