I'm working with some data from the Canary Islands. The timezone in this Spanish region is officially WET/WEST. But this timezone also coincides with the British one for example - GMT/BST. Both change same hour and same day.
I tried to convert some characters (day-month-year) to dates using lubridate library and I am surprised that depending on the timezone I use, the function dmy() can fail to parse or not.
When I tried to parse directly all the date column using the timezone in dmy() tz = "Atlantic/Canary" - which is WET/WEST - it returns 9 failings to parse. This ones:
example = c("06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980", "06/04/1980",
"23/10/2008", "27/03/2017", "24/02/2011", "06/04/1980")
However, trying them alone, it successfully converts 3 / 9, unlike before.
> dmy(example, tz = "Atlantic/Canary")
[1] NA NA NA NA NA "2008-10-23 WEST"
[7] "2017-03-27 WEST" "2011-02-24 WET" NA
Warning message:
6 failed to parse.
And more surprisingly, If I set the timezone to British, it works perfectly. Also, the British one works perfectly for all the column at once:
> dmy(example, tz = "Europe/London")
[1] "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "1980-04-06 BST" "2008-10-23 BST" "2017-03-27 BST"
[8] "2011-02-24 GMT" "1980-04-06 BST"
I don't understand why the 3 cases are different. My original df is 10 million rows. However, even with the list of 9 dates, I don't know why the dmy() function output differs using one tz or another. If I were using hours, maybe it would be for some change, but that is not the case. Any answer will be appreciated.