Showing 1 of 13 files from the diff.
Other files ignored by Codecov

@@ -137,16 +137,18 @@
Loading
137 137
  reclass_date(new, object)
138 138
}
139 139
140 -
#' Roll back date to last day of previous month
140 +
#' Roll backward or forward a date the previous, current or next month
141 141
#'
142 -
#' rollback changes a date to the last day of the previous month or to the first
143 -
#' day of the month. Optionally, the new date can retain the same hour, minute,
144 -
#' and second information.
142 +
#' `rollbackward()` changes a date to the last day of the previous month or to
143 +
#' the first day of the month. `rollforward()` rolls to the last day of the
144 +
#' current month or to the first day of the next month. Optionally, the new date
145 +
#' can retain the same hour, minute, and second information. `rollback()` is a
146 +
#' synonym for `rollbackward()`.
145 147
#'
146 148
#' @export
147 149
#' @param dates A POSIXct, POSIXlt or Date class object.
148 150
#' @param roll_to_first Rollback to the first day of the month instead of the
149 -
#' last day of the previous month
151 +
#' last day of the month
150 152
#' @param preserve_hms Retains the same hour, minute, and second information? If
151 153
#' FALSE, the new date will be at 00:00:00.
152 154
#' @return A date-time object of class POSIXlt, POSIXct or Date, whose day has
@@ -154,17 +156,31 @@
Loading
154 156
#' the month.
155 157
#' @examples
156 158
#' date <- ymd("2010-03-03")
157 -
#' rollback(date)
159 +
#' rollbackward(date)
158 160
#'
159 161
#' dates <- date + months(0:2)
160 -
#' rollback(dates)
162 +
#' rollbackward(dates)
161 163
#'
162 164
#' date <- ymd_hms("2010-03-03 12:44:22")
163 -
#' rollback(date)
164 -
#' rollback(date, roll_to_first = TRUE)
165 -
#' rollback(date, preserve_hms = FALSE)
166 -
#' rollback(date, roll_to_first = TRUE, preserve_hms = FALSE)
167 -
rollback <- function(dates, roll_to_first = FALSE, preserve_hms = TRUE) {
165 +
#' rollbackward(date)
166 +
#' rollbackward(date, roll_to_first = TRUE)
167 +
#' rollbackward(date, preserve_hms = FALSE)
168 +
#' rollbackward(date, roll_to_first = TRUE, preserve_hms = FALSE)
169 +
rollbackward <- function(dates, roll_to_first = FALSE, preserve_hms = TRUE) {
170 +
  .roll(dates, roll_to_first, preserve_hms)
171 +
}
172 +
173 +
#' @rdname rollbackward
174 +
#' @export
175 +
rollback <- rollbackward
176 +
177 +
#' @rdname rollbackward
178 +
#' @export
179 +
rollforward <- function(dates, roll_to_first = FALSE, preserve_hms = TRUE) {
180 +
  .roll(dates, roll_to_first, preserve_hms, forward = TRUE)
181 +
}
182 +
183 +
.roll <- function(dates, roll_to_first, preserve_hms, forward = FALSE) {
168 184
  if (length(dates) == 0)
169 185
    return(dates)
170 186
  day(dates) <- 1
@@ -173,6 +189,9 @@
Loading
173 189
    minute(dates) <- 0
174 190
    second(dates) <- 0
175 191
  }
192 +
  if (forward) {
193 +
    dates <- dates + months(1)
194 +
  }
176 195
  if (roll_to_first) {
177 196
    dates
178 197
  } else {
Files Coverage
R 79.09%
src 71.99%
Project Totals (64 files) 75.90%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading