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

unknown timezone error #615

Closed
jeremy-allen opened this Issue Nov 28, 2017 · 17 comments

Comments

Projects
None yet
5 participants
@jeremy-allen

jeremy-allen commented Nov 28, 2017

> library(lubridate)
> ymd_hms("2017-11-28 16:30:30")
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'

From one of your previous comments I saw that I should uninstall lubridate and Rcpp. I did, and then I reinstalled from CRAN just now and got the error above.

My session info:

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.7.1 knitr_1.17      tufte_0.2      

loaded via a namespace (and not attached):
 [1] compiler_3.4.2  backports_1.1.1 magrittr_1.5    rprojroot_1.2   htmltools_0.3.6
 [6] tools_3.4.2     yaml_2.1.14     Rcpp_0.12.14    stringi_1.1.6   rmarkdown_1.8  
[11] stringr_1.2.0   digest_0.6.12   evaluate_0.10.1

as.POSIXct does

> as.POSIXct("2017-11-28 16:30:30")
[1] "2017-11-28 16:30:30"
@vspinu

This comment has been minimized.

Member

vspinu commented Nov 29, 2017

Could you please post the full traceback?

@jeremy-allen

This comment has been minimized.

jeremy-allen commented Nov 29, 2017

> library(lubridate)
> ymd_hms("2018-11-28 19:50:30")
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'
> traceback()
19: doWithOneRestart(return(expr), restart)
18: withOneRestart(expr, restarts[[1L]])
17: withRestarts({
        .Internal(.signalCondition(simpleWarning(msg, call), msg, 
            call))
        .Internal(.dfltWarn(msg, call))
    }, muffleWarning = function() NULL)
16: .signalSimpleWarning("unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'", 
        quote(as.POSIXlt.POSIXct(x, tz)))
15: as.POSIXlt.POSIXct(x, tz)
14: as.POSIXlt(x, tz)
13: format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...)
12: structure(format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...), 
        names = names(x))
11: format.POSIXct(.date_template, format = format)
10: format(.date_template, format = format)
9: unique(format(.date_template, format = format))
8: .get_locale_regs(locale)
7: guess_formats(x, orders, locale = locale, preproc_wday = TRUE)
6: unique(guess_formats(x, orders, locale = locale, preproc_wday = TRUE))
5: .best_formats(train, orders, locale = locale, select_formats, 
       drop = drop)
4: .local_parse(x[to_parse], TRUE)
3: parse_date_time(dates, orders, tz = tz, quiet = quiet, locale = locale)
2: .parse_xxx_hms(..., orders = c("ymdTz", "ymdT"), quiet = quiet, 
       tz = tz, locale = locale, truncated = truncated)
1: ymd_hms("2018-11-28 19:50:30")

Session info this time

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.7.1 knitr_1.17      tufte_0.2      

loaded via a namespace (and not attached):
[1] compiler_3.4.2  magrittr_1.5    htmltools_0.3.6 tools_3.4.2     yaml_2.1.14    
[6] Rcpp_0.12.14    stringi_1.1.6   stringr_1.2.0   digest_0.6.12  
@vspinu

This comment has been minimized.

Member

vspinu commented Dec 5, 2017

I am sorry. I cannot rack this one. The error occurs in functions which were not changed for years (.get_locale_regs()).

If you call .get_locale_regs() directly do you see the same error?

Judging from the traceback the error occurs in

format(lubridate:::.date_template, format = "%a@%A@%b@%B@%p@")

which is pure R call. Would you be so kind to check if those calls throw? Thanks!

@jeremy-allen

This comment has been minimized.

jeremy-allen commented Dec 5, 2017

format(lubridate:::.date_template, format = "%a@%A@%b@%B@%p@") seems to work, but .get_local_regs() throws a different error:

> library(lubridate)

Attaching package: ‘lubridate’

The following object is masked from ‘package:base’:

    date

> ymd_hms("2017-12-05 14:34:01")
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'
> .get_locale_regs()
Error in .get_locale_regs() : could not find function ".get_locale_regs"
> get_locale_regs()
Error in get_locale_regs() : could not find function "get_locale_regs"
> format(lubridate:::.date_template, format = "%a@%A@%b@%B@%p@")
 [1] "Thu@Thursday@Jan@January@AM@"  "Mon@Monday@Feb@February@PM@"  
 [3] "Tue@Tuesday@Mar@March@AM@"     "Sun@Sunday@Apr@April@PM@"     
 [5] "Fri@Friday@May@May@AM@"        "Tue@Tuesday@Jun@June@PM@"     
 [7] "Fri@Friday@Jul@July@AM@"       "Wed@Wednesday@Aug@August@PM@" 
 [9] "Tue@Tuesday@Sep@September@AM@" "Fri@Friday@Oct@October@PM@"   
