File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 44 constructor
55 * inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem
66
7+ * inst/tinytest/test_date.R: Add tests
8+ * inst/tinytest/cpp/dates.cpp: Idem
9+
7102025-05-06 Dirk Eddelbuettel <
[email protected] >
811
912 * 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+
32// dates.cpp: Rcpp R/C++ interface class library -- Date + Datetime tests
43//
5- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
4+ // Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
65//
76// This file is part of Rcpp.
87//
@@ -245,4 +244,12 @@ bool has_na_dtv(const Rcpp::DatetimeVector d) {
245244 return Rcpp::is_true (Rcpp::any (Rcpp::is_na (d)));
246245}
247246
247+ // [[Rcpp::export]]
248+ Rcpp::DateVector default_ctor_datevector () {
249+ return Rcpp::DateVector ();
250+ }
248251
252+ // [[Rcpp::export]]
253+ Rcpp::DatetimeVector default_ctor_datetimevector () {
254+ return Rcpp::DatetimeVector ();
255+ }
Original file line number Diff line number Diff line change 11
2- # # Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
2+ # # Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
33# #
44# # This file is part of Rcpp.
55# #
@@ -241,3 +241,15 @@ dvt <- Sys.time() + 0:2
241241expect_true(has_na_dtv(dvt ) == FALSE , info = " DatetimeVector.NAtest.withoutNA" )
242242dvt [1 ] <- NA
243243expect_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