8

I have just installed the latest version of lubridate (1.7.3) and am getting the following error

> x <- as.POSIXct("2014-06-01 08:21:59 BST")
> for (j in 1:1e4){
     dum <- lubridate::force_tz(x, tzone = 'UTC')
 }
> for (j in 1:1e8){
     dum <- lubridate::force_tz(x, tzone = 'UTC')
 }
Error in C_force_tz(time, tz = tzone, roll) : 
  CCTZ: Unrecognized timezone of the input vector: ""
> j
[1] 580

Strange that if I continue with 1e4 after the first loop I don't get it, and if I start with 1e8 I don't get it. Any ideas?

smci
  • 32,567
  • 20
  • 113
  • 146
user1165199
  • 6,351
  • 13
  • 44
  • 60
  • 3
    I can also reproduce this using your code. R3.4.4 , lubridate - 1.7.3 – user2957945 Apr 09 '18 at 14:55
  • 3
    I believe this issue was solved in this [commit](https://github.com/tidyverse/lubridate/commit/c4636354e72ce1e6c427784cca94292b58a9271b) – luigi Apr 09 '18 at 16:53

2 Answers2

1

This has now been resolved in the github version of lubridate https://github.com/tidyverse/lubridate/commit/c4636354e72ce1e6c427784cca94292b58a9271b.

They are hoping to release the fix this week

user1165199
  • 6,351
  • 13
  • 44
  • 60
-1

I tried doing this exactly the way you said it, and the loop wouldn't even go through all 1e8 of the values without crashing my machine (which is pretty powerful, so that was a surprise). Also, I noticed that the original dum that was produced only had one date, and the rest were NA.

Will this do the same thing you need? I am guessing that you need to initialize a vector with Date objects. It worked very quickly for me:

> dum <- rep(lubridate::force_tz(x, tzone = 'UTC'),100000000)
> str(dum)
   POSIXct[1:100000000], format: "2014-06-01 08:21:59" "2014-06-01 08:21:59" "2014-06-01 08:21:59" "2014-06-01 08:21:59" ...
> system.time(rep(lubridate::force_tz(x, tzone = 'UTC'),100000000))
   user  system elapsed 
   0.31    0.24    0.55 
mysteRious
  • 4,102
  • 2
  • 16
  • 36
  • Thanks for your help, but the above is just to try and get a reproducable example of what I think is a bug in lubridate, I don't actually need to run the above. But it sounds like you didn't get the same error but it just didn't finish going through the loop? For me it crasged quite soon after starting the `1e8` loop – user1165199 Apr 06 '18 at 21:19