[11] "Tue@Tuesday@Nov@November@AM@"  "Sat@Saturday@Dec@December@PM@"

Session info:

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.7.1

loaded via a namespace (and not attached):
[1] compiler_3.4.2 magrittr_1.5   tools_3.4.2    yaml_2.1.14    Rcpp_0.12.14   stringi_1.1.6 
[7] stringr_1.2.0 
@vspinu

This comment has been minimized.

Member

vspinu commented Dec 6, 2017

.get_local_regs() is an internal function and should be called as lubridate:::.get_local_regs()

@jeremy-allen

This comment has been minimized.

jeremy-allen commented Dec 6, 2017

Sorry about that. Here you go.

> library(lubridate)

Attaching package: ‘lubridate’

The following object is masked from ‘package:base’:

    date

> ymd_hms("2017-12-06 08:08:01")
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'
> lubridate::.get_locale_regs()
Error: '.get_locale_regs' is not an exported object from 'namespace:lubridate'
> traceback()
3: stop(gettextf("'%s' is not an exported object from 'namespace:%s'", 
       name, getNamespaceName(ns)), call. = FALSE, domain = NA)
2: getExportedValue(pkg, name)
1: lubridate::.get_locale_regs
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.7.1

loaded via a namespace (and not attached):
[1] compiler_3.4.2 magrittr_1.5   tools_3.4.2    yaml_2.1.14    Rcpp_0.12.14   stringi_1.1.6 
[7] stringr_1.2.0 
@vspinu

This comment has been minimized.

Member

vspinu commented Dec 6, 2017

It's an internal function you should use ::: (three :) - lubridate:::.get_locale_regs(). I made a typo in my last post. Sorry about that.

@jeremy-allen

This comment has been minimized.

jeremy-allen commented Dec 6, 2017

No worries.
Interesting response this time. ymd_hms fails as usual, but succeeds after I called lubridate:::.get_locale_regs()

> ymd_hms("2017-12-06 08:08:01")
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Denver'
> lubridate:::.get_locale_regs()
$alpha_flex
                                                                                                                                                                       b 
"((?<b_b>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)|(?<B_b>January|February|March|April|May|June|July|August|September|October|November|December))(?![[:alpha:]])" 
                                                                                                                                                                       B 
                                                          "(?<B_B>January|February|March|April|May|June|July|August|September|October|November|December)(?![[:alpha:]])" 
                                                                                                                                                                       a 
                                                 "((?<a_a>Thu|Mon|Tue|Sun|Fri|Wed|Sat)|(?<A_a>Thursday|Monday|Tuesday|Sunday|Friday|Wednesday|Saturday))(?![[:alpha:]])" 
                                                                                                                                                                       A 
                                                                                       "(?<A_A>Thursday|Monday|Tuesday|Sunday|Friday|Wednesday|Saturday)(?![[:alpha:]])" 
                                                                                                                                                                      Ou 
                                                                                                                                            "(?<Ou_Ou>Z)(?![[:alpha:]])" 
                                                                                                                                                                       p 
                                                                                                                                            "(?<p>AM|PM)(?![[:alpha:]])" 

