comparison dwt/internal/cocoa/NSDate.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.NSDate;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSCalendarDate;
18 import dwt.internal.cocoa.NSObject;
19 import dwt.internal.cocoa.NSString;
20 import dwt.internal.cocoa.NSTimeZone;
21 import dwt.internal.cocoa.OS;
22 import objc = dwt.internal.objc.runtime;
23
24 alias double NSTimeInterval;
25
26 public class NSDate : NSObject
27 {
28 public this ()
29 {
30 super();
31 }
32
33 public this (objc.id id)
34 {
35 super(id);
36 }
37
38 public id addTimeInterval (double seconds)
39 {
40 objc.id result = OS.objc_msgSend(this.id, OS.sel_addTimeInterval_1, seconds);
41 return result !is null ? new id(result) : null;
42 }
43
44 public objc.id compare (NSDate other)
45 {
46 return OS.objc_msgSend(this.id, OS.sel_compare_1, other !is null ? other.id : null);
47 }
48
49 public static NSDate date ()
50 {
51 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_date);
52 return result !is null ? new NSDate(result) : null;
53 }
54
55 public NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone)
56 {
57 objc.id result = OS.objc_msgSend(this.id, OS.sel_dateWithCalendarFormat_1timeZone_1, format !is null ? format.id : null,
58 aTimeZone !is null ? aTimeZone.id : null);
59 return result !is null ? new NSCalendarDate(result) : null;
60 }
61
62 public static id static_dateWithNaturalLanguageString_ (NSString string)
63 {
64 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1, string !is null ? string.id : null);
65 return result !is null ? new id(result) : null;
66 }
67
68 public static id static_dateWithNaturalLanguageString_locale_ (NSString string, id locale)
69 {
70 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1locale_1, string !is null ? string.id : null,
71 locale !is null ? locale.id : null);
72 return result !is null ? new id(result) : null;
73 }
74
75 public static id dateWithString (NSString aString)
76 {
77 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithString_1, aString !is null ? aString.id : null);
78 return result !is null ? new id(result) : null;
79 }
80
81 public static id dateWithTimeIntervalSince1970 (double secs)
82 {
83 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSince1970_1, secs);
84 return result !is null ? new id(result) : null;
85 }
86
87 public static NSDate dateWithTimeIntervalSinceNow (double secs)
88 {
89 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceNow_1, secs);
90 return result !is null ? new NSDate(result) : null;
91 }
92
93 public static id dateWithTimeIntervalSinceReferenceDate (double secs)
94 {
95 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceReferenceDate_1, secs);
96 return result !is null ? new id(result) : null;
97 }
98
99 public NSString description ()
100 {
101 objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
102 return result !is null ? new NSString(result) : null;
103 }
104
105 public NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, id locale)
106 {
107 objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithCalendarFormat_1timeZone_1locale_1, format !is null ? format.id : null,
108 aTimeZone !is null ? aTimeZone.id : null, locale !is null ? locale.id : null);
109 return result !is null ? new NSString(result) : null;
110 }
111
112 public NSString descriptionWithLocale (id locale)
113 {
114 objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
115 return result !is null ? new NSString(result) : null;
116 }
117
118 public static NSDate distantFuture ()
119 {
120 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantFuture);
121 return result !is null ? new NSDate(result) : null;
122 }
123
124 public static NSDate distantPast ()
125 {
126 objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantPast);
127 return result !is null ? new NSDate(result) : null;
128 }
129
130 public NSDate earlierDate (NSDate anotherDate)
131 {
132 objc.id result = OS.objc_msgSend(this.id, OS.sel_earlierDate_1, anotherDate !is null ? anotherDate.id : null);
133 return result is this.id ? this : (result !is null ? new NSDate(result) : null);
134 }
135
136 public NSDate initWithString (NSString description)
137 {
138 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, description !is null ? description.id : null);
139 return result !is null ? this : null;
140 }
141
142 public NSDate initWithTimeInterval (double secsToBeAdded, NSDate anotherDate)
143 {
144 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeInterval_1sinceDate_1, secsToBeAdded,
145 anotherDate !is null ? anotherDate.id : null);
146 return result !is null ? this : null;
147 }
148
149 public NSDate initWithTimeIntervalSinceNow (double secsToBeAddedToNow)
150 {
151 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeIntervalSinceNow_1, secsToBeAddedToNow);
152 return result !is null ? this : null;
153 }
154
155 public NSDate initWithTimeIntervalSinceReferenceDate (double secsToBeAdded)
156 {
157 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeIntervalSinceReferenceDate_1, secsToBeAdded);
158 return result !is null ? this : null;
159 }
160
161 public bool isEqualToDate (NSDate otherDate)
162 {
163 return OS.objc_msgSend(this.id, OS.sel_isEqualToDate_1, otherDate !is null ? otherDate.id : null) !is null;
164 }
165
166 public NSDate laterDate (NSDate anotherDate)
167 {
168 objc.id result = OS.objc_msgSend(this.id, OS.sel_laterDate_1, anotherDate !is null ? anotherDate.id : null);
169 return result is this.id ? this : (result !is null ? new NSDate(result) : null);
170 }
171
172 public double timeIntervalSince1970 ()
173 {
174 return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSince1970);
175 }
176
177 public double timeIntervalSinceDate (NSDate anotherDate)
178 {
179 return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceDate_1, anotherDate !is null ? anotherDate.id : null);
180 }
181
182 public double timeIntervalSinceNow ()
183 {
184 return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceNow);
185 }
186
187 public static double static_timeIntervalSinceReferenceDate ()
188 {
189 return OS.objc_msgSend_fpret(OS.class_NSDate, OS.sel_timeIntervalSinceReferenceDate);
190 }
191
192 public double timeIntervalSinceReferenceDate ()
193 {
194 return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceReferenceDate);
195 }
196
197 }