comparison dwt/internal/cocoa/NSCalendarDate.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 62202ce0039f
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.NSCalendarDate; 14 module dwt.internal.cocoa.NSCalendarDate;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import cocoa = dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSDate; 18 import dwt.internal.cocoa.NSDate;
18 import dwt.internal.cocoa.NSInteger;
19 import dwt.internal.cocoa.NSString;
20 import dwt.internal.cocoa.NSTimeZone; 19 import dwt.internal.cocoa.NSTimeZone;
21 import dwt.internal.cocoa.OS; 20 import dwt.internal.cocoa.OS;
21 import dwt.internal.objc.cocoa.Cocoa;
22 import objc = dwt.internal.objc.runtime; 22 import objc = dwt.internal.objc.runtime;
23 23
24 public class NSCalendarDate : NSDate 24 public class NSCalendarDate : NSDate {
25 {
26 25
27 public this () 26 public this() {
28 { 27 super();
29 super(); 28 }
30 }
31 29
32 public this (objc.id id) 30 public this(objc.id id) {
33 { 31 super(id);
34 super(id); 32 }
35 }
36 33
37 public static NSCalendarDate calendarDate () 34 public this(cocoa.id id) {
38 { 35 super(id);
39 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_calendarDate); 36 }
40 return result !is null ? new NSCalendarDate(result) : null;
41 }
42 37
43 public NSString calendarFormat () 38 public static NSCalendarDate calendarDate() {
44 { 39 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_calendarDate);
45 objc.id result = OS.objc_msgSend(this.id_, OS.sel_calendarFormat); 40 return result !is null ? new NSCalendarDate(result) : null;
46 return result !is null ? new NSString(result) : null; 41 }
47 }
48 42
49 public NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) 43 public static NSCalendarDate dateWithYear(NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone) {
50 { 44 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithYear_month_day_hour_minute_second_timeZone_, year, month, day, hour, minute, second, aTimeZone !is null ? aTimeZone.id : null);
51 objc.id result = OS.objc_msgSend(this.id_, OS.sel_dateByAddingYears_1months_1days_1hours_1minutes_1seconds_1, year, month, day, hour, minute, 45 return result !is null ? new NSCalendarDate(result) : null;
52 second); 46 }
53 return result is this.id_ ? this : (result !is null ? new NSCalendarDate(result) : null);
54 }
55 47
56 public static id static_dateWithString_calendarFormat_ (NSString description, NSString format) 48 public NSInteger dayOfMonth() {
57 { 49 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_dayOfMonth);
58 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1, 50 }
59 description !is null ? description.id_ : null, format !is null ? format.id_ : null);
60 return result !is null ? new id(result) : null;
61 }
62 51
63 public static id static_dateWithString_calendarFormat_locale_ (NSString description, NSString format, id locale) 52 public NSInteger hourOfDay() {
64 { 53 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_hourOfDay);
65 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1locale_1, 54 }
66 description !is null ? description.id_ : null, format !is null ? format.id_ : null, locale !is null ? locale.id_ : null);
67 return result !is null ? new id(result) : null;
68 }
69 55
70 public static NSCalendarDate dateWithYear (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second, NSTimeZone aTimeZone) 56 public NSInteger minuteOfHour() {
71 { 57 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_minuteOfHour);
72 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month, 58 }
73 day, hour, minute, second, aTimeZone !is null ? aTimeZone.id_ : null);
74 return result !is null ? new NSCalendarDate(result) : null;
75 }
76 59
77 public NSInteger dayOfCommonEra () 60 public NSInteger monthOfYear() {
78 { 61 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_monthOfYear);
79 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfCommonEra); 62 }
80 }
81 63
82 public NSInteger dayOfMonth () 64 public NSInteger secondOfMinute() {
83 { 65 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondOfMinute);
84 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfMonth); 66 }
85 }
86 67
87 public NSInteger dayOfWeek () 68 public NSTimeZone timeZone() {
88 { 69 objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
89 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfWeek); 70 return result !is null ? new NSTimeZone(result) : null;
90 } 71 }
91 72
92 public NSInteger dayOfYear () 73 public int /*long*/yearOfCommonEra() {
93 { 74 return OS.objc_msgSend(this.id, OS.sel_yearOfCommonEra);
94 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_dayOfYear); 75 }
95 }
96 76
97 public NSString description () 77 public static NSDate dateWithTimeIntervalSinceNow(double secs) {
98 { 78 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithTimeIntervalSinceNow_, secs);
99 objc.id result = OS.objc_msgSend(this.id_, OS.sel_description); 79 return result !is null ? new NSCalendarDate(result) : null;
100 return result !is null ? new NSString(result) : null; 80 }
101 }
102 81
103 public NSString descriptionWithCalendarFormat_ (NSString format) 82 public static NSDate distantFuture() {
104 { 83 objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_distantFuture);
105 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithCalendarFormat_1, format !is null ? format.id_ : null); 84 return result !is null ? new NSCalendarDate(result) : null;
106 return result !is null ? new NSString(result) : null; 85 }
107 }
108
109 public NSString descriptionWithCalendarFormat_locale_ (NSString format, id locale)
110 {
111 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithCalendarFormat_1locale_1, format !is null ? format.id_ : null,
112 locale !is null ? locale.id_ : null);
113 return result !is null ? new NSString(result) : null;
114 }
115
116 public NSString descriptionWithLocale (id locale)
117 {
118 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null);
119 return result !is null ? new NSString(result) : null;
120 }
121
122 public NSInteger hourOfDay ()
123 {
124 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_hourOfDay);
125 }
126
127 public NSCalendarDate initWithString_ (NSString description)
128 {
129 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, description !is null ? description.id_ : null);
130 return result !is null ? this : null;
131 }
132
133 public NSCalendarDate initWithString_calendarFormat_ (NSString description, NSString format)
134 {
135 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1calendarFormat_1, description !is null ? description.id_ : null,
136 format !is null ? format.id_ : null);
137 return result !is null ? this : null;
138 }
139
140 public NSCalendarDate initWithString_calendarFormat_locale_ (NSString description, NSString format, id locale)
141 {
142 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1calendarFormat_1locale_1, description !is null ? description.id_ : null,
143 format !is null ? format.id_ : null, locale !is null ? locale.id_ : null);
144 return result !is null ? this : null;
145 }
146
147 public id initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
148 {
149 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month, day, hour, minute,
150 second, aTimeZone !is null ? aTimeZone.id_ : null);
151 return result !is null ? new id(result) : null;
152 }
153
154 public NSInteger minuteOfHour ()
155 {
156 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_minuteOfHour);
157 }
158
159 public NSInteger monthOfYear ()
160 {
161 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_monthOfYear);
162 }
163
164 public NSInteger secondOfMinute ()
165 {
166 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_secondOfMinute);
167 }
168
169 public void setCalendarFormat (NSString format)
170 {
171 OS.objc_msgSend(this.id_, OS.sel_setCalendarFormat_1, format !is null ? format.id_ : null);
172 }
173
174 public void setTimeZone (NSTimeZone aTimeZone)
175 {
176 OS.objc_msgSend(this.id_, OS.sel_setTimeZone_1, aTimeZone !is null ? aTimeZone.id_ : null);
177 }
178
179 public NSTimeZone timeZone ()
180 {
181 objc.id result = OS.objc_msgSend(this.id_, OS.sel_timeZone);
182 return result !is null ? new NSTimeZone(result) : null;
183 }
184
185 public NSInteger yearOfCommonEra ()
186 {
187 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_yearOfCommonEra);
188 }
189
190 public void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date)
191 {
192 OS.objc_msgSend(this.id_, OS.sel_years_1months_1days_1hours_1minutes_1seconds_1sinceDate_1, yp, mop, dp, hp, mip, sp,
193 date !is null ? date.id_ : null);
194 }
195 86
196 } 87 }