$num_flex
                                                                                                                                                                                                                                                  d 
                                                                                                                                                                                                             "(?<d>[012]?[1-9]|3[01]|[12]0)(?!\\d)" 
                                                                                                                                                                                                                                                  q 
                                                                                                                                                                                                                           "(?<q>[0]?[1-4])(?!\\d)" 
                                                                                                                                                                                                                                                  H 
                                                                                                                                                                                                                     "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  h 
                                                                                                                                                                                                                     "(?<H>2[0-4]|[01]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  I 
                                                                                                                                                                                                                      "(?<I>1[0-2]|0?[1-9])(?!\\d)" 
                                                                                                                                                                                                                                                  j 
                                                                                                                                                                                                                       "(?<j>[0-3]?\\d?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  M 
                                                                                                                                                                                                                           "(?<M>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  S 
                                                                                                                                                                                               "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                  s 
                                                                                                                                                                                               "((?<OS_S>[0-5]?\\d\\.\\d+)|(?<S>[0-6]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                  U 
                                                                                                                                                                                                                           "(?<U>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  w 
                                                                                                                                                                                                                               "(?<w>[0-6])(?!\\d)" 
                                                                                                                                                                                                                                                  u 
                                                                                                                                                                                                                               "(?<u>[1-7])(?!\\d)" 
                                                                                                                                                                                                                                                  W 
                                                                                                                                                                                                                           "(?<W>[0-5]?\\d)(?!\\d)" 
                                                                                                                                                                                                                                                  Y 
                                                                                                                                                                                                                              "(?<Y>\\d{4})(?!\\d)" 
                                                                                                                                                                                                                                                  y 
                                                                                                                                                                                                             "((?<Y_y>\\d{4})|(?<y>\\d{2}))(?!\\d)" 
                                                                                                                                                                                                                                                 Oz 
                                                                                                                                                                                                                      "(?<Oz_Oz>[-+]\\d{4})(?!\\d)" 
                                                                                                                                                                                                                                                 OO 
                                                                                                                                                                                                                  "(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)" 
                                                                                                                                                                                                                                                 Oo 
                                                                                                                                                                                                                         "(?<Oo>[-+]\\d{2})(?!\\d)" 
                                                                                                                                                                                                                                                  T 
"(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D+((?<OS_s_T_S>[0-5]?\\d\\.\\d+)|(?<S_s_T>[0-6]?\\d))\\D*(?<p_s>AM|PM)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)\\D+((?<OS_s_S>[0-5]?\\d\\.\\d+)|(?<S_s>[0-6]?\\d))))(?!\\d)" 
                                                                                                                                                                                                                                                  R 
                                                                                                          "(((?<I_s>1[0-2]|0?[1-9])\\D+(?<M_s_T>[0-5]?\\d)\\D*(?<p_s>AM|PM)(?![[:alpha:]]))|((?<H_s>2[0-4]|[01]?\\d)\\D+(?<M_s>[0-5]?\\d)))(?!\\d)" 
                                                                                                                                                                                                                                                  r 
                                                                                                                                                        "(((?<I_s>1[0-2]|0?[1-9])\\D*(?<p_s>AM|PM)(?![[:alpha:]]))|(?<H_s>2[0-4]|[01]?\\d))(?!\\d)" 
                                                                                                                                                                                                                                                  m 
                                           "((?<m>1[0-2]|0?[1-9](?!\\d))|(((?<b_m>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)|(?<B_m>January|February|March|April|May|June|July|August|September|October|November|December))(?![[:alpha:]])))" 
                                                                                                                                                                                                                                                 OS 
                                                                                                                                                                                                                         "(?<OS_f>[0-5]\\d\\.\\d+)" 
                                                                                                                                                                                                                                                  z 
                                                                                                                                "((?<Ou_Ou>Z)(?![[:alpha:]])|(?<Oz_Oz>[-+]\\d{4})(?!\\d)|(?<OO>[-+]\\d{2}:\\d{2})(?!\\d)|(?<Oo>[-+]\\d{2})(?!\\d))" 

$alpha_exact
                                                                                                                                                                           b 
"((?<b_b_e>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)|(?<B_b_e>January|February|March|April|May|June|July|August|September|October|November|December))(?![[:alpha:]])" 
                                                                                                                                                                           B 
                                                            "(?<B_B_e>January|February|March|April|May|June|July|August|September|October|November|December)(?![[:alpha:]])" 
                                                                                                                                                                           a 
                                                 "((?<a_a_e>Thu|Mon|Tue|Sun|Fri|Wed|Sat)|(?<A_a_e>Thursday|Monday|Tuesday|Sunday|Friday|Wednesday|Saturday))(?![[:alpha:]])" 
                                                                                                                                                                           A 
                                                                                         "(?<A_A_e>Thursday|Monday|Tuesday|Sunday|Friday|Wednesday|Saturday)(?![[:alpha:]])" 
                                                                                                                                                                          Ou 
                                                                                                                                              "(?<Ou_Ou_e>Z)(?![[:alpha:]])" 
                                                                                                                                                                           p 
                                                                                                                                              "(?<p_e>AM|PM)(?![[:alpha:]])" 

