Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timezone warning message #113

Closed
algoquant opened this issue Sep 12, 2015 · 6 comments
Closed

timezone warning message #113

algoquant opened this issue Sep 12, 2015 · 6 comments
Milestone

Comments

@algoquant
Copy link

I'm getting a strange timezone warning message for an xts that does have the correct timezone:

> Sys.timezone()
[1] "America/New_York"
> foo <- xts(x=rnorm(100), order.by=seq(Sys.time(), by="min", length.out=100), tzone=Sys.timezone())
> tzone(foo)
[1] "America/New_York"
> head(foo, 3)
                      [,1]
2015-09-12 16:52:14  0.2673088
2015-09-12 16:53:14  1.1783536
2015-09-12 16:54:14  0.6240479
Warning message:
timezone of object (America/New_York) is different than current timezone (). 

But when I set the timezone to NULL, then there's no warning:

> tzone(foo) <- NULL
> tzone(foo)
TZ 
""
> head(foo, 3)
                      [,1]
2015-09-12 16:52:14  0.2673088
2015-09-12 16:53:14  1.1783536
2015-09-12 16:54:14  0.6240479

I realize that I can suppress the warning by setting:

options(xts_check_TZ=FALSE)

But I would prefer to understand the problem better instead of sweeping it under the rug, in case it may have some consequences.

Here's my setup:

sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
other attached packages:
[1] xts_0.9.874 zoo_1.7-12

@joshuaulrich
Copy link
Owner

I can't replicate this on my Ubuntu machine with 0.9-7 from CRAN, 0.9.874 from the master branch, or 0.9-8 from the develop branch. I can try on a Windows machine tomorrow. Can you try with the head of the develop branch to see if it's still an issue there?

@algoquant
Copy link
Author

I installed xts from the develop branch, but I still got the same warning. I also upgraded R to version 3.2.2, and got the same warning as before. My current setup is:

R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
other attached packages:
[1] xts_0.9-8 zoo_1.7-12

Maybe it's just time for me to switch from Windoze to Linux, finally.

@joshuaulrich
Copy link
Owner

I can replicate this on my Windows machine. It looks like there might have been changes in R-3.0.3 and/or R-3.1.0. I'll install those and investigate.

R> news(grepl("Sys.timezone", Text))
Changes in version 3.1.0:

NEW FEATURES

    o   There is more support to explore the system's idea of time-zone
    names.  Sys.timezone() tries to give the current system setting by
    name (and succeeds at least on Linux, OS X, Solaris and Windows),
    and OlsonNames() lists the names in the system's Olson database.
    Sys.timezone(location = FALSE) gives the previous behaviour.

Changes in version 3.0.3:

NEW FEATURES

    o   On a Unix-alike Sys.timezone() returns NA if the environment
    variable TZ is unset, to distinguish it from an empty string which
    on some OSes means the UTC time zone.

The relevant change was in R-3.1.0. Prior to that, Sys.timezone only returned the timezone abbreviation on Windows (what you see now from Sys.timezone(FALSE)). If you want to avoid the warning, you need to set the TZ environment variable to a valid timezone. For example:

Sys.setenv(TZ=Sys.timezone())

@joshuaulrich
Copy link
Owner

@algoquant did you close this because it's no longer an issue?

@algoquant
Copy link
Author

@joshuaulrich
I still get the Warning message:
timezone of object (America/New_York) is different than current timezone ().

I recently got this Warning on MacOS x86_64-apple-darwin17.0 with R version 4.1.1. Before that I got it on Windows.

But your suggestion to run: Sys.setenv(TZ=Sys.timezone()) fixes it, so that's why I closed the issue. I can reopen it if you think it's worth pursuing.

@joshuaulrich
Copy link
Owner

Thanks for the quick reply! I just had an idea: On the first warning of the session, I could add to the message something like "set options(xts_check_TZ=FALSE) to disable this warning". Setting that option will suppress the warning. What do you think of that?

joshuaulrich added a commit that referenced this issue Feb 5, 2022
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.
@joshuaulrich joshuaulrich added this to the 0.12.2 milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants