Binary files /tmp/tmpPKSfs5/4ZOmt8GfF4/r-cran-rcppdate-0.0.1/build/partial.rdb and /tmp/tmpPKSfs5/iVIic95GxZ/r-cran-rcppdate-0.0.2/build/partial.rdb differ diff -Nru r-cran-rcppdate-0.0.1/ChangeLog r-cran-rcppdate-0.0.2/ChangeLog --- r-cran-rcppdate-0.0.1/ChangeLog 2020-03-17 12:54:52.000000000 +0000 +++ r-cran-rcppdate-0.0.2/ChangeLog 2021-01-29 13:55:19.000000000 +0000 @@ -1,3 +1,35 @@ +2021-01-29 Dirk Eddelbuettel + + * DESCRIPTION (Date, Version): Release 0.0.2 + (Description): Slightly reworded + + * inst/include/date.h: Another upstream commit since 0.3.0 + + * README.md: Added badge for downloads + +2021-01-03 Dirk Eddelbuettel + + * inst/include/date.h: Upstream 0.3.0 plus more recent commits + * inst/include/julian.h: Ditto + * inst/include/ptz.h: Ditto + * inst/include/solar_hijri.h: Ditto + * inst/include/tz_private.h: Ditto + * inst/include/tz.h: Ditto + + * .github/workflows/ci.yaml: Add CI runner using r-ci + * README.md: Add new badge + +2020-06-19 Dirk Eddelbuettel + + * .travis.yml: Determine package name and version from DESCRIPTION, + switch to bionic + +2020-03-24 Dirk Eddelbuettel + + * README.md: Badges for CRAN version, dependencies and last commit + + * inst/NEWS.Rd: Added + 2020-03-17 Dirk Eddelbuettel * DESCRIPTION (Date, Version): Initial CRAN release 0.0.1 diff -Nru r-cran-rcppdate-0.0.1/debian/changelog r-cran-rcppdate-0.0.2/debian/changelog --- r-cran-rcppdate-0.0.1/debian/changelog 2020-12-26 15:24:07.000000000 +0000 +++ r-cran-rcppdate-0.0.2/debian/changelog 2021-01-29 15:41:20.000000000 +0000 @@ -1,3 +1,9 @@ +r-cran-rcppdate (0.0.2-1) unstable; urgency=medium + + * New upstream release + + -- Dirk Eddelbuettel Fri, 29 Jan 2021 09:41:20 -0600 + r-cran-rcppdate (0.0.1-1) unstable; urgency=low * Initial Debian release (Closes: #978135) diff -Nru r-cran-rcppdate-0.0.1/debian/control r-cran-rcppdate-0.0.2/debian/control --- r-cran-rcppdate-0.0.1/debian/control 2020-12-26 15:24:07.000000000 +0000 +++ r-cran-rcppdate-0.0.2/debian/control 2021-01-29 15:41:02.000000000 +0000 @@ -2,7 +2,7 @@ Section: gnu-r Priority: optional Maintainer: Dirk Eddelbuettel -Build-Depends: debhelper-compat (= 11), r-base-dev (>= 4.0.0), dh-r, r-cran-rcpp +Build-Depends: debhelper-compat (= 11), r-base-dev (>= 4.0.3), dh-r, r-cran-rcpp Standards-Version: 4.5.1 Vcs-Browser: https://salsa.debian.org/edd/r-cran-rcppdate Vcs-Git: https://salsa.debian.org/edd/r-cran-rcppdate.git diff -Nru r-cran-rcppdate-0.0.1/DESCRIPTION r-cran-rcppdate-0.0.2/DESCRIPTION --- r-cran-rcppdate-0.0.1/DESCRIPTION 2020-03-24 16:10:02.000000000 +0000 +++ r-cran-rcppdate-0.0.2/DESCRIPTION 2021-01-29 15:00:05.000000000 +0000 @@ -1,23 +1,25 @@ Package: RcppDate Type: Package Title: 'date' C++ Header Library for Date and Time Functionality -Version: 0.0.1 -Date: 2020-03-17 +Version: 0.0.2 +Date: 2021-01-29 Author: Dirk Eddelbuettel Maintainer: Dirk Eddelbuettel -Description: 'date' is a C++ header library offering extensive date - and time functionality for the C++11, C++14 and C++17 standards - written by Howard Hinnant and released under the MIT license. A - slightly modified version has been accepted (along with 'tz.h') as - part of C++20. This package regroups all header files from the - upstream repository by Howard Hinnant so that other R packages can - use them in their C++ code. At present, few of the types have - explicit 'Rcpp' wrapper though these may be added as needed. +Description: A header-only C++ library is provided with support + for dates, time zones, ISO weeks, Julian dates, and Islamic dates. + 'date' offers extensive date and time functionality for the C++11, + C++14 and C++17 standards and was written by Howard Hinnant and released + under the MIT license. A slightly modified version has been accepted + (along with 'tz.h') as part of C++20. This package regroups all + header files from the upstream repository by Howard Hinnant so that + other R packages can use them in their C++ code. At present, few of + the types have explicit 'Rcpp' wrappers though these may be added as + needed. License: GPL (>= 2) Suggests: Rcpp URL: https://github.com/eddelbuettel/rcppdate BugReports: https://github.com/eddelbuettel/rcppdate/issues NeedsCompilation: no -Packaged: 2020-03-17 12:55:12.704435 UTC; edd +Packaged: 2021-01-29 14:26:59 UTC; edd Repository: CRAN -Date/Publication: 2020-03-24 16:10:02 UTC +Date/Publication: 2021-01-29 15:00:05 UTC diff -Nru r-cran-rcppdate-0.0.1/inst/include/date.h r-cran-rcppdate-0.0.2/inst/include/date.h --- r-cran-rcppdate-0.0.1/inst/include/date.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/date.h 2021-01-29 04:44:49.000000000 +0000 @@ -45,9 +45,7 @@ #include #include #include -#if !(__cplusplus >= 201402) -# include -#endif +#include #include #include #include @@ -71,7 +69,7 @@ #ifdef __GNUC__ # pragma GCC diagnostic push -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR > 7) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7) # pragma GCC diagnostic ignored "-Wpedantic" # endif # if __GNUC__ < 5 @@ -1166,7 +1164,11 @@ static const std::intmax_t d1 = R1::den / gcd_d1_d2; static const std::intmax_t n2 = R2::num / gcd_n1_n2; static const std::intmax_t d2 = R2::den / gcd_d1_d2; +#ifdef __cpp_constexpr static const std::intmax_t max = std::numeric_limits::max(); +#else + static const std::intmax_t max = LLONG_MAX; +#endif template struct mul // overflow == false @@ -1354,6 +1356,47 @@ #endif // HAS_CHRONO_ROUNDING +namespace detail +{ + +template +CONSTCD14 +inline +typename std::enable_if +< + !std::chrono::treat_as_floating_point::value, + To +>::type +round_i(const std::chrono::duration& d) +{ + return round(d); +} + +template +CONSTCD14 +inline +typename std::enable_if +< + std::chrono::treat_as_floating_point::value, + To +>::type +round_i(const std::chrono::duration& d) +{ + return d; +} + +template +CONSTCD11 +inline +std::chrono::time_point +round_i(const std::chrono::time_point& tp) +{ + using std::chrono::time_point; + return time_point{round_i(tp.time_since_epoch())}; +} + +} // detail + // trunc towards zero template CONSTCD11 @@ -3681,11 +3724,12 @@ // Example: width<4>::value == 2 // Example: width<10>::value == 1 // Example: width<1000>::value == 3 -template +template struct width { - static CONSTDATA unsigned value = 1 + width::value; + static_assert(d > 0, "width called with zero denominator"); + static CONSTDATA unsigned value = 1 + width::value; }; template @@ -3714,9 +3758,10 @@ { using CT = typename std::common_type::type; using rep = typename CT::rep; + static unsigned CONSTDATA trial_width = + detail::width::value; public: - static unsigned constexpr width = detail::width::value < 19 ? - detail::width::value : 6u; + static unsigned CONSTDATA width = trial_width < 19 ? trial_width : 6u; using precision = std::chrono::duration::value>>; @@ -3732,8 +3777,7 @@ CONSTCD11 explicit decimal_format_seconds(const Duration& d) NOEXCEPT : s_(std::chrono::duration_cast(d)) - , sub_s_(std::chrono::treat_as_floating_point::value ? d - s_ : - std::chrono::duration_cast(d - s_)) + , sub_s_(std::chrono::duration_cast(d - s_)) {} CONSTCD14 std::chrono::seconds& seconds() NOEXCEPT {return s_;} @@ -4149,10 +4193,10 @@ && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5150) template {} || - std::is_same{} || - std::is_same{} || - std::is_same{}>> + class = std::enable_if_t::value || + std::is_same::value || + std::is_same::value || + std::is_same::value>> CONSTCD14 inline string_literal @@ -6123,9 +6167,16 @@ read_long_double(std::basic_istream& is, unsigned m = 1, unsigned M = 10) { unsigned count = 0; + unsigned fcount = 0; + unsigned long long i = 0; + unsigned long long f = 0; + bool parsing_fraction = false; +#if ONLY_C_LOCALE + typename Traits::int_type decimal_point = '.'; +#else auto decimal_point = Traits::to_int_type( std::use_facet>(is.getloc()).decimal_point()); - std::string buf; +#endif while (true) { auto ic = is.peek(); @@ -6133,18 +6184,25 @@ break; if (Traits::eq_int_type(ic, decimal_point)) { - buf += '.'; decimal_point = Traits::eof(); - is.get(); + parsing_fraction = true; } else { auto c = static_cast(Traits::to_char_type(ic)); if (!('0' <= c && c <= '9')) break; - buf += c; - (void)is.get(); + if (!parsing_fraction) + { + i = 10*i + static_cast(c - '0'); + } + else + { + f = 10*f + static_cast(c - '0'); + ++fcount; + } } + (void)is.get(); if (++count == M) break; } @@ -6153,7 +6211,7 @@ is.setstate(std::ios::failbit); return 0; } - return std::stold(buf); + return i + f/std::pow(10.L, fcount); } struct rs @@ -6310,6 +6368,7 @@ using std::chrono::seconds; using std::chrono::minutes; using std::chrono::hours; + using detail::round_i; typename std::basic_istream::sentry ok{is, true}; if (ok) { @@ -6325,7 +6384,7 @@ auto modified = CharT{}; auto width = -1; - CONSTDATA int not_a_year = numeric_limits::min(); + CONSTDATA int not_a_year = numeric_limits::min(); CONSTDATA int not_a_2digit_year = 100; CONSTDATA int not_a_century = not_a_year / 100; CONSTDATA int not_a_month = 0; @@ -6523,7 +6582,7 @@ CharT{':'}, rld{S, 1, w}); checked_set(H, tH, not_a_hour, is); checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), + checked_set(s, round_i(duration{S}), not_a_second, is); ws(is); int tY = not_a_year; @@ -6603,7 +6662,7 @@ CharT{':'}, rld{S, 1, w}); checked_set(H, tH, not_a_hour, is); checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), + checked_set(s, round_i(duration{S}), not_a_second, is); #endif } @@ -6919,7 +6978,7 @@ #else auto nm = detail::ampm_names(); auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - tp = i; + tp = static_cast(i); #endif checked_set(p, tp, not_a_ampm, is); } @@ -6960,7 +7019,7 @@ CharT{':'}, rld{S, 1, w}); checked_set(I, tI, not_a_hour_12_value, is); checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), + checked_set(s, round_i(duration{S}), not_a_second, is); ws(is); auto nm = detail::ampm_names(); @@ -7011,7 +7070,7 @@ CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; long double S; read(is, rld{S, 1, width == -1 ? w : static_cast(width)}); - checked_set(s, round(duration{S}), + checked_set(s, round_i(duration{S}), not_a_second, is); } #if !ONLY_C_LOCALE @@ -7048,7 +7107,7 @@ CharT{':'}, rld{S, 1, w}); checked_set(H, tH, not_a_hour, is); checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), + checked_set(s, round_i(duration{S}), not_a_second, is); } else @@ -7751,6 +7810,7 @@ std::chrono::minutes* offset = nullptr) { using CT = typename std::common_type::type; + using detail::round_i; std::chrono::minutes offset_local{}; auto offptr = offset ? offset : &offset_local; fields fds{}; @@ -7759,7 +7819,7 @@ if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) is.setstate(std::ios::failbit); if (!is.fail()) - tp = round(sys_days(fds.ymd) - *offptr + fds.tod.to_duration()); + tp = round_i(sys_days(fds.ymd) - *offptr + fds.tod.to_duration()); return is; } @@ -7770,13 +7830,14 @@ std::chrono::minutes* offset = nullptr) { using CT = typename std::common_type::type; + using detail::round_i; fields fds{}; fds.has_tod = true; from_stream(is, fmt, fds, abbrev, offset); if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) is.setstate(std::ios::failbit); if (!is.fail()) - tp = round(local_seconds{local_days(fds.ymd)} + fds.tod.to_duration()); + tp = round_i(local_seconds{local_days(fds.ymd)} + fds.tod.to_duration()); return is; } diff -Nru r-cran-rcppdate-0.0.1/inst/include/julian.h r-cran-rcppdate-0.0.2/inst/include/julian.h --- r-cran-rcppdate-0.0.1/inst/include/julian.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/julian.h 2021-01-03 21:48:32.000000000 +0000 @@ -1655,9 +1655,12 @@ bool month_day::ok() const NOEXCEPT { - CONSTDATA julian::day d[] = - {31_d, 29_d, 31_d, 30_d, 31_d, 30_d, 31_d, 31_d, 30_d, 31_d, 30_d, 31_d}; - return m_.ok() && 1_d <= d_ && d_ <= d[static_cast(m_)-1]; + CONSTDATA julian::day d[] = { + julian::day(31), julian::day(29), julian::day(31), julian::day(30), + julian::day(31), julian::day(30), julian::day(31), julian::day(31), + julian::day(30), julian::day(31), julian::day(30), julian::day(31) + }; + return m_.ok() && julian::day(1) <= d_ && d_ <= d[static_cast(m_)-1]; } CONSTCD11 @@ -1946,9 +1949,12 @@ day year_month_day_last::day() const NOEXCEPT { - CONSTDATA julian::day d[] = - {31_d, 28_d, 31_d, 30_d, 31_d, 30_d, 31_d, 31_d, 30_d, 31_d, 30_d, 31_d}; - return month() != feb || !y_.is_leap() ? d[static_cast(month())-1] : 29_d; + CONSTDATA julian::day d[] = { + julian::day(31), julian::day(28), julian::day(31), julian::day(30), + julian::day(31), julian::day(30), julian::day(31), julian::day(31), + julian::day(30), julian::day(31), julian::day(30), julian::day(31) + }; + return month() != feb || !y_.is_leap() ? d[static_cast(month())-1] : julian::day(29); } CONSTCD14 @@ -2190,7 +2196,7 @@ { if (!(y_.ok() && m_.ok())) return false; - return 1_d <= d_ && d_ <= (y_/m_/last).day(); + return julian::day(1) <= d_ && d_ <= (y_/m_/last).day(); } CONSTCD11 diff -Nru r-cran-rcppdate-0.0.1/inst/include/ptz.h r-cran-rcppdate-0.0.2/inst/include/ptz.h --- r-cran-rcppdate-0.0.1/inst/include/ptz.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/ptz.h 2021-01-03 21:48:32.000000000 +0000 @@ -36,6 +36,9 @@ // Posix::time_zone tz{"EST5EDT,M3.2.0,M11.1.0"}; // zoned_time zt{tz, system_clock::now()}; // +// If the rule set is missing (everything starting with ','), then the rule is that the +// alternate offset is never enabled. +// // Note, Posix-style time zones are not recommended for all of the reasons described here: // https://stackoverflow.com/tags/timezone/info // @@ -70,7 +73,8 @@ unsigned read_name(const string_t& s, unsigned i, std::string& name); unsigned read_signed_time(const string_t& s, unsigned i, std::chrono::seconds& t); unsigned read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t); -unsigned read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u); +unsigned read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u, + const string_t& message = string_t{}); class rule { @@ -87,12 +91,39 @@ bool ok() const {return mode_ != off;} date::local_seconds operator()(date::year y) const; + std::string to_string() const; friend std::ostream& operator<<(std::ostream& os, const rule& r); friend unsigned read_date(const string_t& s, unsigned i, rule& r); + friend bool operator==(const rule& x, const rule& y); }; inline +bool +operator==(const rule& x, const rule& y) +{ + if (x.mode_ != y.mode_) + return false; + switch (x.mode_) + { + case rule::J: + case rule::N: + return x.n_ == y.n_; + case rule::M: + return x.m_ == y.m_ && x.n_ == y.n_ && x.wd_ == y.wd_; + default: + return true; + } +} + +inline +bool +operator!=(const rule& x, const rule& y) +{ + return !(x == y); +} + +inline date::local_seconds rule::operator()(date::year y) const { @@ -120,6 +151,62 @@ } inline +std::string +rule::to_string() const +{ + using namespace std::chrono; + auto print_offset = [](seconds off) + { + std::string nm; + if (off != hours{2}) + { + date::hh_mm_ss offset{off}; + nm = '/'; + nm += std::to_string(offset.hours().count()); + if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0}) + { + nm += ':'; + if (offset.minutes() < minutes{10}) + nm += '0'; + nm += std::to_string(offset.minutes().count()); + if (offset.seconds() != seconds{0}) + { + nm += ':'; + if (offset.seconds() < seconds{10}) + nm += '0'; + nm += std::to_string(offset.seconds().count()); + } + } + } + return nm; + }; + + std::string nm; + switch (mode_) + { + case rule::J: + nm = 'J'; + nm += std::to_string(n_); + break; + case rule::M: + nm = 'M'; + nm += std::to_string(static_cast(m_)); + nm += '.'; + nm += std::to_string(n_); + nm += '.'; + nm += std::to_string(wd_.c_encoding()); + break; + case rule::N: + nm = std::to_string(n_); + break; + default: + break; + } + nm += print_offset(time_); + return nm; +} + +inline std::ostream& operator<<(std::ostream& os, const rule& r) { @@ -178,6 +265,10 @@ friend std::ostream& operator<<(std::ostream& os, const time_zone& z); const time_zone* operator->() const {return this;} + + std::string name() const; + + friend bool operator==(const time_zone& x, const time_zone& y); }; inline @@ -195,7 +286,10 @@ if (i != s.size()) { if (s[i] != ',') + { i = read_signed_time(s, i, save_); + save_ = -save_ - offset_; + } if (i != s.size()) { if (s[i] != ',') @@ -416,6 +510,72 @@ return os; } +inline +std::string +time_zone::name() const +{ + using namespace date; + using namespace std::chrono; + auto nm = std_abbrev_; + auto print_offset = [](seconds off) + { + std::string nm; + hh_mm_ss offset{-off}; + if (offset.is_negative()) + nm += '-'; + nm += std::to_string(offset.hours().count()); + if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0}) + { + nm += ':'; + if (offset.minutes() < minutes{10}) + nm += '0'; + nm += std::to_string(offset.minutes().count()); + if (offset.seconds() != seconds{0}) + { + nm += ':'; + if (offset.seconds() < seconds{10}) + nm += '0'; + nm += std::to_string(offset.seconds().count()); + } + } + return nm; + }; + nm += print_offset(offset_); + if (!dst_abbrev_.empty()) + { + nm += dst_abbrev_; + if (save_ != hours{1}) + nm += print_offset(offset_+save_); + if (start_rule_.ok()) + { + nm += ','; + nm += start_rule_.to_string(); + nm += ','; + nm += end_rule_.to_string(); + } + } + return nm; +} + +inline +bool +operator==(const time_zone& x, const time_zone& y) +{ + return x.std_abbrev_ == y.std_abbrev_ && + x.dst_abbrev_ == y. dst_abbrev_ && + x.offset_ == y.offset_ && + x.save_ == y.save_ && + x.start_rule_ == y.start_rule_ && + x.end_rule_ == y.end_rule_; +} + +inline +bool +operator!=(const time_zone& x, const time_zone& y) +{ + return !(x == y); +} + namespace detail { @@ -428,7 +588,7 @@ std::string(s) + '\n' + "\x1b[1;32m" + std::string(i, '~') + '^' + - std::string(s.size()-i-1, '~') + + std::string(i < s.size() ? s.size()-i-1 : 0, '~') + "\x1b[0m"); } @@ -444,7 +604,7 @@ { ++i; unsigned n; - i = read_unsigned(s, i, 3, n); + i = read_unsigned(s, i, 3, n, "Expected to find the Julian day [1, 365]"); r.mode_ = rule::J; r.n_ = n; } @@ -452,17 +612,17 @@ { ++i; unsigned m; - i = read_unsigned(s, i, 2, m); + i = read_unsigned(s, i, 2, m, "Expected to find month [1, 12]"); if (i == s.size() || s[i] != '.') throw_invalid(s, i, "Expected '.' after month"); ++i; unsigned n; - i = read_unsigned(s, i, 1, n); + i = read_unsigned(s, i, 1, n, "Expected to find week number [1, 5]"); if (i == s.size() || s[i] != '.') throw_invalid(s, i, "Expected '.' after weekday index"); ++i; unsigned wd; - i = read_unsigned(s, i, 1, wd); + i = read_unsigned(s, i, 1, wd, "Expected to find day of week [0, 6]"); r.mode_ = rule::M; r.m_ = month{m}; r.wd_ = weekday{wd}; @@ -552,17 +712,17 @@ if (i == s.size()) throw_invalid(s, i, "Expected to read unsigned time, but found end of string"); unsigned x; - i = read_unsigned(s, i, 2, x); + i = read_unsigned(s, i, 2, x, "Expected to find hours [0, 24]"); t = hours{x}; if (i != s.size() && s[i] == ':') { ++i; - i = read_unsigned(s, i, 2, x); + i = read_unsigned(s, i, 2, x, "Expected to find minutes [0, 59]"); t += minutes{x}; if (i != s.size() && s[i] == ':') { ++i; - i = read_unsigned(s, i, 2, x); + i = read_unsigned(s, i, 2, x, "Expected to find seconds [0, 59]"); t += seconds{x}; } } @@ -571,10 +731,11 @@ inline unsigned -read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u) +read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u, + const string_t& message) { if (i == s.size() || !std::isdigit(s[i])) - throw_invalid(s, i, "Expected to find a decimal digit"); + throw_invalid(s, i, message); u = static_cast(s[i] - '0'); unsigned count = 1; for (++i; count < limit && i != s.size() && std::isdigit(s[i]); ++i, ++count) diff -Nru r-cran-rcppdate-0.0.1/inst/include/solar_hijri.h r-cran-rcppdate-0.0.2/inst/include/solar_hijri.h --- r-cran-rcppdate-0.0.1/inst/include/solar_hijri.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/solar_hijri.h 2021-01-03 21:48:32.000000000 +0000 @@ -1707,9 +1707,13 @@ bool month_day::ok() const NOEXCEPT { - CONSTDATA solar_hijri::day d[] = - {31_d, 31_d, 31_d, 31_d, 31_d, 31_d, 30_d, 30_d, 30_d, 30_d, 30_d, 30_d}; - return m_.ok() && 1_d <= d_ && d_ <= d[static_cast(m_)-1]; + CONSTDATA solar_hijri::day d[] = { + solar_hijri::day(31), solar_hijri::day(31), solar_hijri::day(31), + solar_hijri::day(31), solar_hijri::day(31), solar_hijri::day(31), + solar_hijri::day(30), solar_hijri::day(30), solar_hijri::day(30), + solar_hijri::day(30), solar_hijri::day(30), solar_hijri::day(30) + }; + return m_.ok() && solar_hijri::day(1) <= d_ && d_ <= d[static_cast(m_)-1]; } CONSTCD11 @@ -1998,10 +2002,14 @@ day year_month_day_last::day() const NOEXCEPT { - CONSTDATA solar_hijri::day d[] = - {31_d, 31_d, 31_d, 31_d, 31_d, 31_d, 30_d, 30_d, 30_d, 30_d, 30_d, 29_d}; + CONSTDATA solar_hijri::day d[] = { + solar_hijri::day(31), solar_hijri::day(31), solar_hijri::day(31), + solar_hijri::day(31), solar_hijri::day(31), solar_hijri::day(31), + solar_hijri::day(30), solar_hijri::day(30), solar_hijri::day(30), + solar_hijri::day(30), solar_hijri::day(30), solar_hijri::day(29) + }; return month() != esf || !y_.is_leap() ? - d[static_cast(month())-1] : 30_d; + d[static_cast(month()) - 1] : solar_hijri::day(30); } CONSTCD14 @@ -2260,7 +2268,7 @@ { if (!(y_.ok() && m_.ok())) return false; - return 1_d <= d_ && d_ <= (y_/m_/last).day(); + return solar_hijri::day(1) <= d_ && d_ <= (y_/m_/last).day(); } CONSTCD11 diff -Nru r-cran-rcppdate-0.0.1/inst/include/tz.h r-cran-rcppdate-0.0.2/inst/include/tz.h --- r-cran-rcppdate-0.0.1/inst/include/tz.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/tz.h 2021-01-03 21:48:32.000000000 +0000 @@ -86,15 +86,6 @@ # ifdef _WIN32 # error "USE_OS_TZDB can not be used on Windows" # endif -# ifndef MISSING_LEAP_SECONDS -# ifdef __APPLE__ -# define MISSING_LEAP_SECONDS 1 -# else -# define MISSING_LEAP_SECONDS 0 -# endif -# endif -#else -# define MISSING_LEAP_SECONDS 0 #endif #ifndef HAS_DEDUCTION_GUIDES @@ -703,6 +694,11 @@ private: template friend class zoned_time; + + template + static + TimeZonePtr2&& + check(TimeZonePtr2&& p); }; using zoned_seconds = zoned_time; @@ -990,8 +986,6 @@ #endif // !USE_OS_TZDB -#if !MISSING_LEAP_SECONDS - class leap_second { private: @@ -1115,8 +1109,6 @@ using leap = leap_second; -#endif // !MISSING_LEAP_SECONDS - #ifdef _WIN32 namespace detail @@ -1162,9 +1154,7 @@ #if !USE_OS_TZDB std::vector links; #endif -#if !MISSING_LEAP_SECONDS std::vector leap_seconds; -#endif #if !USE_OS_TZDB std::vector rules; #endif @@ -1221,31 +1211,31 @@ public: ~tzdb_list(); tzdb_list() = default; - tzdb_list(tzdb_list&& x) noexcept; + tzdb_list(tzdb_list&& x) NOEXCEPT; - const tzdb& front() const noexcept {return *head_;} - tzdb& front() noexcept {return *head_;} + const tzdb& front() const NOEXCEPT {return *head_;} + tzdb& front() NOEXCEPT {return *head_;} class const_iterator; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; + const_iterator begin() const NOEXCEPT; + const_iterator end() const NOEXCEPT; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; + const_iterator cbegin() const NOEXCEPT; + const_iterator cend() const NOEXCEPT; - const_iterator erase_after(const_iterator p) noexcept; + const_iterator erase_after(const_iterator p) NOEXCEPT; struct undocumented_helper; private: - void push_front(tzdb* tzdb) noexcept; + void push_front(tzdb* tzdb) NOEXCEPT; }; class tzdb_list::const_iterator { tzdb* p_ = nullptr; - explicit const_iterator(tzdb* p) noexcept : p_{p} {} + explicit const_iterator(tzdb* p) NOEXCEPT : p_{p} {} public: const_iterator() = default; @@ -1255,20 +1245,20 @@ using pointer = const value_type*; using difference_type = std::ptrdiff_t; - reference operator*() const noexcept {return *p_;} - pointer operator->() const noexcept {return p_;} + reference operator*() const NOEXCEPT {return *p_;} + pointer operator->() const NOEXCEPT {return p_;} - const_iterator& operator++() noexcept {p_ = p_->next; return *this;} - const_iterator operator++(int) noexcept {auto t = *this; ++(*this); return t;} + const_iterator& operator++() NOEXCEPT {p_ = p_->next; return *this;} + const_iterator operator++(int) NOEXCEPT {auto t = *this; ++(*this); return t;} friend bool - operator==(const const_iterator& x, const const_iterator& y) noexcept + operator==(const const_iterator& x, const const_iterator& y) NOEXCEPT {return x.p_ == y.p_;} friend bool - operator!=(const const_iterator& x, const const_iterator& y) noexcept + operator!=(const const_iterator& x, const const_iterator& y) NOEXCEPT {return !(x == y);} friend class tzdb_list; @@ -1276,28 +1266,28 @@ inline tzdb_list::const_iterator -tzdb_list::begin() const noexcept +tzdb_list::begin() const NOEXCEPT { return const_iterator{head_}; } inline tzdb_list::const_iterator -tzdb_list::end() const noexcept +tzdb_list::end() const NOEXCEPT { return const_iterator{nullptr}; } inline tzdb_list::const_iterator -tzdb_list::cbegin() const noexcept +tzdb_list::cbegin() const NOEXCEPT { return begin(); } inline tzdb_list::const_iterator -tzdb_list::cend() const noexcept +tzdb_list::cend() const NOEXCEPT { return end(); } @@ -1328,7 +1318,7 @@ template inline T* -to_raw_pointer(T* p) noexcept +to_raw_pointer(T* p) NOEXCEPT { return p; } @@ -1336,7 +1326,7 @@ template inline auto -to_raw_pointer(Pointer p) noexcept +to_raw_pointer(Pointer p) NOEXCEPT -> decltype(detail::to_raw_pointer(p.operator->())) { return detail::to_raw_pointer(p.operator->()); @@ -1345,12 +1335,24 @@ } // namespace detail template +template +inline +TimeZonePtr2&& +zoned_time::check(TimeZonePtr2&& p) +{ + if (detail::to_raw_pointer(p) == nullptr) + throw std::runtime_error( + "zoned_time constructed with a time zone pointer == nullptr"); + return std::forward(p); +} + +template #if !defined(_MSC_VER) || (_MSC_VER > 1916) template #endif inline zoned_time::zoned_time() - : zone_(zoned_traits::default_zone()) + : zone_(check(zoned_traits::default_zone())) {} template @@ -1359,15 +1361,15 @@ #endif inline zoned_time::zoned_time(const sys_time& st) - : zone_(zoned_traits::default_zone()) + : zone_(check(zoned_traits::default_zone())) , tp_(st) {} template inline zoned_time::zoned_time(TimeZonePtr z) - : zone_(std::move(z)) - {assert(detail::to_raw_pointer(zone_) != nullptr);} + : zone_(check(std::move(z))) + {} #if HAS_STRING_VIEW @@ -1402,7 +1404,7 @@ template inline zoned_time::zoned_time(TimeZonePtr z, const sys_time& st) - : zone_(std::move(z)) + : zone_(check(std::move(z))) , tp_(st) {} @@ -1412,7 +1414,7 @@ #endif inline zoned_time::zoned_time(TimeZonePtr z, const local_time& t) - : zone_(std::move(z)) + : zone_(check(std::move(z))) , tp_(zone_->to_sys(t)) {} @@ -1423,7 +1425,7 @@ inline zoned_time::zoned_time(TimeZonePtr z, const local_time& t, choose c) - : zone_(std::move(z)) + : zone_(check(std::move(z))) , tp_(zone_->to_sys(t, c)) {} @@ -1432,7 +1434,7 @@ inline zoned_time::zoned_time(TimeZonePtr z, const zoned_time& zt) - : zone_(std::move(z)) + : zone_(check(std::move(z))) , tp_(zt.tp_) {} @@ -1847,8 +1849,6 @@ return to_stream(os, fmt, t); } -#if !MISSING_LEAP_SECONDS - class utc_clock { public: @@ -2787,8 +2787,6 @@ return gps_clock::from_utc(tai_clock::to_utc(t)); } -#endif // !MISSING_LEAP_SECONDS - } // namespace date #endif // TZ_H diff -Nru r-cran-rcppdate-0.0.1/inst/include/tz_private.h r-cran-rcppdate-0.0.2/inst/include/tz_private.h --- r-cran-rcppdate-0.0.1/inst/include/tz_private.h 2020-03-15 15:46:12.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/include/tz_private.h 2021-01-03 21:48:32.000000000 +0000 @@ -95,9 +95,9 @@ U& operator=(const pair& x); } u; - std::chrono::hours h_{}; - std::chrono::minutes m_{}; - std::chrono::seconds s_{}; + std::chrono::hours h_{0}; + std::chrono::minutes m_{0}; + std::chrono::seconds s_{0}; tz zone_{tz::local}; public: @@ -245,7 +245,7 @@ sys_seconds until_utc_; local_seconds until_std_; local_seconds until_loc_; - std::chrono::minutes initial_save_{}; + std::chrono::minutes initial_save_{0}; std::string initial_abbrev_; std::pair first_rule_{nullptr, date::year::min()}; std::pair last_rule_{nullptr, date::year::max()}; diff -Nru r-cran-rcppdate-0.0.1/inst/NEWS.Rd r-cran-rcppdate-0.0.2/inst/NEWS.Rd --- r-cran-rcppdate-0.0.1/inst/NEWS.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-rcppdate-0.0.2/inst/NEWS.Rd 2021-01-29 04:46:41.000000000 +0000 @@ -0,0 +1,18 @@ +\name{NEWS} +\title{News for Package \pkg{RcppDate}} +\newcommand{\ghpr}{\href{https://github.com/eddelbuettel/rcppdate/pull/#1}{##1}} +\newcommand{\ghit}{\href{https://github.com/eddelbuettel/rcppdate/issues/#1}{##1}} + +\section{Changes in version 0.0.2 (2021-01-29)}{ + \itemize{ + \item Added GitHub Actions CI via \code{run.sh} from \pkg{r-ci} + \item Updated to upstream version 3.0.0 (plus newer commits) + } +} + +\section{Changes in version 0.0.1 (2020-03-17)}{ + \itemize{ + \item Initial CRAN upload of first version + } +} + diff -Nru r-cran-rcppdate-0.0.1/man/RcppDate-package.Rd r-cran-rcppdate-0.0.2/man/RcppDate-package.Rd --- r-cran-rcppdate-0.0.1/man/RcppDate-package.Rd 2020-03-17 12:50:50.000000000 +0000 +++ r-cran-rcppdate-0.0.2/man/RcppDate-package.Rd 2021-01-29 13:35:19.000000000 +0000 @@ -11,7 +11,7 @@ \examples{ ## see the source files in the examples/ directory of the package ## check for (optional, only in Suggests:) Rcpp, and ensure we are -## but not on Windows as this runs up to the ten second time limit +## not on Windows as this runs up to the ten second time limit if (requireNamespace("Rcpp", quietly=TRUE) && (.Platform$OS.type != "windows")) { Rcpp::sourceCpp(system.file("examples", "year_month_day.cpp", package="RcppDate")) } diff -Nru r-cran-rcppdate-0.0.1/MD5 r-cran-rcppdate-0.0.2/MD5 --- r-cran-rcppdate-0.0.1/MD5 2020-03-24 16:10:02.000000000 +0000 +++ r-cran-rcppdate-0.0.2/MD5 2021-01-29 15:00:05.000000000 +0000 @@ -1,19 +1,20 @@ -2919bee41a27b70d564407354e134001 *ChangeLog -6c220f123311b8c9ae039ea7f9780e8d *DESCRIPTION +67323e4f612905df5777e89ef85f34e1 *ChangeLog +ea191522e061a8fba821a7f0eee471d2 *DESCRIPTION 9fdfeb11f7ddba6f3aab9aaa6b1ac5dd *NAMESPACE -cdcc75a22a4f45d63870b6e7611bb31c *README.md -e05c036197803afc48bec733c6397a05 *build/partial.rdb +fe7190193625cb33c12e26edc1b3f5b3 *README.md +b799d7d7cf16a667dba3837438f179d2 *build/partial.rdb +5fd05e03efa083ea7e5e7fbc51876425 *inst/NEWS.Rd 6f980b10925c8dce4ec316ca2ead7185 *inst/examples/iso_week.cpp c0233285240db68ab5e5aff9cf4092e2 *inst/examples/year_month_day.cpp 17782665d3a7dfe6aa7a03b5a605abf8 *inst/include/chrono_io.h -25d49628c3da8f5a1bb20fc20dba5c29 *inst/include/date.h +ca6b30e39821fa9c23d7d0996293ec82 *inst/include/date.h 080fefc4b8adfe56588960d5bb1ba680 *inst/include/ios.h f78efe7eb3c499caf89584227b94aa11 *inst/include/islamic.h d9079fc1458c23f8eef3d2fe73bf00f9 *inst/include/iso_week.h -2231bc52ee7d38065659b656fa9ef6b2 *inst/include/julian.h -cbdc56a4203bcee23ba75f76de9bb7db *inst/include/ptz.h -cb0ddecd1b4bb235de87dad0968f79ec *inst/include/solar_hijri.h -f4b4f2dbbe021a4de4c40e6064af55b7 *inst/include/tz.h -1d7289010ae58cc7e8752f7ae9822728 *inst/include/tz_private.h -a75464d62052613df1fcb0a1d29db394 *man/RcppDate-package.Rd +deb467d791c426fa65c845647d5dfbd1 *inst/include/julian.h +12de4385f09957cc1fa9e00c3de4a86b *inst/include/ptz.h +81d3207383cfa6f2afd4a2bbbfee7f95 *inst/include/solar_hijri.h +b4177312d77734be9f4e195cd2654e8b *inst/include/tz.h +db5c6aad29600abf9bd4326c0a36755a *inst/include/tz_private.h +61f9d35bd4e83544c7fe780fe96fe3a9 *man/RcppDate-package.Rd b5b571e108a95e91149429515f8f4ed6 *tests/simpleTests.R diff -Nru r-cran-rcppdate-0.0.1/README.md r-cran-rcppdate-0.0.2/README.md --- r-cran-rcppdate-0.0.1/README.md 2020-03-16 02:30:07.000000000 +0000 +++ r-cran-rcppdate-0.0.2/README.md 2021-01-29 13:32:17.000000000 +0000 @@ -2,7 +2,12 @@ ## RcppDate: date C++ header library for R [![Build Status](https://travis-ci.org/eddelbuettel/rcppdate.svg)](https://travis-ci.org/eddelbuettel/rcppdate) +[![CI](https://github.com/eddelbuettel/rcppdate/workflows/ci/badge.svg)](https://github.com/eddelbuettel/rcppdate/actions?query=workflow%3Aci) [![License](https://eddelbuettel.github.io/badges/GPL2+.svg)](http://www.gnu.org/licenses/gpl-2.0.html) +[![CRAN](http://www.r-pkg.org/badges/version/RcppDate)](https://cran.r-project.org/package=RcppDate) +[![Dependencies](https://tinyverse.netlify.com/badge/RcppDate)](https://cran.r-project.org/package=RcppDate) +[![Downloads](https://cranlogs.r-pkg.org/badges/RcppDate?color=brightgreen)](https://www.r-pkg.org/pkg/RcppDate) +[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/rcppdate)](https://github.com/eddelbuettel/rcppdate) ### About @@ -25,7 +30,7 @@ constexpr auto x3 = 22_d/March/2015; ``` -See the file [inst/examples/year_month_day.cpp](inst/examples/year_month_day.cpp) for +See the file [inst/examples/year_month_day.cpp](inst/examples/year_month_day.cpp) for the complete example, and the upstream documentation for full details. ### Limitations