File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 4
4
constructor
5
5
* inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem
6
6
7
+ * inst/tinytest/test_date.R: Add tests
8
+ * inst/tinytest/cpp/dates.cpp: Idem
9
+
7
10
2025-05-06 Dirk Eddelbuettel <
[email protected] >
8
11
9
12
* DESCRIPTION (Version, Date): Roll micro version and date
Original file line number Diff line number Diff line change 1
- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
- //
1
+
3
2
// dates.cpp: Rcpp R/C++ interface class library -- Date + Datetime tests
4
3
//
5
- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
4
+ // Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
6
5
//
7
6
// This file is part of Rcpp.
8
7
//
@@ -245,4 +244,12 @@ bool has_na_dtv(const Rcpp::DatetimeVector d) {
245
244
return Rcpp::is_true (Rcpp::any (Rcpp::is_na (d)));
246
245
}
247
246
247
+ // [[Rcpp::export]]
248
+ Rcpp::DateVector default_ctor_datevector () {
249
+ return Rcpp::DateVector ();
250
+ }
248
251
252
+ // [[Rcpp::export]]
253
+ Rcpp::DatetimeVector default_ctor_datetimevector () {
254
+ return Rcpp::DatetimeVector ();
255
+ }
Original file line number Diff line number Diff line change 1
1
2
- # # Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
2
+ # # Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
3
3
# #
4
4
# # This file is part of Rcpp.
5
5
# #
@@ -241,3 +241,15 @@ dvt <- Sys.time() + 0:2
241
241
expect_true(has_na_dtv(dvt ) == FALSE , info = " DatetimeVector.NAtest.withoutNA" )
242
242
dvt [1 ] <- NA
243
243
expect_true(has_na_dtv(dvt ) == TRUE , info = " DatetimeVector.NAtest.withNA" )
244
+
245
+ # # default ctor: date
246
+ dv <- default_ctor_datevector()
247
+ expect_true(inherits(dv , " Date" ))
248
+ expect_equal(length(dv ), 0L )
249
+ expect_equal(dv , as.Date(double()))
250
+
251
+ # # default ctor: datetime
252
+ dtv <- default_ctor_datetimevector()
253
+ expect_true(inherits(dtv , " POSIXct" ))
254
+ expect_equal(length(dtv ), 0L )
255
+ expect_equal(dtv , as.POSIXct(double(), origin = " 1970-01-01" )) # origin for R < 4.3.0
You can’t perform that action at this time.
0 commit comments