Skip to content

Commit

Permalink
0.4 : add inUTC in getMoonTimes
Browse files Browse the repository at this point in the history
  • Loading branch information
bthieurmel committed Feb 22, 2018
1 parent 8bb2765 commit 6d5b0f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: suncalc
Version: 0.3
Date: 2017-10-04
Version: 0.4
Date: 2018-02-22
Title: Compute Sun Position, Sunlight Phases, Moon Position and Lunar Phase
Authors@R: c(
person("Vladimir", "Agafonkin", role = c("aut", "cph"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# suncalc 0.4 (2018-02-22)

## Bugfixes
* Dates with times before a certain time return times for previous day. See https://github.com/mourner/suncalc/issues/11

# suncalc 0.3 (2017-10-04)

## Bugfixes
Expand Down
8 changes: 5 additions & 3 deletions R/getMoonTimes.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param data : \code{data.frame}. Alternative to use \code{date}, \code{lat}, \code{lon} for passing multiple coordinates
#' @param keep : \code{character}. Vector of variables to keep. See \code{Details}
#' @param tz : \code{character}. timezone of results
#' @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.
#'
#' @return \code{data.frame}
#'
Expand Down Expand Up @@ -46,7 +47,7 @@
#'
getMoonTimes <- function(date = NULL, lat = NULL, lon = NULL, data = NULL,
keep = c("rise", "set", "alwaysUp", "alwaysDown"),
tz = "UTC"){
tz = "UTC", inUTC = FALSE){


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

data$date <- paste0(data$date, " 12:00:00")
# data$date <- paste0(data$date, " 12:00:00")

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

tmp_res <- unlist(ct$get("tmp_res"))
mat_res[x, names(tmp_res)] <<- tmp_res
Expand Down
5 changes: 4 additions & 1 deletion man/getMoonTimes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d5b0f1

Please sign in to comment.