Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSCalendar.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.NSCalendar; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSDate; | |
18 import dwt.internal.cocoa.NSDateComponents; | |
19 import dwt.internal.cocoa.NSLocale; | |
20 import dwt.internal.cocoa.NSObject; | |
21 import dwt.internal.cocoa.NSInteger; | |
22 import dwt.internal.cocoa.NSRange; | |
23 import dwt.internal.cocoa.NSString; | |
24 import dwt.internal.cocoa.NSTimeZone; | |
25 import dwt.internal.cocoa.OS; | |
26 import objc = dwt.internal.objc.runtime; | |
27 | |
28 public class NSCalendar : NSObject | |
29 { | |
30 | |
31 public this () | |
32 { | |
33 super(); | |
34 } | |
35 | |
36 public this (objc.id id) | |
37 { | |
38 super(id); | |
39 } | |
40 | |
41 public static id autoupdatingCurrentCalendar () | |
42 { | |
43 objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_autoupdatingCurrentCalendar); | |
44 return result !is null ? new id(result) : null; | |
45 } | |
46 | |
47 public NSString calendarIdentifier () | |
48 { | |
49 objc.id result = OS.objc_msgSend(this.id, OS.sel_calendarIdentifier); | |
50 return result !is null ? new NSString(result) : null; | |
51 } | |
52 | |
53 public NSDateComponents components_fromDate_ (NSUInteger unitFlags, NSDate date) | |
54 { | |
55 objc.id result = OS.objc_msgSend(this.id, OS.sel_components_1fromDate_1, unitFlags, date !is null ? date.id : null); | |
56 return result !is null ? new NSDateComponents(result) : null; | |
57 } | |
58 | |
59 public NSDateComponents components_fromDate_toDate_options_ (NSUInteger unitFlags, NSDate startingDate, NSDate resultDate, NSUInteger opts) | |
60 { | |
61 objc.id result = OS.objc_msgSend(this.id, OS.sel_components_1fromDate_1toDate_1options_1, unitFlags, | |
62 startingDate !is null ? startingDate.id : null, resultDate !is null ? resultDate.id : null, opts); | |
63 return result !is null ? new NSDateComponents(result) : null; | |
64 } | |
65 | |
66 public static id currentCalendar () | |
67 { | |
68 objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_currentCalendar); | |
69 return result !is null ? new id(result) : null; | |
70 } | |
71 | |
72 public NSDate dateByAddingComponents (NSDateComponents comps, NSDate date, NSUInteger opts) | |
73 { | |
74 objc.id result = OS.objc_msgSend(this.id, OS.sel_dateByAddingComponents_1toDate_1options_1, comps !is null ? comps.id : null, | |
75 date !is null ? date.id : null, opts); | |
76 return result !is null ? new NSDate(result) : null; | |
77 } | |
78 | |
79 public NSDate dateFromComponents (NSDateComponents comps) | |
80 { | |
81 objc.id result = OS.objc_msgSend(this.id, OS.sel_dateFromComponents_1, comps !is null ? comps.id : null); | |
82 return result !is null ? new NSDate(result) : null; | |
83 } | |
84 | |
85 public NSUInteger firstWeekday () | |
86 { | |
87 return OS.objc_msgSend(this.id, OS.sel_firstWeekday); | |
88 } | |
89 | |
90 public NSCalendar initWithCalendarIdentifier (NSString ident) | |
91 { | |
92 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCalendarIdentifier_1, ident !is null ? ident.id : null); | |
93 return result !is null ? this : null; | |
94 } | |
95 | |
96 public NSLocale locale () | |
97 { | |
98 objc.id result = OS.objc_msgSend(this.id, OS.sel_locale); | |
99 return result !is null ? new NSLocale(result) : null; | |
100 } | |
101 | |
102 public NSRange maximumRangeOfUnit (objc.id unit) | |
103 { | |
104 NSRange result; | |
105 OS.objc_msgSend_stret(result, this.id, OS.sel_maximumRangeOfUnit_1, unit); | |
106 return result; | |
107 } | |
108 | |
109 public NSUInteger minimumDaysInFirstWeek () | |
110 { | |
111 return OS.objc_msgSend(this.id, OS.sel_minimumDaysInFirstWeek); | |
112 } | |
113 | |
114 public NSRange minimumRangeOfUnit (objc.id unit) | |
115 { | |
116 NSRange result; | |
117 OS.objc_msgSend_stret(result, this.id, OS.sel_minimumRangeOfUnit_1, unit); | |
118 return result; | |
119 } | |
120 | |
121 public NSUInteger ordinalityOfUnit (objc.id smaller, objc.id larger, NSDate date) | |
122 { | |
123 return OS.objc_msgSend(this.id, OS.sel_ordinalityOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id : null); | |
124 } | |
125 | |
126 public NSRange rangeOfUnit_inUnit_forDate_ (objc.id smaller, objc.id larger, NSDate date) | |
127 { | |
128 NSRange result; | |
129 OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id : null); | |
130 return result; | |
131 } | |
132 | |
133 public bool rangeOfUnit_startDate_interval_forDate_ (objc.id unit, objc.id datep, objc.id tip, NSDate date) | |
134 { | |
135 return OS.objc_msgSend(this.id, OS.sel_rangeOfUnit_1startDate_1interval_1forDate_1, unit, datep, tip, date !is null ? date.id : null) !is null; | |
136 } | |
137 | |
138 public void setFirstWeekday (NSUInteger weekday) | |
139 { | |
140 OS.objc_msgSend(this.id, OS.sel_setFirstWeekday_1, weekday); | |
141 } | |
142 | |
143 public void setLocale (NSLocale locale) | |
144 { | |
145 OS.objc_msgSend(this.id, OS.sel_setLocale_1, locale !is null ? locale.id : null); | |
146 } | |
147 | |
148 public void setMinimumDaysInFirstWeek (NSUInteger mdw) | |
149 { | |
150 OS.objc_msgSend(this.id, OS.sel_setMinimumDaysInFirstWeek_1, mdw); | |
151 } | |
152 | |
153 public void setTimeZone (NSTimeZone tz) | |
154 { | |
155 OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, tz !is null ? tz.id : null); | |
156 } | |
157 | |
158 public NSTimeZone timeZone () | |
159 { | |
160 objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone); | |
161 return result !is null ? new NSTimeZone(result) : null; | |
162 } | |
163 | |
164 } |