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.NSDate;
|
|
8
|
|
9 import dstep.foundation.NSObject;
|
|
10 import dstep.foundation.NSString;
|
|
11 import dstep.objc.bridge.Bridge;
|
|
12 import dstep.objc.objc : id;
|
|
13
|
|
14 alias double NSTimeInterval;
|
|
15
|
|
16 class NSDate : NSObject, INSCopying, INSCoding
|
|
17 {
|
|
18 mixin ObjcWrap;
|
|
19 mixin TNSExtendedDate;
|
|
20 mixin TNSDateCreation;
|
|
21 mixin TNSNaturalLangage;
|
|
22 mixin TNSCalendarDateExtras;
|
|
23
|
|
24 double timeIntervalSinceReferenceDate ()
|
|
25 {
|
|
26 return invokeObjcSelf!(double, "timeIntervalSinceReferenceDate");
|
|
27 }
|
|
28
|
|
29 Object copyWithZone (NSZone* zone)
|
|
30 {
|
|
31 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
32 }
|
|
33
|
|
34 void encodeWithCoder (NSCoder aCoder)
|
|
35 {
|
|
36 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
37 }
|
|
38
|
|
39 Object initWithCoder (NSCoder aDecoder)
|
|
40 {
|
|
41 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
42 }
|
|
43
|
|
44 this (NSCoder aDecoder)
|
|
45 {
|
|
46 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
47 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
48
|
|
49 if (result)
|
|
50 objcObject = ret;
|
|
51
|
|
52 dObject = this;
|
|
53 }
|
|
54 }
|
|
55
|
|
56 template TNSExtendedDate ()
|
|
57 {
|
|
58 double timeIntervalSinceDate (NSDate anotherDate)
|
|
59 {
|
|
60 return invokeObjcSelf!(double, "timeIntervalSinceDate:", NSDate)(anotherDate);
|
|
61 }
|
|
62
|
|
63 double timeIntervalSinceNow ()
|
|
64 {
|
|
65 return invokeObjcSelf!(double, "timeIntervalSinceNow");
|
|
66 }
|
|
67
|
|
68 double timeIntervalSince1970 ()
|
|
69 {
|
|
70 return invokeObjcSelf!(double, "timeIntervalSince1970");
|
|
71 }
|
|
72
|
|
73 Object addTimeInterval (double seconds)
|
|
74 {
|
|
75 return invokeObjcSelf!(Object, "addTimeInterval:", double)(seconds);
|
|
76 }
|
|
77
|
|
78 NSDate earlierDate (NSDate anotherDate)
|
|
79 {
|
|
80 return invokeObjcSelf!(NSDate, "earlierDate:", NSDate)(anotherDate);
|
|
81 }
|
|
82
|
|
83 NSDate laterDate (NSDate anotherDate)
|
|
84 {
|
|
85 return invokeObjcSelf!(NSDate, "laterDate:", NSDate)(anotherDate);
|
|
86 }
|
|
87
|
|
88 int compare (NSDate other)
|
|
89 {
|
|
90 return invokeObjcSelf!(int, "compare:", NSDate)(other);
|
|
91 }
|
|
92
|
|
93 NSString description ()
|
|
94 {
|
|
95 return invokeObjcSelf!(NSString, "description");
|
|
96 }
|
|
97
|
|
98 bool isEqualToDate (NSDate otherDate)
|
|
99 {
|
|
100 return invokeObjcSelf!(bool, "isEqualToDate:", NSDate)(otherDate);
|
|
101 }
|
|
102
|
|
103 static double timeIntervalSinceReferenceDate ()
|
|
104 {
|
|
105 return invokeObjcSelfClass!(double, "timeIntervalSinceReferenceDate");
|
|
106 }
|
|
107 }
|
|
108
|
|
109 template TNSDateCreation ()
|
|
110 {
|
|
111 static Object date ()
|
|
112 {
|
|
113 return invokeObjcSelfClass!(Object, "date");
|
|
114 }
|
|
115
|
|
116 static Object dateWithTimeIntervalSinceNow (double secs)
|
|
117 {
|
|
118 return invokeObjcSelfClass!(Object, "dateWithTimeIntervalSinceNow:", double)(secs);
|
|
119 }
|
|
120
|
|
121 static Object dateWithTimeIntervalSinceReferenceDate (double secs)
|
|
122 {
|
|
123 return invokeObjcSelfClass!(Object, "dateWithTimeIntervalSinceReferenceDate:", double)(secs);
|
|
124 }
|
|
125
|
|
126 static Object dateWithTimeIntervalSince1970 (double secs)
|
|
127 {
|
|
128 return invokeObjcSelfClass!(Object, "dateWithTimeIntervalSince1970:", double)(secs);
|
|
129 }
|
|
130
|
|
131 static Object distantFuture ()
|
|
132 {
|
|
133 return invokeObjcSelfClass!(Object, "distantFuture");
|
|
134 }
|
|
135
|
|
136 static Object distantPast ()
|
|
137 {
|
|
138 return invokeObjcSelfClass!(Object, "distantPast");
|
|
139 }
|
|
140
|
|
141 Object init ()
|
|
142 {
|
|
143 return invokeObjcSelf!(Object, "init");
|
|
144 }
|
|
145
|
|
146 this ()
|
|
147 {
|
|
148 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
149 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject);
|
|
150
|
|
151 if (result)
|
|
152 objcObject = ret;
|
|
153
|
|
154 dObject = this;
|
|
155 }
|
|
156
|
|
157 Object initWithTimeIntervalSinceReferenceDate (double secsToBeAdded)
|
|
158 {
|
|
159 return invokeObjcSelf!(Object, "initWithTimeIntervalSinceReferenceDate:", double)(secsToBeAdded);
|
|
160 }
|
|
161
|
|
162 this (double secsToBeAdded)
|
|
163 {
|
|
164 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
165 id result = Bridge.invokeObjcMethod!(id, "initWithTimeIntervalSinceReferenceDate:", double)(objcObject, secsToBeAdded);
|
|
166
|
|
167 if (result)
|
|
168 objcObject = ret;
|
|
169
|
|
170 dObject = this;
|
|
171 }
|
|
172
|
|
173 Object initWithTimeInterval (double secsToBeAdded, NSDate anotherDate)
|
|
174 {
|
|
175 return invokeObjcSelf!(Object, "initWithTimeInterval:sinceDate:", double, NSDate)(secsToBeAdded, anotherDate);
|
|
176 }
|
|
177
|
|
178 this (double secsToBeAdded, NSDate anotherDate)
|
|
179 {
|
|
180 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
181 id result = Bridge.invokeObjcMethod!(id, "initWithTimeInterval:sinceDate:", double, NSDate)(objcObject, secsToBeAdded, anotherDate);
|
|
182
|
|
183 if (result)
|
|
184 objcObject = ret;
|
|
185
|
|
186 dObject = this;
|
|
187 }
|
|
188
|
|
189 Object initWithTimeIntervalSinceNow (double secsToBeAddedToNow)
|
|
190 {
|
|
191 return invokeObjcSelf!(Object, "initWithTimeIntervalSinceNow:", double)(secsToBeAddedToNow);
|
|
192 }
|
|
193
|
|
194 this (double secsToBeAddedToNow)
|
|
195 {
|
|
196 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
197 id result = Bridge.invokeObjcMethod!(id, "initWithTimeIntervalSinceNow:", double)(objcObject, secsToBeAddedToNow);
|
|
198
|
|
199 if (result)
|
|
200 objcObject = ret;
|
|
201
|
|
202 dObject = this;
|
|
203 }
|
|
204 }
|
|
205
|