comparison dwt/internal/cocoa/NSTimeZone.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSTimeZone;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSArray;
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;
24 import dwt.internal.cocoa.NSString;
25 import dwt.internal.cocoa.OS;
26 import objc = dwt.internal.objc.runtime;
27
28 enum NSTimeZoneNameStyle : NSInteger
29 {
30 NSTimeZoneNameStyleStandard,
31 NSTimeZoneNameStyleShortStandard,
32 NSTimeZoneNameStyleDaylightSaving,
33 NSTimeZoneNameStyleShortDaylightSaving
34 }
35
36 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleStandard NSTimeZoneNameStyleStandard;
37 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortStandard NSTimeZoneNameStyleShortStandard;
38 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleDaylightSaving NSTimeZoneNameStyleDaylightSaving;
39 alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortDaylightSaving NSTimeZoneNameStyleShortDaylightSaving;
40
41 public class NSTimeZone : NSObject
42 {
43
44 public this ()
45 {
46 super();
47 }
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
214 }