Skip to content

Commit

Permalink
Tell user how to disable 'xts_check_TZ' warning
Browse files Browse the repository at this point in the history
This warning can be annoying, and it's not clear how to disable it.
Add a message, once per session, to tell the user how to disable
the warning.

See #113.
  • Loading branch information
joshuaulrich committed Feb 5, 2022
1 parent 2c9caec commit f58fceb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions R/tzone.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ isUTC <- function(tz = NULL) {

check.TZ <- function(x, ...)
{
#if( !getOption("xts_check_TZ", FALSE))
# return()
check <- getOption("xts_check_TZ")
if( !is.null(check) && !check)
return()
Expand All @@ -126,8 +124,17 @@ check.TZ <- function(x, ...)
return()
}
if(!is.null(tzone(x)) && tzone(x) != "" &&
!identical(STZ, as.character(tzone(x))))
!identical(STZ, as.character(tzone(x)))) {
warning(paste("timezone of object (",tzone(x),
") is different than current timezone (",STZ,").",sep=""),
call.=FALSE)
call.=FALSE, immediate.=TRUE)

if(is.null(check)) {
# xts_check_TZ is NULL by default
# set to TRUE after messaging user how to disable the warning
message("NOTE: set 'options(xts_check_TZ = FALSE)' to disable this warning\n",
" This note is displayed once per session")
options(xts_check_TZ = TRUE)
}
}
}

0 comments on commit f58fceb

Please sign in to comment.