@@ -14,13 +14,25 @@ mod ffi {
14
14
type DateFormat = crate :: DateFormat ;
15
15
}
16
16
17
+ unsafe extern "C++" {
18
+ include ! ( "cxx-qt-lib/qtypes.h" ) ;
19
+ #[ cxx_name = "qint64" ]
20
+ type QInt64 = crate :: QInt64 ;
21
+ }
22
+
17
23
unsafe extern "C++" {
18
24
include ! ( "cxx-qt-lib/qstring.h" ) ;
19
25
type QString = crate :: QString ;
20
26
21
27
include ! ( "cxx-qt-lib/qdate.h" ) ;
22
28
type QDate = super :: QDate ;
23
29
30
+ /// Returns a QDate object containing a date ndays later than the date of this object (or earlier if ndays is negative).
31
+ ///
32
+ /// Returns a null date if the current date is invalid or the new date is out of range.
33
+ #[ rust_name = "add_days" ]
34
+ fn addDays ( self : & QDate , ndays : QInt64 ) -> QDate ;
35
+
24
36
/// Returns a QDate object containing a date nmonths later than the date of this object (or earlier if nmonths is negative).
25
37
#[ rust_name = "add_months" ]
26
38
fn addMonths ( self : & QDate , nmonths : i32 ) -> QDate ;
@@ -76,17 +88,13 @@ mod ffi {
76
88
77
89
#[ namespace = "rust::cxxqtlib1" ]
78
90
unsafe extern "C++" {
79
- #[ doc( hidden) ]
80
- #[ rust_name = "qdate_add_days" ]
81
- fn qdateAddDays ( date : & QDate , ndays : i64 ) -> QDate ;
82
-
83
91
#[ doc( hidden) ]
84
92
#[ rust_name = "qdate_current_date" ]
85
93
fn qdateCurrentDate ( ) -> QDate ;
86
94
87
95
#[ doc( hidden) ]
88
96
#[ rust_name = "qdate_days_to" ]
89
- fn qdateDaysTo ( date : & QDate , d : QDate ) -> i64 ;
97
+ fn qdateDaysTo ( date : & QDate , d : QDate ) -> QInt64 ;
90
98
91
99
#[ doc( hidden) ]
92
100
#[ rust_name = "qdate_from_string" ]
@@ -147,13 +155,6 @@ impl fmt::Debug for QDate {
147
155
}
148
156
149
157
impl QDate {
150
- /// Returns a QDate object containing a date ndays later than the date of this object (or earlier if ndays is negative).
151
- ///
152
- /// Returns a null date if the current date is invalid or the new date is out of range.
153
- pub fn add_days ( & self , ndays : i64 ) -> Self {
154
- ffi:: qdate_add_days ( self , ndays)
155
- }
156
-
157
158
// Returns the current date, as reported by the system clock.
158
159
pub fn current_date ( ) -> Self {
159
160
ffi:: qdate_current_date ( )
@@ -162,7 +163,7 @@ impl QDate {
162
163
/// Returns the number of days from this date to d (which is negative if d is earlier than this date).
163
164
///
164
165
/// Returns 0 if either date is invalid.
165
- pub fn days_to ( & self , date : Self ) -> i64 {
166
+ pub fn days_to ( & self , date : Self ) -> ffi :: QInt64 {
166
167
ffi:: qdate_days_to ( self , date)
167
168
}
168
169
@@ -271,15 +272,15 @@ mod test {
271
272
#[ test]
272
273
fn qdate_current_date ( ) {
273
274
let date_a = QDate :: current_date ( ) ;
274
- let date_b = date_a. add_days ( 100 ) ;
275
- assert_eq ! ( date_a. days_to( date_b) , 100 ) ;
275
+ let date_b = date_a. add_days ( 100 . into ( ) ) ;
276
+ assert_eq ! ( i64 :: from ( date_a. days_to( date_b) ) , 100 ) ;
276
277
}
277
278
278
279
#[ test]
279
280
fn qdate_julian_day ( ) {
280
281
let date_a = QDate :: from_julian_day ( 1000 ) ;
281
282
let date_b = QDate :: from_julian_day ( 1010 ) ;
282
- assert_eq ! ( date_a. days_to( date_b) , 10 ) ;
283
+ assert_eq ! ( i64 :: from ( date_a. days_to( date_b) ) , 10 ) ;
283
284
}
284
285
285
286
#[ cfg( feature = "chrono" ) ]
0 commit comments