Skip to content

Commit 6d5b0f1

Browse files
committed
0.4 : add inUTC in getMoonTimes
1 parent 8bb2765 commit 6d5b0f1

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: suncalc
2-
Version: 0.3
3-
Date: 2017-10-04
2+
Version: 0.4
3+
Date: 2018-02-22
44
Title: Compute Sun Position, Sunlight Phases, Moon Position and Lunar Phase
55
Authors@R: c(
66
person("Vladimir", "Agafonkin", role = c("aut", "cph"),

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# suncalc 0.4 (2018-02-22)
2+
3+
## Bugfixes
4+
* Dates with times before a certain time return times for previous day. See https://github.com/mourner/suncalc/issues/11
5+
16
# suncalc 0.3 (2017-10-04)
27

38
## Bugfixes

R/getMoonTimes.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#' @param data : \code{data.frame}. Alternative to use \code{date}, \code{lat}, \code{lon} for passing multiple coordinates
77
#' @param keep : \code{character}. Vector of variables to keep. See \code{Details}
88
#' @param tz : \code{character}. timezone of results
9+
#' @param inUTC : \code{logical}. By default, it will search for moon rise and set during local user's day (from 0 to 24 hours). If TRUE, it will instead search the specified date from 0 to 24 UTC hours.
910
#'
1011
#' @return \code{data.frame}
1112
#'
@@ -46,7 +47,7 @@
4647
#'
4748
getMoonTimes <- function(date = NULL, lat = NULL, lon = NULL, data = NULL,
4849
keep = c("rise", "set", "alwaysUp", "alwaysDown"),
49-
tz = "UTC"){
50+
tz = "UTC", inUTC = FALSE){
5051

5152

5253
# data control
@@ -56,7 +57,7 @@ getMoonTimes <- function(date = NULL, lat = NULL, lon = NULL, data = NULL,
5657
stop("date must to be a Date object (class Date)")
5758
}
5859

59-
data$date <- paste0(data$date, " 12:00:00")
60+
# data$date <- paste0(data$date, " 12:00:00")
6061

6162
# variable control
6263
available_var <- c("rise", "set", "alwaysUp", "alwaysDown")
@@ -74,7 +75,8 @@ getMoonTimes <- function(date = NULL, lat = NULL, lon = NULL, data = NULL,
7475
mat_res$alwaysDown <- FALSE
7576
add_res <- lapply(1:nrow(mat_res), function(x){
7677
ct$eval(paste0("var tmp_res = SunCalc.getMoonTimes(new Date('",
77-
data[x, "date"], "'),", data[x, "lat"], ", ", data[x, "lon"], ", true);"))
78+
data[x, "date"], "'),", data[x, "lat"], ", ",
79+
data[x, "lon"], ",", tolower(inUTC), ");"))
7880

7981
tmp_res <- unlist(ct$get("tmp_res"))
8082
mat_res[x, names(tmp_res)] <<- tmp_res

man/getMoonTimes.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)