Skip to content
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

[bug] possible regression in as.IDate. #2453

Closed
arunsrinivasan opened this issue Oct 31, 2017 · 6 comments
Closed

[bug] possible regression in as.IDate. #2453

arunsrinivasan opened this issue Oct 31, 2017 · 6 comments

Comments

@arunsrinivasan
Copy link
Member

@arunsrinivasan arunsrinivasan commented Oct 31, 2017

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
@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Oct 31, 2017

%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?

@arunsrinivasan
Copy link
Member Author

@arunsrinivasan arunsrinivasan commented Oct 31, 2017

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.

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Oct 31, 2017

Agreed. Perhaps Jan had something in mind...

@mattdowle
Copy link
Member

@mattdowle mattdowle commented Oct 31, 2017

Might be my fault as I had a hand in that PR. I'll take a look ...

@mattdowle mattdowle added this to the v1.10.6 milestone Oct 31, 2017
@mattdowle mattdowle closed this in 4828560 Oct 31, 2017
@arunsrinivasan
Copy link
Member Author

@arunsrinivasan arunsrinivasan commented Oct 31, 2017

Awesome! Thanks for the super-quick fix!

@aadler
Copy link

@aadler aadler commented Nov 1, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants