Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/library/base/R/dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ seq.Date <- function(from, to, by, length.out = NULL, along.with = NULL, ...)
if(is.na(by)) stop("'by' is NA")

res <- switch(missing_arg,
from = seq.int(to = unclass(to), by = by, length.out = length.out),
to = seq.int(from = unclass(from), by = by, length.out = length.out),
length.out = seq.int(from = unclass(from), to = unclass(to), by = by)
from = seq.int(to = unclass(as.Date(to)), by = by, length.out = length.out),
to = seq.int(from = unclass(as.Date(from)), by = by, length.out = length.out),
length.out = seq.int(from = unclass(as.Date(from)), to = unclass(as.Date(to)), by = by)
)
.Date(res)
}
Expand Down
14 changes: 13 additions & 1 deletion tests/datetime3.R
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,19 @@ identicalPlt <- function(x, y, ...)
stopifnot(identicalPlt(z1, z), identicalPlt(z2, z))
## failed previously, incl in rev 88441


## strings in one argument of seq.Date always get coerced
from_str <- "2025-01-01"; to_str <- "2025-01-07"
full_seq <- seq(as.Date(from_str), as.Date(to_str))
stopifnot(exprs = {
identical(seq(as.Date(from_str), to_str), full_seq)
identical(seq(as.Date(from_str), to_str, by=1L), full_seq)
identical(seq(as.Date(from_str), to_str, length.out=7L), full_seq)
identical(seq(to=as.Date(to_str), length.out=7L, by=1L), full_seq)
identical(seq(from=as.Date(from_str), length.out=7L, by=1L), full_seq)
identical(seq(to=as.Date(to_str), from_str), full_seq)
identical(seq(to=as.Date(to_str), from_str, by=1L), full_seq)
identical(seq(to=as.Date(to_str), from_str, length.out=7L), full_seq)
})

## keep at end
rbind(last = proc.time() - .pt,
Expand Down
Loading