Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSTimeZone.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSTimeZone; | 14 module dwt.internal.cocoa.NSTimeZone; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSArray; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSData; | |
19 import dwt.internal.cocoa.NSDate; | |
20 import dwt.internal.cocoa.NSDictionary; | |
21 import dwt.internal.cocoa.NSInteger; | |
22 import dwt.internal.cocoa.NSLocale; | |
23 import dwt.internal.cocoa.NSObject; | 18 import dwt.internal.cocoa.NSObject; |
24 import dwt.internal.cocoa.NSString; | |
25 import dwt.internal.cocoa.OS; | 19 import dwt.internal.cocoa.OS; |
26 import objc = dwt.internal.objc.runtime; | 20 import objc = dwt.internal.objc.runtime; |
27 | 21 |
28 enum NSTimeZoneNameStyle : NSInteger | 22 public class NSTimeZone : NSObject { |
29 { | 23 |
30 NSTimeZoneNameStyleStandard, | 24 public this() { |
31 NSTimeZoneNameStyleShortStandard, | 25 super(); |
32 NSTimeZoneNameStyleDaylightSaving, | |
33 NSTimeZoneNameStyleShortDaylightSaving | |
34 } | 26 } |
35 | 27 |
36 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleStandard NSTimeZoneNameStyleStandard; | 28 public this(objc.id id) { |
37 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortStandard NSTimeZoneNameStyleShortStandard; | 29 super(id); |
38 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleDaylightSaving NSTimeZoneNameStyleDaylightSaving; | 30 } |
39 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortDaylightSaving NSTimeZoneNameStyleShortDaylightSaving; | |
40 | 31 |
41 public class NSTimeZone : NSObject | 32 public this(cocoa.id id) { |
42 { | 33 super(id); |
34 } | |
43 | 35 |
44 public this () | 36 public static NSTimeZone defaultTimeZone() { |
45 { | 37 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_defaultTimeZone); |
46 super(); | 38 return result !is null ? new NSTimeZone(result) : null; |
47 } | 39 } |
48 | |
49 public this (objc.id id) | |
50 { | |
51 super(id); | |
52 } | |
53 | |
54 public NSString abbreviation () | |
55 { | |
56 objc.id result = OS.objc_msgSend(this.id_, OS.sel_abbreviation); | |
57 return result !is null ? new NSString(result) : null; | |
58 } | |
59 | |
60 public static NSDictionary abbreviationDictionary () | |
61 { | |
62 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_abbreviationDictionary); | |
63 return result !is null ? new NSDictionary(result) : null; | |
64 } | |
65 | |
66 public NSString abbreviationForDate (NSDate aDate) | |
67 { | |
68 objc.id result = OS.objc_msgSend(this.id_, OS.sel_abbreviationForDate_1, aDate !is null ? aDate.id_ : null); | |
69 return result !is null ? new NSString(result) : null; | |
70 } | |
71 | |
72 public NSData data () | |
73 { | |
74 objc.id result = OS.objc_msgSend(this.id_, OS.sel_data); | |
75 return result !is null ? new NSData(result) : null; | |
76 } | |
77 | |
78 public NSTimeInterval daylightSavingTimeOffset () | |
79 { | |
80 return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id_, OS.sel_daylightSavingTimeOffset); | |
81 } | |
82 | |
83 public NSTimeInterval daylightSavingTimeOffsetForDate (NSDate aDate) | |
84 { | |
85 return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id_, OS.sel_daylightSavingTimeOffsetForDate_1, aDate !is null ? aDate.id_ : null); | |
86 } | |
87 | |
88 public static NSTimeZone defaultTimeZone () | |
89 { | |
90 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_defaultTimeZone); | |
91 return result !is null ? new NSTimeZone(result) : null; | |
92 } | |
93 | |
94 public NSString description () | |
95 { | |
96 objc.id result = OS.objc_msgSend(this.id_, OS.sel_description); | |
97 return result !is null ? new NSString(result) : null; | |
98 } | |
99 | |
100 public id initWithName_ (NSString tzName) | |
101 { | |
102 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithName_1, tzName !is null ? tzName.id_ : null); | |
103 return result !is null ? new id(result) : null; | |
104 } | |
105 | |
106 public id initWithName_data_ (NSString tzName, NSData aData) | |
107 { | |
108 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithName_1data_1, tzName !is null ? tzName.id_ : null, aData !is null ? aData.id_ : null); | |
109 return result !is null ? new id(result) : null; | |
110 } | |
111 | |
112 public bool isDaylightSavingTime () | |
113 { | |
114 return OS.objc_msgSend(this.id_, OS.sel_isDaylightSavingTime) !is null; | |
115 } | |
116 | |
117 public bool isDaylightSavingTimeForDate (NSDate aDate) | |
118 { | |
119 return OS.objc_msgSend(this.id_, OS.sel_isDaylightSavingTimeForDate_1, aDate !is null ? aDate.id_ : null) !is null; | |
120 } | |
121 | |
122 public bool isEqualToTimeZone (NSTimeZone aTimeZone) | |
123 { | |
124 return OS.objc_msgSend(this.id_, OS.sel_isEqualToTimeZone_1, aTimeZone !is null ? aTimeZone.id_ : null) !is null; | |
125 } | |
126 | |
127 public static NSArray knownTimeZoneNames () | |
128 { | |
129 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_knownTimeZoneNames); | |
130 return result !is null ? new NSArray(result) : null; | |
131 } | |
132 | |
133 public static NSTimeZone localTimeZone () | |
134 { | |
135 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_localTimeZone); | |
136 return result !is null ? new NSTimeZone(result) : null; | |
137 } | |
138 | |
139 public NSString localizedName (NSTimeZoneNameStyle style, NSLocale locale) | |
140 { | |
141 objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedName_1locale_1, style, locale !is null ? locale.id_ : null); | |
142 return result !is null ? new NSString(result) : null; | |
143 } | |
144 | |
145 public NSString name () | |
146 { | |
147 objc.id result = OS.objc_msgSend(this.id_, OS.sel_name); | |
148 return result !is null ? new NSString(result) : null; | |
149 } | |
150 | |
151 public NSDate nextDaylightSavingTimeTransition () | |
152 { | |
153 objc.id result = OS.objc_msgSend(this.id_, OS.sel_nextDaylightSavingTimeTransition); | |
154 return result !is null ? new NSDate(result) : null; | |
155 } | |
156 | |
157 public NSDate nextDaylightSavingTimeTransitionAfterDate (NSDate aDate) | |
158 { | |
159 objc.id result = OS.objc_msgSend(this.id_, OS.sel_nextDaylightSavingTimeTransitionAfterDate_1, aDate !is null ? aDate.id_ : null); | |
160 return result !is null ? new NSDate(result) : null; | |
161 } | |
162 | |
163 public static void resetSystemTimeZone () | |
164 { | |
165 OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_resetSystemTimeZone); | |
166 } | |
167 | |
168 public NSInteger secondsFromGMT () | |
169 { | |
170 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_secondsFromGMT); | |
171 } | |
172 | |
173 public NSInteger secondsFromGMTForDate (NSDate aDate) | |
174 { | |
175 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_secondsFromGMTForDate_1, aDate !is null ? aDate.id_ : null); | |
176 } | |
177 | |
178 public static void setDefaultTimeZone (NSTimeZone aTimeZone) | |
179 { | |
180 OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_setDefaultTimeZone_1, aTimeZone !is null ? aTimeZone.id_ : null); | |
181 } | |
182 | |
183 public static NSTimeZone systemTimeZone () | |
184 { | |
185 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_systemTimeZone); | |
186 return result !is null ? new NSTimeZone(result) : null; | |
187 } | |
188 | |
189 public static id timeZoneForSecondsFromGMT (NSInteger seconds) | |
190 { | |
191 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneForSecondsFromGMT_1, seconds); | |
192 return result !is null ? new id(result) : null; | |
193 } | |
194 | |
195 public static id timeZoneWithAbbreviation (NSString abbreviation) | |
196 { | |
197 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithAbbreviation_1, abbreviation !is null ? abbreviation.id_ : null); | |
198 return result !is null ? new id(result) : null; | |
199 } | |
200 | |
201 public static id static_timeZoneWithName_ (NSString tzName) | |
202 { | |
203 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1, tzName !is null ? tzName.id_ : null); | |
204 return result !is null ? new id(result) : null; | |
205 } | |
206 | |
207 public static id static_timeZoneWithName_data_ (NSString tzName, NSData aData) | |
208 { | |
209 objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1data_1, tzName !is null ? tzName.id_ : null, | |
210 aData !is null ? aData.id_ : null); | |
211 return result !is null ? new id(result) : null; | |
212 } | |
213 | 40 |
214 } | 41 } |