Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct sec + nanosec conversion (closes #12) #14

Merged
merged 1 commit into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2017-01-27 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor release and date

* src/utilities.cpp (parseDouble): Correct conversion to seconds
and nanoseconds as suggested by Leonardo Silvestri in #12

2017-01-08 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Release 0.2.0
Expand Down
44 changes: 22 additions & 22 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Package: RcppCCTZ
Type: Package
Title: 'Rcpp' Bindings for the 'CCTZ' Library
Version: 0.2.0
Date: 2017-01-08
Author: Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: 'Rcpp' Access to the 'CCTZ' timezone library is provided. 'CCTZ' is
a C++ library for translating between absolute and civil times using the rules
of a time zone. The 'CCTZ' source code, released under the Apache 2.0 License,
is included in this package. See <https://github.com/google/cctz> for more
details.
License: GPL (>= 2)
Imports: Rcpp (>= 0.11.0)
LinkingTo: Rcpp
SystemRequirements: A 64-bit POSIX OS such as Linux or OS X with IANA time
zone data in /usr/share/zoneinfo as well as a C++11 compiler. On Windows
the zoneinfo included with R is used; and time parsing support is enabled
via a backport of std::get_time from the LLVM libc++.
URL: https://github.com/eddelbuettel/rcppcctz
BugReports: https://github.com/eddelbuettel/rcppcctz/issues
RoxygenNote: 5.0.1
Package: RcppCCTZ
Type: Package
Title: 'Rcpp' Bindings for the 'CCTZ' Library
Version: 0.2.0.1
Date: 2017-01-08
Author: Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: 'Rcpp' Access to the 'CCTZ' timezone library is provided. 'CCTZ' is
a C++ library for translating between absolute and civil times using the rules
of a time zone. The 'CCTZ' source code, released under the Apache 2.0 License,
is included in this package. See <https://github.com/google/cctz> for more
details.
License: GPL (>= 2)
Imports: Rcpp (>= 0.11.0)
LinkingTo: Rcpp
SystemRequirements: A 64-bit POSIX OS such as Linux or OS X with IANA time
zone data in /usr/share/zoneinfo as well as a C++11 compiler. On Windows
the zoneinfo included with R is used; and time parsing support is enabled
via a backport of std::get_time from the LLVM libc++.
URL: https://github.com/eddelbuettel/rcppcctz
BugReports: https://github.com/eddelbuettel/rcppcctz/issues
RoxygenNote: 5.0.1
4 changes: 2 additions & 2 deletions src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ Rcpp::NumericMatrix parseDouble(Rcpp::CharacterVector svec,
if (!cctz::parse(fmt, txt, tz, &tp)) Rcpp::stop("Parse error on %s", txt);

auto nanoseconds = (tp - unix_epoch).count();
double secs = std::trunc(nanoseconds / 1.0e9);
auto nanos = nanoseconds - static_cast<int64_t>(secs * 1e9);
auto secs = nanoseconds / 1000000000;
auto nanos = nanoseconds - secs * 1000000000;
//Rcpp::Rcout << nanoseconds << " " << secs << " " << nanos << std::endl;
dm(i, 0) = secs;
dm(i, 1) = nanos;
Expand Down