Skip to content

with_tz() warns about invalid timezones, but returns them correctly anyway #602

@steffilazerte

Description

@steffilazerte

This is a problem I've noticed on Windows only (not my Ubuntu machine). The warnings are also popping up in the AppVeyor tests (but not on Travis CI for Ubuntu and Mac).

I think it's only in lubridate v0.7.0 (related to c10c8cf) but I had problems trying to install v0.6.0 to double check.

with_tz() warns about invalid timezones, but returns them correctly anyway...

> Sys.time()
[1] "2017-11-02 00:17:10 AST"

> lubridate::with_tz(Sys.time(), "UTC")
[1] "2017-11-02 04:17:26"

> lubridate::with_tz(Sys.time(), "America/Vancouver")
[1] "2017-11-01 21:17:28 PDT"
Warning message:
In lubridate::with_tz(Sys.time(), "America/Vancouver") :
  Unrecognized time zone 'America/Vancouver'

> lubridate::with_tz(Sys.time(), "Etc/GMT+8")
[1] "2017-11-01 20:18:25 -08"
Warning message:
In lubridate::with_tz(Sys.time(), "Etc/GMT+8") :
  Unrecognized time zone 'Etc/GMT+8'

If I try a non-legitimate name I get a second warning message (and UTC):

> lubridate::with_tz(Sys.time(), "America/Van")
[1] "2017-11-02 04:41:31 GMT"
Warning messages:
1: In lubridate::with_tz(Sys.time(), "America/Van") :
  Unrecognized time zone 'America/Van'
2: In as.POSIXlt.POSIXct(x, tz) : unknown timezone "America/Van"

The first two are both legitimate timezones (i.e. they're in OlsonNames())

> OlsonNames()[OlsonNames() == "America/Vancouver"]
[1] "America/Vancouver"

> OlsonNames()[OlsonNames() == "Etc/GMT+8"]
[1] "Etc/GMT+8"

> OlsonNames()[OlsonNames() == "America/Van"]
character(0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions