require(data.table) # built 2017-10-31
as.IDate("20170929", "%Y%m%d")
# Error in charToDate(x) :
# character string is not in a standard unambiguous format
as.Date("20170929", "%Y%m%d")
# [1] "2017-09-29"
This worked fine in 1.10.4 and also on current CRAN version, but fails on devel.
Output of sessionInfo()
# R version 3.3.2 (2016-10-31)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows Server >= 2012 x64 (build 9200)
#
# locale:
# [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
# [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
# [5] LC_TIME=English_United States.1252
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] data.table_1.10.5
#
# loaded via a namespace (and not attached):
# [1] tools_3.3.2 yaml_2.1.14
%Y%m%d is being passed as the tz argument:
as.IDate("20170929", format = "%Y%m%d")
# [1] "2017-09-29"
Here's the commit that changed, I think that was from @jangorecki's PR #1393
Personally I'm in the habit of always writing out format =, what do you think?
I don't think there's a need for tz argument for .default method. That's what breaks things in this scenario. There's a tz argument added for .POSIXct method in the same PR, which is also consistent with as.Date and should be sufficient IMHO.
Agreed. Perhaps Jan had something in mind...
Might be my fault as I had a hand in that PR. I'll take a look ...
Awesome! Thanks for the super-quick fix!
@MichaelChirico I also write out format; in some testing I've found it to be slightly faster, which adds up in data.table-sized data structures.