Mercurial > projects > dstep
annotate dstep/foundation/NSCalendarDate.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 7ff919f595d5 |
children | b9de51448c6b |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSCalendarDate; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSDate; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
11 import dstep.foundation.NSObjCRuntime; |
14 | 12 import dstep.foundation.NSString; |
13 import dstep.foundation.NSTimeZone; | |
14 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
15 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
16 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
17 const TNSNaturalLangage = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
18 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
19 static Object dateWithNaturalLanguageString (NSString string) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
20 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
21 return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:", NSString)(string); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
22 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
23 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
24 static Object dateWithNaturalLanguageString (NSString string, Object locale) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
25 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
26 return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
27 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
28 `; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
29 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
30 const TNSCalendarDateExtras = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
31 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
32 static Object dateWithString (NSString aString) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
33 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
34 return invokeObjcSuperClass!(Object, "dateWithString:", NSString)(aString); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
35 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
36 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
37 Object initWithString (NSString description) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
41 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
42 this (NSString description) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
43 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
44 typeof(this).alloc.initWithString(description); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
45 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
46 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
47 NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 NSString descriptionWithLocale (Object locale) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
55 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
56 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
58 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
59 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
60 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
61 `; |
14 | 62 |
63 class NSCalendarDate : NSDate | |
64 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
65 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
66 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
67 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
68 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
69 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
70 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
71 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
72 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
73 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
74 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
75 } |
14 | 76 |
77 static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
78 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
79 return invokeObjcSuperClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); |
14 | 80 } |
81 | |
82 static Object dateWithString (NSString description, NSString format) | |
83 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
84 return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format); |
14 | 85 } |
86 | |
87 static Object dateWithString (NSString description, NSString format, Object locale) | |
88 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
89 return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); |
14 | 90 } |
91 | |
92 static Object calendarDate () | |
93 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
94 return invokeObjcSuperClass!(Object, "calendarDate"); |
14 | 95 } |
96 | |
97 Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
98 { | |
99 return invokeObjcSelf!(Object, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); | |
100 } | |
101 | |
102 this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
103 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
104 typeof(this).alloc.initWithYear(year, month, day, hour, minute, second, aTimeZone); |
14 | 105 } |
106 | |
107 Object initWithString (NSString description) | |
108 { | |
109 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | |
110 } | |
111 | |
112 this (NSString description) | |
113 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
114 typeof(this).alloc.initWithString(description); |
14 | 115 } |
116 | |
117 Object initWithString (NSString description, NSString format) | |
118 { | |
119 return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format); | |
120 } | |
121 | |
122 this (NSString description, NSString format) | |
123 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
124 typeof(this).alloc.initWithString(description, format); |
14 | 125 } |
126 | |
127 Object initWithString (NSString description, NSString format, Object locale) | |
128 { | |
129 return invokeObjcSelf!(Object, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); | |
130 } | |
131 | |
132 this (NSString description, NSString format, Object locale) | |
133 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
134 typeof(this).alloc.initWithString(description, format, locale); |
14 | 135 } |
136 | |
137 NSTimeZone timeZone () | |
138 { | |
139 return invokeObjcSelf!(NSTimeZone, "timeZone"); | |
140 } | |
141 | |
142 void setTimeZone (NSTimeZone aTimeZone) | |
143 { | |
144 return invokeObjcSelf!(void, "setTimeZone:", NSTimeZone)(aTimeZone); | |
145 } | |
146 | |
147 NSString calendarFormat () | |
148 { | |
149 return invokeObjcSelf!(NSString, "calendarFormat"); | |
150 } | |
151 | |
152 void setCalendarFormat (NSString format) | |
153 { | |
154 return invokeObjcSelf!(void, "setCalendarFormat:", NSString)(format); | |
155 } | |
156 | |
157 NSInteger yearOfCommonEra () | |
158 { | |
159 return invokeObjcSelf!(NSInteger, "yearOfCommonEra"); | |
160 } | |
161 | |
162 NSInteger monthOfYear () | |
163 { | |
164 return invokeObjcSelf!(NSInteger, "monthOfYear"); | |
165 } | |
166 | |
167 NSInteger dayOfMonth () | |
168 { | |
169 return invokeObjcSelf!(NSInteger, "dayOfMonth"); | |
170 } | |
171 | |
172 NSInteger dayOfWeek () | |
173 { | |
174 return invokeObjcSelf!(NSInteger, "dayOfWeek"); | |
175 } | |
176 | |
177 NSInteger dayOfYear () | |
178 { | |
179 return invokeObjcSelf!(NSInteger, "dayOfYear"); | |
180 } | |
181 | |
182 NSInteger dayOfCommonEra () | |
183 { | |
184 return invokeObjcSelf!(NSInteger, "dayOfCommonEra"); | |
185 } | |
186 | |
187 NSInteger hourOfDay () | |
188 { | |
189 return invokeObjcSelf!(NSInteger, "hourOfDay"); | |
190 } | |
191 | |
192 NSInteger minuteOfHour () | |
193 { | |
194 return invokeObjcSelf!(NSInteger, "minuteOfHour"); | |
195 } | |
196 | |
197 NSInteger secondOfMinute () | |
198 { | |
199 return invokeObjcSelf!(NSInteger, "secondOfMinute"); | |
200 } | |
201 | |
202 NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) | |
203 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
204 id result = invokeObjcSelf!(id, "dateByAddingYears:months:days:hours:minutes:seconds:", NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger)(year, month, day, hour, minute, second); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
205 return result is this.objcObject ? this : (result !is null ? new NSCalendarDate(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
206 } |
14 | 207 |
208 void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date) | |
209 { | |
210 return invokeObjcSelf!(void, "years:months:days:hours:minutes:seconds:sinceDate:", NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSCalendarDate)(yp, mop, dp, hp, mip, sp, date); | |
211 } | |
212 | |
213 NSString description () | |
214 { | |
215 return invokeObjcSelf!(NSString, "description"); | |
216 } | |
217 | |
218 NSString descriptionWithLocale (Object locale) | |
219 { | |
220 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
221 } | |
222 | |
223 NSString descriptionWithCalendarFormat (NSString format) | |
224 { | |
225 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:", NSString)(format); | |
226 } | |
227 | |
228 NSString descriptionWithCalendarFormat (NSString format, Object locale) | |
229 { | |
230 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale); | |
231 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
232 } |