@@ -14,13 +14,25 @@ mod ffi {
1414 type DateFormat = crate :: DateFormat ;
1515 }
1616
17+ unsafe extern "C++" {
18+ include ! ( "cxx-qt-lib/qtypes.h" ) ;
19+ #[ cxx_name = "qint64" ]
20+ type QInt64 = crate :: QInt64 ;
21+ }
22+
1723 unsafe extern "C++" {
1824 include ! ( "cxx-qt-lib/qstring.h" ) ;
1925 type QString = crate :: QString ;
2026
2127 include ! ( "cxx-qt-lib/qdate.h" ) ;
2228 type QDate = super :: QDate ;
2329
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+
2436 /// Returns a QDate object containing a date nmonths later than the date of this object (or earlier if nmonths is negative).
2537 #[ rust_name = "add_months" ]
2638 fn addMonths ( self : & QDate , nmonths : i32 ) -> QDate ;
@@ -76,17 +88,13 @@ mod ffi {
7688
7789 #[ namespace = "rust::cxxqtlib1" ]
7890 unsafe extern "C++" {
79- #[ doc( hidden) ]
80- #[ rust_name = "qdate_add_days" ]
81- fn qdateAddDays ( date : & QDate , ndays : i64 ) -> QDate ;
82-
8391 #[ doc( hidden) ]
8492 #[ rust_name = "qdate_current_date" ]
8593 fn qdateCurrentDate ( ) -> QDate ;
8694
8795 #[ doc( hidden) ]
8896 #[ rust_name = "qdate_days_to" ]
89- fn qdateDaysTo ( date : & QDate , d : QDate ) -> i64 ;
97+ fn qdateDaysTo ( date : & QDate , d : QDate ) -> QInt64 ;
9098
9199 #[ doc( hidden) ]
92100 #[ rust_name = "qdate_from_string" ]
@@ -147,13 +155,6 @@ impl fmt::Debug for QDate {
147155}
148156
149157impl 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-
157158 // Returns the current date, as reported by the system clock.
158159 pub fn current_date ( ) -> Self {
159160 ffi:: qdate_current_date ( )
@@ -162,7 +163,7 @@ impl QDate {
162163 /// Returns the number of days from this date to d (which is negative if d is earlier than this date).
163164 ///
164165 /// 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 {
166167 ffi:: qdate_days_to ( self , date)
167168 }
168169
@@ -271,15 +272,15 @@ mod test {
271272 #[ test]
272273 fn qdate_current_date ( ) {
273274 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 ) ;
276277 }
277278
278279 #[ test]
279280 fn qdate_julian_day ( ) {
280281 let date_a = QDate :: from_julian_day ( 1000 ) ;
281282 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 ) ;
283284 }
284285
285286 #[ cfg( feature = "chrono" ) ]
0 commit comments