Mercurial > projects > dstep
comparison dstep/foundation/NSCalendarDate.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 7ff919f595d5 |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
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; | |
11 import dstep.foundation.NSString; | |
12 import dstep.foundation.NSTimeZone; | |
13 import dstep.objc.bridge.Bridge; | |
14 import dstep.objc.objc : id; | |
15 | |
16 class NSCalendarDate : NSDate | |
17 { | |
18 mixin ObjcWrap; | |
19 | |
20 static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
21 { | |
22 return invokeObjcSelfClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); | |
23 } | |
24 | |
25 static Object dateWithString (NSString description, NSString format) | |
26 { | |
27 return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format); | |
28 } | |
29 | |
30 static Object dateWithString (NSString description, NSString format, Object locale) | |
31 { | |
32 return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); | |
33 } | |
34 | |
35 static Object calendarDate () | |
36 { | |
37 return invokeObjcSelfClass!(Object, "calendarDate"); | |
38 } | |
39 | |
40 Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
41 { | |
42 return invokeObjcSelf!(Object, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone); | |
43 } | |
44 | |
45 this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) | |
46 { | |
47 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
48 id result = Bridge.invokeObjcMethod!(id, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(objcObject, year, month, day, hour, minute, second, aTimeZone); | |
49 | |
50 if (result) | |
51 objcObject = ret; | |
52 | |
53 dObject = this; | |
54 } | |
55 | |
56 Object initWithString (NSString description) | |
57 { | |
58 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | |
59 } | |
60 | |
61 this (NSString description) | |
62 { | |
63 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
64 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description); | |
65 | |
66 if (result) | |
67 objcObject = ret; | |
68 | |
69 dObject = this; | |
70 } | |
71 | |
72 Object initWithString (NSString description, NSString format) | |
73 { | |
74 return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format); | |
75 } | |
76 | |
77 this (NSString description, NSString format) | |
78 { | |
79 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
80 id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:", NSString, NSString)(objcObject, description, format); | |
81 | |
82 if (result) | |
83 objcObject = ret; | |
84 | |
85 dObject = this; | |
86 } | |
87 | |
88 Object initWithString (NSString description, NSString format, Object locale) | |
89 { | |
90 return invokeObjcSelf!(Object, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale); | |
91 } | |
92 | |
93 this (NSString description, NSString format, Object locale) | |
94 { | |
95 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
96 id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(objcObject, description, format, locale); | |
97 | |
98 if (result) | |
99 objcObject = ret; | |
100 | |
101 dObject = this; | |
102 } | |
103 | |
104 NSTimeZone timeZone () | |
105 { | |
106 return invokeObjcSelf!(NSTimeZone, "timeZone"); | |
107 } | |
108 | |
109 void setTimeZone (NSTimeZone aTimeZone) | |
110 { | |
111 return invokeObjcSelf!(void, "setTimeZone:", NSTimeZone)(aTimeZone); | |
112 } | |
113 | |
114 NSString calendarFormat () | |
115 { | |
116 return invokeObjcSelf!(NSString, "calendarFormat"); | |
117 } | |
118 | |
119 void setCalendarFormat (NSString format) | |
120 { | |
121 return invokeObjcSelf!(void, "setCalendarFormat:", NSString)(format); | |
122 } | |
123 | |
124 NSInteger yearOfCommonEra () | |
125 { | |
126 return invokeObjcSelf!(NSInteger, "yearOfCommonEra"); | |
127 } | |
128 | |
129 NSInteger monthOfYear () | |
130 { | |
131 return invokeObjcSelf!(NSInteger, "monthOfYear"); | |
132 } | |
133 | |
134 NSInteger dayOfMonth () | |
135 { | |
136 return invokeObjcSelf!(NSInteger, "dayOfMonth"); | |
137 } | |
138 | |
139 NSInteger dayOfWeek () | |
140 { | |
141 return invokeObjcSelf!(NSInteger, "dayOfWeek"); | |
142 } | |
143 | |
144 NSInteger dayOfYear () | |
145 { | |
146 return invokeObjcSelf!(NSInteger, "dayOfYear"); | |
147 } | |
148 | |
149 NSInteger dayOfCommonEra () | |
150 { | |
151 return invokeObjcSelf!(NSInteger, "dayOfCommonEra"); | |
152 } | |
153 | |
154 NSInteger hourOfDay () | |
155 { | |
156 return invokeObjcSelf!(NSInteger, "hourOfDay"); | |
157 } | |
158 | |
159 NSInteger minuteOfHour () | |
160 { | |
161 return invokeObjcSelf!(NSInteger, "minuteOfHour"); | |
162 } | |
163 | |
164 NSInteger secondOfMinute () | |
165 { | |
166 return invokeObjcSelf!(NSInteger, "secondOfMinute"); | |
167 } | |
168 | |
169 NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) | |
170 { | |
171 id result = invokeObjcSelf!(id, "dateByAddingYears:months:days:hours:minutes:seconds:", NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger)(year, month, day, hour, minute, secondreturn result is this.objcObject ? this : (result !is null ? new NSCalendarDate(result) : null); } | |
172 | |
173 void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date) | |
174 { | |
175 return invokeObjcSelf!(void, "years:months:days:hours:minutes:seconds:sinceDate:", NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSCalendarDate)(yp, mop, dp, hp, mip, sp, date); | |
176 } | |
177 | |
178 NSString description () | |
179 { | |
180 return invokeObjcSelf!(NSString, "description"); | |
181 } | |
182 | |
183 NSString descriptionWithLocale (Object locale) | |
184 { | |
185 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
186 } | |
187 | |
188 NSString descriptionWithCalendarFormat (NSString format) | |
189 { | |
190 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:", NSString)(format); | |
191 } | |
192 | |
193 NSString descriptionWithCalendarFormat (NSString format, Object locale) | |
194 { | |
195 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale); | |
196 } | |
197 } | |
198 | |
199 template TNSNaturalLangage () | |
200 { | |
201 static Object dateWithNaturalLanguageString (NSString string) | |
202 { | |
203 return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:", NSString)(string); | |
204 } | |
205 | |
206 static Object dateWithNaturalLanguageString (NSString string, Object locale) | |
207 { | |
208 return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale); | |
209 } | |
210 } | |
211 | |
212 template TNSCalendarDateExtras () | |
213 { | |
214 static Object dateWithString (NSString aString) | |
215 { | |
216 return invokeObjcSelfClass!(Object, "dateWithString:", NSString)(aString); | |
217 } | |
218 | |
219 Object initWithString (NSString description) | |
220 { | |
221 return invokeObjcSelf!(Object, "initWithString:", NSString)(description); | |
222 } | |
223 | |
224 this (NSString description) | |
225 { | |
226 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
227 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description); | |
228 | |
229 if (result) | |
230 objcObject = ret; | |
231 | |
232 dObject = this; | |
233 } | |
234 | |
235 NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone) | |
236 { | |
237 return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone); | |
238 } | |
239 | |
240 NSString descriptionWithLocale (Object locale) | |
241 { | |
242 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
243 } | |
244 | |
245 NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale) | |
246 { | |
247 return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale); | |
248 } | |
249 } | |
250 |