Skip to content

Commit

Permalink
Fix compiler %ld warning
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Jan 17, 2024
1 parent 9f7c564 commit 110f222
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 5 additions & 4 deletions R/round.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,13 @@ time_round <- function(time, unit = "second",
## return(from_posixlt(out, time, force_date = unit != "hour"))
## }

## Behavior or this logic is different from the base rounding for repeated times
## because timechange operates on clock time but round.POSIXt on absolute time. Thus
## Behavior here is different from the base rounding for repeated times because
## timechange operates on clock time but round.POSIXt on absolute time. Thus
## time_ceiling("2014-11-02 01:35:00 EDT", "hour") is "2014-11-02 02:00:00 EST", 1h25m
## difference. But round.POSIXt("2014-11-02 01:35:00 EDT", "hour") is "2014-11-02
## 01:00:00 EST" which always results in clock hour <= than the original clock hour.
## Rounding on absolute time can be achieved with absolute units - asec, amin, ahour.
## 01:00:00 EST" which always results in clock hour <= than the original clock
## hour. Rounding on absolute time can be achieved with absolute units - asec, amin,
## ahour.
above <- unclass(C_time_ceiling(ct, unit, n, week_start, TRUE, origin))
mid <- unclass(ct)
below <- unclass(C_time_floor(ct, unit, n, week_start, origin))
Expand Down
1 change: 0 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CXX_STD = CXX11
PKG_CPPFLAGS= -I. -I./cctz/src/
PKG_LIBS= -L. -lcctz

Expand Down
6 changes: 3 additions & 3 deletions src/round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ cpp11::writable::doubles C_time_ceiling(const cpp11::doubles dt,

bool loop_origin = origin.size() != 1;
if (loop_origin && origin.size() != dt.size()) {
Rf_error("`origin` length (%ld) must be either 1 or the same as the length of the input date-time (%ld)\n",
Rf_error("`origin` length (%lld) must be either 1 or the same as the length of the input date-time (%lld)\n",
origin.size(), dt.size());
}

Expand Down Expand Up @@ -284,7 +284,7 @@ cpp11::writable::doubles C_time_floor(const cpp11::doubles dt,

bool loop_origin = origin.size() != 1;
if (loop_origin && origin.size() != dt.size()) {
Rf_error("`origin` length (%ld) must be either 1 or the same as the length of the input date-time (%ld)\n",
Rf_error("`origin` length (%lld) must be either 1 or the same as the length of the input date-time (%lld)\n",
origin.size(), dt.size());
}

Expand Down Expand Up @@ -316,7 +316,7 @@ cpp11::writable::doubles C_time_floor(const cpp11::doubles dt,
double ds = floor_multi_unit(cs.second() + rem, N);
int_fast64_t is = static_cast<int_fast64_t>(ds);
rem = ds - is;
/* Rprintf("dsec:%f isec%f rem:%f ds:%f is:%ld\n", dsecs, isecs, ds, is); */
/* Rprintf("dsec:%f isec%f rem:%f ds:%f is:%lld\n", dsecs, isecs, ds, is); */
cctz::civil_second ct = cctz::civil_second(cctz::civil_minute(cs)) + is;
out[i] = ct2posix4floor(ct, tz, tp, cs, rem);
break;
Expand Down

0 comments on commit 110f222

Please sign in to comment.