$num_exact
                                                                                                                                                                                                                                                     d 
                                                                                                                                                                                                                      "(?<d_e>[012][1-9]|3[01]|[12]0)" 
                                                                                                                                                                                                                                                     q 
                                                                                                                                                                                                                                    "(?<q_e>[0][1-4])" 
                                                                                                                                                                                                                                                     H 
                                                                                                                                                                                                                              "(?<H_e>2[0-4]|[01]\\d)" 
                                                                                                                                                                                                                                                     h 
                                                                                                                                                                                                                              "(?<H_e>2[0-4]|[01]\\d)" 
                                                                                                                                                                                                                                                     I 
                                                                                                                                                                                                                               "(?<I_e>1[0-2]|0[1-9])" 
                                                                                                                                                                                                                                                     j 
                                                                                                                                                                                                                                 "(?<j_e>[0-3]\\d\\d)" 
                                                                                                                                                                                                                                                     M 
                                                                                                                                                                                                                                    "(?<M_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                     S 
                                                                                                                                                                                                       "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
                                                                                                                                                                                                                                                     s 
                                                                                                                                                                                                       "((?<OS_S_e>[0-5]\\d\\.\\d*)|(?<S_e>[0-6]\\d))" 
                                                                                                                                                                                                                                                     U 
                                                                                                                                                                                                                                    "(?<U_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                     w 
                                                                                                                                                                                                                                       "(?<w_e>[0-6])" 
                                                                                                                                                                                                                                                     u 
                                                                                                                                                                                                                                       "(?<u_e>[1-7])" 
                                                                                                                                                                                                                                                     W 
                                                                                                                                                                                                                                    "(?<W_e>[0-5]\\d)" 
                                                                                                                                                                                                                                                     Y 
                                                                                                                                                                                                                                      "(?<Y_e>\\d{4})" 
                                                                                                                                                                                                                                                     y 
                                                                                                                                                                                                                   "((?<Y_y_e>\\d{4})|(?<y_e>\\d{2}))" 
                                                                                                                                                                                                                                                    Oz 
                                                                                                                                                                                                                              "(?<Oz_Oz_e>[-*]\\d{4})" 
                                                                                                                                                                                                                                                    OO 
                                                                                                                                                                                                                          "(?<OO_e>[-*]\\d{2}:\\d{2})" 
                                                                                                                                                                                                                                                    Oo 
                                                                                                                                                                                                                                 "(?<Oo_e>[-*]\\d{2})" 
                                                                                                                                                                                                                                                     T 
"(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*((?<OS_s_T_S_e>[0-5]\\d\\.\\d*)|(?<S_s_T_e>[0-6]\\d))\\D*(?<p_s_e>AM|PM)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)\\D*((?<OS_s_S_e>[0-5]\\d\\.\\d*)|(?<S_s_e>[0-6]\\d))))" 
                                                                                                                                                                                                                                                     R 
                                                                                                              "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<M_s_T_e>[0-5]\\d)\\D*(?<p_s_e>AM|PM)(?![[:alpha:]]))|((?<H_s_e>2[0-4]|[01]\\d)\\D*(?<M_s_e>[0-5]\\d)))" 
                                                                                                                                                                                                                                                     r 
                                                                                                                                                              "(((?<I_s_e>1[0-2]|0[1-9])\\D*(?<p_s_e>AM|PM)(?![[:alpha:]]))|(?<H_s_e>2[0-4]|[01]\\d))" 
                                                                                                                                                                                                                                                     m 
                                                "((?<m_e>1[0-2]|0[1-9])|(((?<b_m_e>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)|(?<B_m_e>January|February|March|April|May|June|July|August|September|October|November|December))(?![[:alpha:]])))" 
                                                                                                                                                                                                                                                    OS 
                                                                                                                                                                                                                            "(?<OS_e>[0-5]\\d\\.\\d+)" 
                                                                                                                                                                                                                                                     z 
                                                                                                                                                "((?<Ou_Ou_e>Z)(?![[:alpha:]])|(?<Oz_Oz_e>[-*]\\d{4})|(?<OO_e>[-*]\\d{2}:\\d{2})|(?<Oo_e>[-*]\\d{2}))" 

$wday_names
$wday_names$abr
[1] "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"

$wday_names$full
[1] "Sunday"    "Monday"    "Tuesday"   "Wednesday" "Thursday"  "Friday"    "Saturday" 


