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.NSTimeZone;
|
|
8
|
|
9 import dstep.foundation.NSArray;
|
|
10 import dstep.foundation.NSData;
|
|
11 import dstep.foundation.NSDate;
|
|
12 import dstep.foundation.NSDictionary;
|
|
13 import dstep.foundation.NSLocale;
|
|
14 import dstep.foundation.NSObject;
|
|
15 import dstep.foundation.NSString;
|
|
16 import dstep.objc.bridge.Bridge;
|
|
17 import dstep.objc.objc : id;
|
|
18
|
|
19 import bindings = dstep.foundation.NSTimeZone_bindings;
|
|
20
|
|
21 alias NSInteger NSTimeZoneNameStyle;
|
|
22
|
|
23 const NSString NSSystemTimeZoneDidChangeNotification;
|
|
24
|
|
25 enum
|
|
26 {
|
|
27 NSTimeZoneNameStyleStandard,
|
|
28 NSTimeZoneNameStyleShortStandard,
|
|
29 NSTimeZoneNameStyleDaylightSaving,
|
|
30 NSTimeZoneNameStyleShortDaylightSaving
|
|
31 }
|
|
32
|
|
33 static this ()
|
|
34 {
|
|
35 NSSystemTimeZoneDidChangeNotification = new NSString(bindings.NSSystemTimeZoneDidChangeNotification);
|
|
36 }
|
|
37
|
|
38 class NSTimeZone : NSObject, INSCopying, INSCoding
|
|
39 {
|
|
40 mixin ObjcWrap;
|
|
41 mixin TNSExtendedTimeZone;
|
|
42 mixin TNSTimeZoneCreation;
|
|
43
|
|
44 NSString name ()
|
|
45 {
|
|
46 return invokeObjcSelf!(NSString, "name");
|
|
47 }
|
|
48
|
|
49 NSData data ()
|
|
50 {
|
|
51 return invokeObjcSelf!(NSData, "data");
|
|
52 }
|
|
53
|
|
54 NSInteger secondsFromGMTForDate (NSDate aDate)
|
|
55 {
|
|
56 return invokeObjcSelf!(NSInteger, "secondsFromGMTForDate:", NSDate)(aDate);
|
|
57 }
|
|
58
|
|
59 NSString abbreviationForDate (NSDate aDate)
|
|
60 {
|
|
61 return invokeObjcSelf!(NSString, "abbreviationForDate:", NSDate)(aDate);
|
|
62 }
|
|
63
|
|
64 bool isDaylightSavingTimeForDate (NSDate aDate)
|
|
65 {
|
|
66 return invokeObjcSelf!(bool, "isDaylightSavingTimeForDate:", NSDate)(aDate);
|
|
67 }
|
|
68
|
|
69 double daylightSavingTimeOffsetForDate (NSDate aDate)
|
|
70 {
|
|
71 return invokeObjcSelf!(double, "daylightSavingTimeOffsetForDate:", NSDate)(aDate);
|
|
72 }
|
|
73
|
|
74 NSDate nextDaylightSavingTimeTransitionAfterDate (NSDate aDate)
|
|
75 {
|
|
76 return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransitionAfterDate:", NSDate)(aDate);
|
|
77 }
|
|
78
|
|
79 Object copyWithZone (NSZone* zone)
|
|
80 {
|
|
81 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
82 }
|
|
83
|
|
84 void encodeWithCoder (NSCoder aCoder)
|
|
85 {
|
|
86 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
87 }
|
|
88
|
|
89 Object initWithCoder (NSCoder aDecoder)
|
|
90 {
|
|
91 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
92 }
|
|
93
|
|
94 this (NSCoder aDecoder)
|
|
95 {
|
|
96 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
97 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
98
|
|
99 if (result)
|
|
100 objcObject = ret;
|
|
101
|
|
102 dObject = this;
|
|
103 }
|
|
104 }
|
|
105
|
|
106 template TNSExtendedTimeZone ()
|
|
107 {
|
|
108 static NSTimeZone systemTimeZone ()
|
|
109 {
|
|
110 return invokeObjcSelfClass!(NSTimeZone, "systemTimeZone");
|
|
111 }
|
|
112
|
|
113 static void resetSystemTimeZone ()
|
|
114 {
|
|
115 return invokeObjcSelfClass!(void, "resetSystemTimeZone");
|
|
116 }
|
|
117
|
|
118 static NSTimeZone defaultTimeZone ()
|
|
119 {
|
|
120 return invokeObjcSelfClass!(NSTimeZone, "defaultTimeZone");
|
|
121 }
|
|
122
|
|
123 static void setDefaultTimeZone (NSTimeZone aTimeZone)
|
|
124 {
|
|
125 return invokeObjcSelfClass!(void, "setDefaultTimeZone:", NSTimeZone)(aTimeZone);
|
|
126 }
|
|
127
|
|
128 static NSTimeZone localTimeZone ()
|
|
129 {
|
|
130 return invokeObjcSelfClass!(NSTimeZone, "localTimeZone");
|
|
131 }
|
|
132
|
|
133 static NSArray knownTimeZoneNames ()
|
|
134 {
|
|
135 return invokeObjcSelfClass!(NSArray, "knownTimeZoneNames");
|
|
136 }
|
|
137
|
|
138 static NSDictionary abbreviationDictionary ()
|
|
139 {
|
|
140 return invokeObjcSelfClass!(NSDictionary, "abbreviationDictionary");
|
|
141 }
|
|
142
|
|
143 NSInteger secondsFromGMT ()
|
|
144 {
|
|
145 return invokeObjcSelf!(NSInteger, "secondsFromGMT");
|
|
146 }
|
|
147
|
|
148 NSString abbreviation ()
|
|
149 {
|
|
150 return invokeObjcSelf!(NSString, "abbreviation");
|
|
151 }
|
|
152
|
|
153 bool isDaylightSavingTime ()
|
|
154 {
|
|
155 return invokeObjcSelf!(bool, "isDaylightSavingTime");
|
|
156 }
|
|
157
|
|
158 double daylightSavingTimeOffset ()
|
|
159 {
|
|
160 return invokeObjcSelf!(double, "daylightSavingTimeOffset");
|
|
161 }
|
|
162
|
|
163 NSDate nextDaylightSavingTimeTransition ()
|
|
164 {
|
|
165 return invokeObjcSelf!(NSDate, "nextDaylightSavingTimeTransition");
|
|
166 }
|
|
167
|
|
168 NSString description ()
|
|
169 {
|
|
170 return invokeObjcSelf!(NSString, "description");
|
|
171 }
|
|
172
|
|
173 bool isEqualToTimeZone (NSTimeZone aTimeZone)
|
|
174 {
|
|
175 return invokeObjcSelf!(bool, "isEqualToTimeZone:", NSTimeZone)(aTimeZone);
|
|
176 }
|
|
177
|
|
178 NSString localizedName (int style, NSLocale locale)
|
|
179 {
|
|
180 return invokeObjcSelf!(NSString, "localizedName:locale:", int, NSLocale)(style, locale);
|
|
181 }
|
|
182 }
|
|
183
|
|
184 template TNSTimeZoneCreation ()
|
|
185 {
|
|
186 static Object timeZoneWithName (NSString tzName)
|
|
187 {
|
|
188 return invokeObjcSelfClass!(Object, "timeZoneWithName:", NSString)(tzName);
|
|
189 }
|
|
190
|
|
191 static Object timeZoneWithName (NSString tzName, NSData aData)
|
|
192 {
|
|
193 return invokeObjcSelfClass!(Object, "timeZoneWithName:data:", NSString, NSData)(tzName, aData);
|
|
194 }
|
|
195
|
|
196 Object initWithName (NSString tzName)
|
|
197 {
|
|
198 return invokeObjcSelf!(Object, "initWithName:", NSString)(tzName);
|
|
199 }
|
|
200
|
|
201 this (NSString tzName)
|
|
202 {
|
|
203 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
204 id result = Bridge.invokeObjcMethod!(id, "initWithName:", NSString)(objcObject, tzName);
|
|
205
|
|
206 if (result)
|
|
207 objcObject = ret;
|
|
208
|
|
209 dObject = this;
|
|
210 }
|
|
211
|
|
212 Object initWithName (NSString tzName, NSData aData)
|
|
213 {
|
|
214 return invokeObjcSelf!(Object, "initWithName:data:", NSString, NSData)(tzName, aData);
|
|
215 }
|
|
216
|
|
217 this (NSString tzName, NSData aData)
|
|
218 {
|
|
219 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
220 id result = Bridge.invokeObjcMethod!(id, "initWithName:data:", NSString, NSData)(objcObject, tzName, aData);
|
|
221
|
|
222 if (result)
|
|
223 objcObject = ret;
|
|
224
|
|
225 dObject = this;
|
|
226 }
|
|
227
|
|
228 static Object timeZoneForSecondsFromGMT (NSInteger seconds)
|
|
229 {
|
|
230 return invokeObjcSelfClass!(Object, "timeZoneForSecondsFromGMT:", NSInteger)(seconds);
|
|
231 }
|
|
232
|
|
233 static Object timeZoneWithAbbreviation (NSString abbreviation)
|
|
234 {
|
|
235 return invokeObjcSelfClass!(Object, "timeZoneWithAbbreviation:", NSString)(abbreviation);
|
|
236 }
|
|
237 }
|
|
238
|