objc2_foundation/generated/
NSDate.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern "C" {
12 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
14 pub static NSSystemClockDidChangeNotification: &'static NSNotificationName;
15}
16
17pub type NSTimeInterval = c_double;
19
20extern_class!(
21 #[unsafe(super(NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 pub struct NSDate;
25);
26
27unsafe impl Send for NSDate {}
28
29unsafe impl Sync for NSDate {}
30
31#[cfg(feature = "objc2-core-foundation")]
32impl AsRef<NSDate> for CFDate {
33 #[inline]
34 fn as_ref(&self) -> &NSDate {
35 unsafe { &*((self as *const Self).cast()) }
36 }
37}
38
39#[cfg(feature = "objc2-core-foundation")]
40impl AsRef<CFDate> for NSDate {
41 #[inline]
42 fn as_ref(&self) -> &CFDate {
43 unsafe { &*((self as *const Self).cast()) }
44 }
45}
46
47#[cfg(feature = "NSObject")]
48extern_conformance!(
49 unsafe impl NSCoding for NSDate {}
50);
51
52#[cfg(feature = "NSObject")]
53extern_conformance!(
54 unsafe impl NSCopying for NSDate {}
55);
56
57#[cfg(feature = "NSObject")]
58unsafe impl CopyingHelper for NSDate {
59 type Result = Self;
60}
61
62extern_conformance!(
63 unsafe impl NSObjectProtocol for NSDate {}
64);
65
66#[cfg(feature = "NSObject")]
67extern_conformance!(
68 unsafe impl NSSecureCoding for NSDate {}
69);
70
71impl NSDate {
72 extern_methods!(
73 #[unsafe(method(timeIntervalSinceReferenceDate))]
74 #[unsafe(method_family = none)]
75 pub fn timeIntervalSinceReferenceDate(&self) -> NSTimeInterval;
76
77 #[unsafe(method(init))]
78 #[unsafe(method_family = init)]
79 pub fn init(this: Allocated<Self>) -> Retained<Self>;
80
81 #[unsafe(method(initWithTimeIntervalSinceReferenceDate:))]
82 #[unsafe(method_family = init)]
83 pub fn initWithTimeIntervalSinceReferenceDate(
84 this: Allocated<Self>,
85 ti: NSTimeInterval,
86 ) -> Retained<Self>;
87
88 #[cfg(feature = "NSCoder")]
89 #[unsafe(method(initWithCoder:))]
93 #[unsafe(method_family = init)]
94 pub unsafe fn initWithCoder(
95 this: Allocated<Self>,
96 coder: &NSCoder,
97 ) -> Option<Retained<Self>>;
98 );
99}
100
101impl NSDate {
103 extern_methods!(
104 #[unsafe(method(new))]
105 #[unsafe(method_family = new)]
106 pub fn new() -> Retained<Self>;
107 );
108}
109
110impl DefaultRetained for NSDate {
111 #[inline]
112 fn default_retained() -> Retained<Self> {
113 Self::new()
114 }
115}
116
117impl NSDate {
119 extern_methods!(
120 #[unsafe(method(timeIntervalSinceDate:))]
121 #[unsafe(method_family = none)]
122 pub fn timeIntervalSinceDate(&self, another_date: &NSDate) -> NSTimeInterval;
123
124 #[unsafe(method(timeIntervalSinceNow))]
125 #[unsafe(method_family = none)]
126 pub fn timeIntervalSinceNow(&self) -> NSTimeInterval;
127
128 #[unsafe(method(timeIntervalSince1970))]
129 #[unsafe(method_family = none)]
130 pub fn timeIntervalSince1970(&self) -> NSTimeInterval;
131
132 #[deprecated = "Use dateByAddingTimeInterval instead"]
133 #[unsafe(method(addTimeInterval:))]
134 #[unsafe(method_family = none)]
135 pub fn addTimeInterval(&self, seconds: NSTimeInterval) -> Retained<AnyObject>;
136
137 #[unsafe(method(dateByAddingTimeInterval:))]
138 #[unsafe(method_family = none)]
139 pub fn dateByAddingTimeInterval(&self, ti: NSTimeInterval) -> Retained<Self>;
140
141 #[unsafe(method(earlierDate:))]
142 #[unsafe(method_family = none)]
143 pub fn earlierDate(&self, another_date: &NSDate) -> Retained<NSDate>;
144
145 #[unsafe(method(laterDate:))]
146 #[unsafe(method_family = none)]
147 pub fn laterDate(&self, another_date: &NSDate) -> Retained<NSDate>;
148
149 #[cfg(feature = "NSObjCRuntime")]
150 #[unsafe(method(compare:))]
151 #[unsafe(method_family = none)]
152 pub fn compare(&self, other: &NSDate) -> NSComparisonResult;
153
154 #[unsafe(method(isEqualToDate:))]
155 #[unsafe(method_family = none)]
156 pub fn isEqualToDate(&self, other_date: &NSDate) -> bool;
157
158 #[cfg(feature = "NSString")]
159 #[unsafe(method(description))]
160 #[unsafe(method_family = none)]
161 pub fn description(&self) -> Retained<NSString>;
162
163 #[cfg(feature = "NSString")]
164 #[unsafe(method(descriptionWithLocale:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn descriptionWithLocale(
170 &self,
171 locale: Option<&AnyObject>,
172 ) -> Retained<NSString>;
173
174 #[unsafe(method(timeIntervalSinceReferenceDate))]
175 #[unsafe(method_family = none)]
176 pub fn timeIntervalSinceReferenceDate_class() -> NSTimeInterval;
177 );
178}
179
180impl NSDate {
182 extern_methods!(
183 #[unsafe(method(date))]
184 #[unsafe(method_family = none)]
185 pub fn date() -> Retained<Self>;
186
187 #[unsafe(method(dateWithTimeIntervalSinceNow:))]
188 #[unsafe(method_family = none)]
189 pub fn dateWithTimeIntervalSinceNow(secs: NSTimeInterval) -> Retained<Self>;
190
191 #[unsafe(method(dateWithTimeIntervalSinceReferenceDate:))]
192 #[unsafe(method_family = none)]
193 pub fn dateWithTimeIntervalSinceReferenceDate(ti: NSTimeInterval) -> Retained<Self>;
194
195 #[unsafe(method(dateWithTimeIntervalSince1970:))]
196 #[unsafe(method_family = none)]
197 pub fn dateWithTimeIntervalSince1970(secs: NSTimeInterval) -> Retained<Self>;
198
199 #[unsafe(method(dateWithTimeInterval:sinceDate:))]
200 #[unsafe(method_family = none)]
201 pub fn dateWithTimeInterval_sinceDate(
202 secs_to_be_added: NSTimeInterval,
203 date: &NSDate,
204 ) -> Retained<Self>;
205
206 #[unsafe(method(distantFuture))]
207 #[unsafe(method_family = none)]
208 pub fn distantFuture() -> Retained<NSDate>;
209
210 #[unsafe(method(distantPast))]
211 #[unsafe(method_family = none)]
212 pub fn distantPast() -> Retained<NSDate>;
213
214 #[unsafe(method(now))]
215 #[unsafe(method_family = none)]
216 pub fn now() -> Retained<NSDate>;
217
218 #[unsafe(method(initWithTimeIntervalSinceNow:))]
219 #[unsafe(method_family = init)]
220 pub fn initWithTimeIntervalSinceNow(
221 this: Allocated<Self>,
222 secs: NSTimeInterval,
223 ) -> Retained<Self>;
224
225 #[unsafe(method(initWithTimeIntervalSince1970:))]
226 #[unsafe(method_family = init)]
227 pub fn initWithTimeIntervalSince1970(
228 this: Allocated<Self>,
229 secs: NSTimeInterval,
230 ) -> Retained<Self>;
231
232 #[unsafe(method(initWithTimeInterval:sinceDate:))]
233 #[unsafe(method_family = init)]
234 pub fn initWithTimeInterval_sinceDate(
235 this: Allocated<Self>,
236 secs_to_be_added: NSTimeInterval,
237 date: &NSDate,
238 ) -> Retained<Self>;
239 );
240}