$month_names
$month_names$abr
 [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"

$month_names$full
 [1] "January"   "February"  "March"     "April"     "May"       "June"      "July"     
 [8] "August"    "September" "October"   "November"  "December" 


> ymd_hms("2017-12-06 08:08:01")
[1] "2017-12-06 08:08:01 UTC"
@gadenbuie

This comment has been minimized.

Contributor

gadenbuie commented Dec 6, 2017

Maybe this is related to High Sierra and how R determines system timezones? I've also recently started to run into this warning and it seems that the warning is thrown the first time R interacts with a POSIXct (so maybe not dependent on calling lubridate:::.get_locale_regs() as in #615 (comment))

Clean R session from the terminal:

> lubridate::ymd_hms("2017-12-06 08:08:01")
Error in as.POSIXlt.POSIXct(x, tz) :
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
> lubridate::ymd_hms("2017-12-06 08:08:01")
[1] "2017-12-06 08:08:01 UTC"

And again in a clean session, but triggering the warning without calling a lubridate function.

> strptime(Sys.time(), "%F %T", tz = "UTC")
[1] "2017-12-06 17:27:18 UTC"
Warning message:
In as.POSIXlt.POSIXct(x, tz) :
  unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
> lubridate::ymd_hms("2017-12-06 08:08:01")
[1] "2017-12-06 08:08:01 UTC"

I called traceback() on both errors on a clean R session, here's what was returned:

> options(warn = 2)
> strptime(Sys.time(), "%F %T", tz = "UTC")
Error in as.POSIXlt.POSIXct(x, tz) :
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
> traceback()
13: doWithOneRestart(return(expr), restart)
12: withOneRestart(expr, restarts[[1L]])
11: withRestarts({
        .Internal(.signalCondition(simpleWarning(msg, call), msg,
            call))
        .Internal(.dfltWarn(msg, call))
    }, muffleWarning = function() NULL)
10: .signalSimpleWarning("unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'",
        quote(as.POSIXlt.POSIXct(x, tz)))
9: as.POSIXlt.POSIXct(x, tz)
8: as.POSIXlt(x, tz)
7: format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...)
6: structure(format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...),
       names = names(x))
5: format.POSIXct(x, ...)
4: format(x, ...)
3: as.character.POSIXt(x)
2: as.character(x)
1: strptime(Sys.time(), "%F %T", tz = "UTC")
> lubridate::ymd_hms("2017-12-06 08:08:01")
Error in as.POSIXlt.POSIXct(x, tz) :
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
> traceback()
19: doWithOneRestart(return(expr), restart)
18: withOneRestart(expr, restarts[[1L]])
17: withRestarts({
        .Internal(.signalCondition(simpleWarning(msg, call), msg,
            call))
        .Internal(.dfltWarn(msg, call))
    }, muffleWarning = function() NULL)
16: .signalSimpleWarning("unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'",
        quote(as.POSIXlt.POSIXct(x, tz)))
15: as.POSIXlt.POSIXct(x, tz)
14: as.POSIXlt(x, tz)
13: format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...)
12: structure(format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...),
        names = names(x))
11: format.POSIXct(.date_template, format = format)
10: format(.date_template, format = format)
9: unique(format(.date_template, format = format))
8: .get_locale_regs(locale)
7: guess_formats(x, orders, locale = locale, preproc_wday = TRUE)
6: unique(guess_formats(x, orders, locale = locale, preproc_wday = TRUE))
5: .best_formats(train, orders, locale = locale, select_formats,
       drop = drop)
4: .local_parse(x[to_parse], TRUE)
3: parse_date_time(dates, orders, tz = tz, quiet = quiet, locale = locale)
2: .parse_xxx_hms(..., orders = c("ymdTz", "ymdT"), quiet = quiet,
       tz = tz, locale = locale, truncated = truncated)
1: lubridate::ymd_hms("2017-12-06 08:08:01")

Session Info

> library(lubridate)
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 3.4.2 (2017-09-28)
 os       macOS High Sierra 10.13.1
 system   x86_64, darwin15.6.0
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 tz       <NA>
 date     2017-12-06Packages ───────────────────────────────────────────────────────────────────
 package     * version date       source
 clisymbols    1.2.0   2017-05-21 CRAN (R 3.4.0)
 lubridate   * 1.7.1   2017-11-03 CRAN (R 3.4.2)
 magrittr      1.5     2014-11-22 CRAN (R 3.4.0)
 Rcpp          0.12.14 2017-11-23 CRAN (R 3.4.3)
 sessioninfo   1.0.1   2017-09-11 Github (r-lib/sessioninfo@e813de4)
 stringi       1.1.6   2017-11-17 CRAN (R 3.4.2)
 stringr       1.2.0   2017-02-18 CRAN (R 3.4.0)
 withr         2.1.0   2017-11-01 CRAN (R 3.4.2)
Warning message:
In as.POSIXlt.POSIXct(Sys.time()) :
  unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
@vspinu

This comment has been minimized.

Member

vspinu commented Dec 6, 2017

Thanks @gadenbuie. That clarifies it then. It's not lubridate specific then and should be reported to the R folks.

Now I wonder, is this just a one-time warning or it does lead to incorrect results. In the OP I see converted from warning which presumably means options(warn=2) was set beforehand.

@gadenbuie

This comment has been minimized.

Contributor

gadenbuie commented Dec 6, 2017

That part might be lubridate related? lubridate::ymd_hms("2017-12-06 08:08:01") gives me an error even though I didn't set warn = 2 (and I've checked that it's at 0), tested both in a terminal session and a script called via Rscript. This means an R script with an early call to lubridate::ymd_hms() or similar might stop because of the conversion of the warning to an error.

This gives an error and halts execution:

$ Rscript -e 'lubridate::ymd_hms("2017-12-06 08:08:01")'
Error in as.POSIXlt.POSIXct(x, tz) :
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
Calls: <Anonymous> ... structure -> format.POSIXlt -> as.POSIXlt -> as.POSIXlt.POSIXct
Execution halted

but this doesn't

$ Rscript -e 'lubridate::ymd_hms(Sys.time())'
[1] "2017-12-06 18:33:59 UTC"
Warning message:
In as.POSIXlt.POSIXct(x, tz) :
  unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'

vspinu added a commit that referenced this issue Dec 6, 2017

@vspinu

This comment has been minimized.

Member

vspinu commented Dec 6, 2017

Right. Lubridate actually sets warn level there to catch such system warnings. Most of the time it indicates a missing locale. I have just made that setup a bit more localized as originally intended. Would it be possible for you to check if the github version doesn't throw?

@gadenbuie

This comment has been minimized.

Contributor

gadenbuie commented Dec 6, 2017

It works! 👍

> lubridate::ymd_hms("2017-12-06 08:08:01")
[1] "2017-12-06 08:08:01 UTC"
Warning message:
In as.POSIXlt.POSIXct(x, tz) :
  unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/New_York'
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 3.4.2 (2017-09-28)
 os       macOS High Sierra 10.13.1
 system   x86_64, darwin15.6.0
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 tz       <NA>
 date     2017-12-06Packages ───────────────────────────────────────────────────────────────────
 package     * version date       source
 clisymbols    1.2.0   2017-05-21 CRAN (R 3.4.0)
 lubridate     1.7.1   2017-12-06 Github (tidyverse/lubridate@1dce6d3)
 magrittr      1.5     2014-11-22 CRAN (R 3.4.0)
 Rcpp          0.12.14 2017-11-23 CRAN (R 3.4.3)
 sessioninfo   1.0.1   2017-09-11 Github (r-lib/sessioninfo@e813de4)
 stringi       1.1.6   2017-11-17 CRAN (R 3.4.2)
 stringr       1.2.0   2017-02-18 CRAN (R 3.4.0)
 withr         2.1.0   2017-11-01 CRAN (R 3.4.2)
@vspinu

This comment has been minimized.

Member

vspinu commented Dec 6, 2017

Great. Thank you guys for all the feedback!

@vspinu vspinu closed this Dec 6, 2017

@szapataa

This comment has been minimized.

szapataa commented Dec 7, 2017

#This will work regardless of location and will persist across sessions (and is OS independent)
#find timezone through online api using httr and rgeolocate

setme <-
"Sys.setenv(TZ='America/New_York') #some default not get any errors
invisible(loadNamespace('rgeolocate'))
invisible(loadNamespace('httr'))
mytz <- rgeolocate::ip_api(httr::content(httr::GET('https://api.ipify.org?format=json'))[1])[['timezone']]
Sys.setenv(TZ=mytz)"

cat(setme,file=file.path(R.home(),'etc/Rprofile.site'),sep='\n')

@gadenbuie

This comment has been minimized.

Contributor

gadenbuie commented Dec 11, 2017

Just saw this was fixed in R 3.4.3:

A workaround has been added for the changes in location of time-zone files in macOS 10.13 ‘High Sierra’ and again in 10.13.1, so the default time zone is deduced correctly from the system setting when R is configured with --with-internal-tzcode (the default on macOS).

@Waqasejaz

This comment has been minimized.

Waqasejaz commented May 4, 2018

@szapataa your solution fixed the problem for good :-) thanks for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment